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

Adjust AxisX.LabelStep when zooming in categorical chart

3 Answers 44 Views
Chart
This is a migrated thread and some comments may be shown as answers.
AndrewRichards
Top achievements
Rank 1
AndrewRichards asked on 16 Nov 2011, 11:16 PM
Hello,

I have a data bound Chart with zooming and scrolling enabled. There are lots of points on the chart and since it's a (DateTime) categorical chart, the X axis shows a LOT of ticks. 

chart.DefaultView.ChartArea.ZoomScrollSettingsX.MinZoomRange = range;
chart.DefaultView.ChartArea.ZoomScrollSettingsX.RangeStart = 0.0;
chart.DefaultView.ChartArea.ZoomScrollSettingsX.RangeEnd = range * 2;
chart.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom;
  
chart.DefaultView.ChartArea.AxisX.LabelStep = 1;
chart.DefaultView.ChartArea.AxisX.StepLabelLevelCount = 3;
chart.DefaultView.ChartArea.AxisX.MajorGridLinesVisibility = Visibility.Visible;
chart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "MMM yyyy";


The problem is that when fully zoomed out (RangeStart = 0.0 and RangeEnd = 1.0), the X-axis ticker labels start to overlap. Is there an event or some other way to adjust the AxisX.LabelStep when zooming in and out ?

I've also attached a screenshot of the problem.

Thanks!

3 Answers, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 21 Nov 2011, 11:10 AM
Hi Andres,

What you can do is wire to the PropertyChanged event like this:

void MainWindow_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if ((RangeStart == 0.0) && (RangeEnd == 1.0))
            {
                radChart.DefaultView.ChartArea.AxisX.LabelStep = 2;
            }
        }
This way when your chart has RangeStart = 0.0 and RangeEnd = 1.0 values, it will set the label step to 2 or any other value that best fits your scenario.

Kind regards,
Peshito
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
AndrewRichards
Top achievements
Rank 1
answered on 22 Nov 2011, 03:54 PM
Not sure if I understand correctly. I have the grid on a UserControl (no access to Window). Is there an event I can listen to ?  Any other way ?
0
Accepted
Peshito
Telerik team
answered on 24 Nov 2011, 04:24 PM
Hi Andres,

Please disregard my previous suggestion and excuse me for inconvenience caused.

Yes, there is another way. You can wire to the ZoomScrollSettingsX PropertyChanged event like this:
void ZoomScrollSettingsX_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if ((RangeStart == 0.0) && (RangeEnd == 1.0))
            {
                radChart.DefaultView.ChartArea.AxisX.LabelStep = 2;
            }
        }

Regards,
Peshito
the Telerik team

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

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