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

BarSeries in a RadCartesianChart left aligned

1 Answer 91 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Indu-Sol
Top achievements
Rank 1
Indu-Sol asked on 27 Jul 2017, 09:36 AM

Hi everyone,

i wanna left align a BarSeries with a CategoricalAxis in a RadCartesianChart (barseries_target). Per default the BarSeries is using the whole space (barseries_origin).

Is there any possibility to get the left align worked?

 

Thanks in advance.

Thomas

 

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 28 Jul 2017, 12:56 PM
Hello Thomas,

In RadChartView there is no notion for series alignment. When you have a BarSeries, which is a categorical series, the chart will create a category slot on the CategoricalAxis for each distinct category value. In your case those are 2, 5, 6, 8, 16, 32. 

To achieve your requirement and display categories from 1 to 28 you will need to add dummy data points in the BarSeries ItemsSource (or DataPoints) after you load the original data (from 2 to 32). The dummy points can have set their Value to null and Category to the corresponding category from 1 to 28.

Note that the chart won't allow you to have categories with the same value. For example, if you have two items with category set to 2 the chart will combine them in the same category. So, you can't have duplicate category slots drawn on the axis. To resolve this you can set the categories of the data items to unique names and use LabelTemplate for the CategoricalAxis to display text differen than the original category value. 

I prepared a small example demonstrating such approach. I hope it helps.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
Chart
Asked by
Indu-Sol
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or