
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
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

foreach (TickPoint point in radchartarea.AdditionalYAxes[0].TickPoints)
{
if (point.Value < 0)
{
point.Label = " ";
}
}
Please let us know about any alternative solution for this.
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

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
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";
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);
foreach (TickPoint point in axisY1.TickPoints)
{
if (point.Value < 0)
{
point.Label = " ";
}
}
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 >>

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.

Can I also remove the lines which are coming along with numbers as shown in the attachment.please Reply ASAP.
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 >>