This is a migrated thread and some comments may be shown as answers.

Hide Y-Axis labels

8 Answers 313 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Manishkumar
Top achievements
Rank 1
Manishkumar asked on 04 Aug 2011, 10:53 AM
Hi,

I have bar chart with  Y-Axis having range from 0 to 100. On the same chartarea I have one more Y-Axis(right hand side) having range from -100 to 100 in the step of 50. i want to make -100, -50 label values invisible so that 0 starts in the middle of the Y-axis.  I am using this Y-Axis for showing line chart. Please help me achieve this.

8 Answers, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 09 Aug 2011, 12:46 PM
Hi Manishkumar,

This feature is not supported out of the box. However there is a workaround you could use in order to achieve similar scenario. You can simply hide your YAxis negative tick points by setting their values to white space string like this:

foreach (TickPoint point in axisY1.TickPoints)
{
     if (point.Value < 0)
     {
          point.Label = " ";
     }
}

Please find attached a sample project where you could see how it can be accomplished.

In case this solution does not fit your needs, we will need a sample screenshot of the desired result as well as any additional information that will be helpful.

All the best,
Peshito
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Manishkumar
Top achievements
Rank 1
answered on 17 Aug 2011, 06:47 AM
The Solution Provided by you is not working,We have used the same way.

foreach (TickPoint point in radchartarea.AdditionalYAxes[0].TickPoints)
{
     if (point.Value < 0)
     {
          point.Label = " ";
     }
}

Please let us know about any alternative solution for this.
0
Peshito
Telerik team
answered on 19 Aug 2011, 02:25 PM
Hello Manishkumar,

I am unable to reproduce the issue you mentioned. I have tried to use the same code as you did and as a result the the second Y-Axis labels less then zero are hidden. You can see this from the screenshot attached as well as the sample project which I've modified as follows:
foreach (TickPoint point in radChart.DefaultView.ChartArea.AdditionalYAxes[0].TickPoints)
            {
                if (point.Value < 0)
                {
                    point.Label = " ";
                }
            }

Please note that the additional Y-Axis should be added before you use it in the foreach statement.
radChart.DefaultView.ChartArea.AdditionalYAxes.Add(axisY1);

Best wishes,
Peshito
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Manishkumar
Top achievements
Rank 1
answered on 23 Aug 2011, 02:00 PM
Still We are not able to resolve the issue by using your solution.Please find the below code snippet .


radchartarea.AdditionalYAxes.Add(axisy);

radchartarea.AdditionalYAxes[0].AutoRange =

 

false;

 

radchartarea.AdditionalYAxes[0].AddRange(-_intMaxValYAxisSec, _intMaxValYAxisSec + 0.10, (_intMaxValYAxisSec * 2) / 4);

radchartarea.AdditionalYAxes[0].PlotAreaAxisVisibility =

 

Visibility.Collapsed;

 

radchartarea.AdditionalYAxes[0].DefaultLabelFormat =

 

"#VAL{P0}";

 



Here We are adding the additional Y -Axis --axisY. And after that we are making te value of lable as Blank.

 

 

foreach (TickPoint point in radchartarea.AdditionalYAxes[0].TickPoints)

 

{

 

 

if (point.Value < 0)

 

{

point.Label =

 

" ";

 

}

}


but still the value get displayed.
Please let us know is it the right way .Please provide the solution for this
0
Peshito
Telerik team
answered on 26 Aug 2011, 08:41 AM
Hi Manishkumar,

From the code you've shared I see that you are accessing the additional axis by its index.

Try using another approach like this one for instance:
first set an AxisName to your series:
secondSeriesMapping.SeriesDefinition.AxisName = "secondary";
then define the additional axis:
AxisY axisY1 = new AxisY();
axisY1.AxisName = "secondary";
axisY1.AutoRange = false;
axisY1.MinValue = -100;
axisY1.MaxValue = 100;
axisY1.Step = 50;
radChart.DefaultView.ChartArea.AdditionalYAxes.Add(axisY1);
create the foreach statement:
foreach (TickPoint point in axisY1.TickPoints)
            {
                if (point.Value < 0)
                {
                    point.Label = " ";
                }
            }
as a result you should end up with hidden labels for the additional axis points with value less than zero.

Best wishes,
Peshito
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Manishkumar
Top achievements
Rank 1
answered on 01 Nov 2011, 08:08 AM
HI;
 If Give the minvalue as -100,Maxvalue as 100,Step as 50 then the above solution with for loop works.
But if I give the value as  minvalue as -1.10,Maxvalue as 1.10,Step as 0.5  then it does not work with above solution and not able to hide the values can you please Provide me the solution ASAP.
same thing was able to replicate in the source code posted in this soluiton.
U can replicate it by changing the minvalue,maxvalue and step.
Please Provide Solution ASAP.
0
Manishkumar
Top achievements
Rank 1
answered on 02 Nov 2011, 08:27 AM
Hi;

Can I also remove the lines which are coming along with numbers as shown in the attachment.please Reply ASAP.
0
Accepted
Peshito
Telerik team
answered on 03 Nov 2011, 04:32 PM
Hi Manishkumar,

Chart axes ticks visibility can be controlled using the MajorTicksVisibility and MinorTicksVisibility properties. More about Ticks can be found in one of our help topics here.

Regarding your other issue, because the AutoRange is set to false, you will have to manually set the best appropriate values for your axis. In your case, try setting the Step to 0.4 instead of 0.5 which will make the chart to hide the negative values.

Kind regards,
Peshito
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Chart
Asked by
Manishkumar
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Manishkumar
Top achievements
Rank 1
Share this question
or