How to create data series for RadChart?

2 posts, 0 answers
  1. Rob
    Rob avatar
    238 posts
    Member since:
    Jan 2009

    Posted 26 Mar 2010 Link to this post

    In the RadChart examples on the Telerik website, the data supplied to the charts is structured as value pairs (i.e. Month – TotalSales).  This allows simple and straightforward data displaying by mapping one field to XCategory and another to YValue.  Essentially the data comes with some pre-aggregation already done.

    In our application the chart data are supplied in raw form as the set of items having {field_1, field_2, … ,field_n} therefore the aggregation is required for achieving any meaningful data representation; otherwise the chart will create separate bar for each dataset item with only numeric  fields suitable for mapping to the Y axis. Furthermore we want to take advantage of the built-in RadChart aggregation to have flexible user interface that allows data presentation in different profiles.

    However the use of aggregation had some undesired effects we have not been abe to overcome, please advise what would be our best solution:

    Scenario 1.

    The aggregation is applied to one of the fields of the data item; that field is mapped as XCategory, another field is mapped as YValue with the desired aggregation function. 

    The X axis is broken into segments according to actual amount of groups for the group-by field. The bar representing the aggregated value is drawn within each segment with the label placed under the segment. The problem is that the bar does not occupy the entire width of allocated segment and positions differently for each segment.  Apparently despite the fact that each segment should represent only one group it still allocates inside the space for the bars representing all groups however only the relevant bar is displayed.

    Scenario 2.

    The aggregation is applied to one of the fields of the data item however unlike the Scenario 1 that field is mapped as LegendLabel, another field is mapped as YValue with the desired aggregation function.

    The appearance of the bars has improved, they occupy more chart space however the X axis is no longer broken into group segments and the group labels are no longer displayed under the bars. Instead bars are placed into one section without the gap having strange label “1” underneath.

    Scenario 3.

    As the workaround a fake constant field has been added to the data item and fake aggregation on that field has been set for the chart. The idea behind that fake aggregation on constant field was to ensure that its results always get into single group.  Also like in secenario 1 the actual aggregation was applied to one of the fields of the data item; that field was mapped as XCategory, another field was mapped as YValue with the desired aggregation function.

    The X axis is broken into group segments with the labels underneath. The bars evenly occupy the space within their segments. The problem is that all bars are painted in the same colour and the legend does not show what is represented by each bar.

    Is there any solution for this situation; is there way to achieve something like combination of the results 1 (colours and legend) and 3 (bars alignment). 

  2. Ves
    Ves avatar
    2926 posts

    Posted 31 Mar 2010 Link to this post

    Hello Rob,

    Some words on these scenarios:
    1. There are 4 DataSeries with 1 DataPoint (bar) in each of them. Each datapoint has its own XCategory, so the datapoints appear at different positions along the X axis. Still, as you have noticed, RadChart knowing that there are 4 series calculates the bar width, so that there is enough room for 4 bars at every position in X axis.
    2. Close to #1, but no XValue -- 4 DataSeries with one bar in each. All the bars appear at the first position, so there is only 1 position in X axis. Basically - stretched #1.
    3. One DataSeries with 4 bars. Each position in X axis should contain only 1 bar, so the bars are wider than those in #1.
    You can achieve the desired result using #3 and setting the SeriesDefinition.LagendDisplayMode property to LegendDisplayMode.DataPointLabel. This forces RadChart not only to display a legend item for each series item, but also to apply the series palette item-wise.

    Best regards,
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top