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

StackedBarChart in XAML/DataSeries flagged errors

3 Answers 93 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 1
Ian asked on 04 May 2009, 02:53 PM
The Demo site shows a Stacked Bar Chart and states "This is accomplished by setting the GroupName property of each StackedBarSeriesDefinition".  A reply to another thread repeats this assertion. But there is no such "GroupName" property on this StackedBarSeriesDefinition class and attempting to use one in XAML causes a XAMLParse exception.

The "code behind" for the demo, which might give some clues, doesn't help because everything is locked away in a "sample" dll.

I was going to ask if someone could provide a XAML snippet showing how a StackedBarChart like that shown in the demo can be accomplished but after a LOT of trial and error I managed to create one using the XAML shown at the bottom of this post. Notice the complete absence of anything to do with "GroupName"! Hopefully it might help someone else struggling with this stuff, the way I have been over the last few days!

At the moment, I'm using the "Creating Chart Declaratively" page of the documentation to try and work out how to use the charting functionality, but it's very thin on explanation or any kind of proper charting overview. The simple code given on that page builds but causes errors (red squiggly lines) to be shown for the ChartArea.DataSeries element ("Writable property or collection expected") and for the DataSeries declaration that immediately follows it ("Invalid type"). Is there any way to remove these as they get in the way of understanding where any REAL errors in the XAML might be or should this just be considered "business as usual" for Telerik controls (I've got used to endless exceptions in the Design View but had hoped the XAML view would be clean).

Telerik, you seem to have some nice controls that can be coerced into delivering what customers want but if you want trial versions to turn into sales you really need to sort something out with regard to documentation and the specific detail of the answers given here (I'm still scratching my head on the "theme selection" snippet - I have 3 different 'theme' dlls I'm supposed to add but somehow they all magically resolve to the same "telerik" namespace prefix used in XAML?!).

Developers purchase controls to increase productivity but the ramp-up time on Telerik controls because of poor documentation/misinformation given is huge. The demo's purport to show code but invariably the most interesting ones just show a few lines, with most of the required information hidden away in dlls. Comments like "use the GroupName property" or "set SmallIncrement" don't help at all when these properties don't exist and just lead to wasted time and frustration, where a simple line or two of code snippet would have solved the problem.  MS advice continually recommends putting all the UI into declarative XAML so demo's/training information that hides everything away in dlls really isn't very helpful!

                           <tkc:ChartDefaultView.ChartArea>
                                <tkc:ChartArea LegendName="Stack1">
                                    <tkc:ChartArea.DataSeries>
                                        <tkc:DataSeries Label="Pension Fund">
                                        <tkc:DataSeries.Definition>
                                            <tkc:StackedBarSeriesDefinition  />
                                        </tkc:DataSeries.Definition>
                                            <tkc:DataPoint YValue="3000" />
                                            <tkc:DataPoint YValue="8000" />
                                            <tkc:DataPoint YValue="11000" />
                                        </tkc:DataSeries>
                                    <tkc:DataSeries Label="Stack2">
                                        <tkc:DataSeries.Definition>
                                            <tkc:StackedBarSeriesDefinition />
                                        </tkc:DataSeries.Definition>
                                        <tkc:DataPoint YValue="4000" />
                                        <tkc:DataPoint YValue="6000" />
                                        <tkc:DataPoint YValue="8000" />
                                    </tkc:DataSeries>
                                </tkc:ChartArea.DataSeries>
                            </tkc:ChartArea>

Thanks for reading.

3 Answers, 1 is accepted

Sort by
0
Vladimir Milev
Telerik team
answered on 07 May 2009, 10:44 AM
Hello Ian,

First of all let me apologize for the unpleasant experience you've had with our control. 

I would like to take the time to clear the confusion regarding the StackGroup feature. Consider the following code snippet:

Vladimir Milev
0
Ian
Top achievements
Rank 1
answered on 07 May 2009, 11:14 AM
Hi Vladimir

I'd love to consider the "following code snippet". But it appears to have gone AWOL (at least when this thread is viewed in IE8 or if I view the copy of the response emailed to me)?
0
Accepted
Vladimir Milev
Telerik team
answered on 08 May 2009, 02:03 PM
Hi Ian,

I'm sincerely sorry but there seems to be a bug in our ticketing system and my response was lost. I will retype it here.

So hopefully you will now be able to see the following code snippet :)
DataSeries series1 = new DataSeries(); 
series1.Add(new DataPoint(1)); 
series1.Add(new DataPoint(4)); 
series1.Add(new DataPoint(6)); 
series1.Add(new DataPoint(3)); 
series1.Definition = new StackedBarSeriesDefinition(); 
//series1.Definition.AggregationGroup.GroupName = "stack2"; 
 
DataSeries series2 = new DataSeries(); 
series2.Add(new DataPoint(3)); 
series2.Add(new DataPoint(2)); 
series2.Add(new DataPoint(1)); 
series2.Add(new DataPoint(4)); 
series2.Definition = new StackedBarSeriesDefinition(); 
//series2.Definition.AggregationGroup.GroupName = "stack1"; 
 
RadChart1.DefaultView.ChartArea.DataSeries.Add(series1); 
RadChart1.DefaultView.ChartArea.DataSeries.Add(series2); 

The code above will cause the chart control to stack both bar series on top of each other. This is because by default all stacked series share the same stack group name (which is an empty string). However, if you uncomment those two lines the chart will not stack the bars. The reason for this is that they are now in different stack groups and RadChart only stacks one series over another if they share the same stack group name.  This is where the GroupName property comes into play and how to set it.

By the way - the syntax:
series2.Definition.AggregationGroup.GroupName = "stack1";
is equivalent to:
series2.Definition = new StackedBarSeriesDefinition("stack1");

The constructor parameter is just a shortcut to set the property. Nevertheless your feedback is good because we did not use that property in our demo code and I agree with you that a lot of demo functionality is hidden away in helper classes and in DLLs. We will try to improve that for Q2.

About the red squiggly lines - I immediately checked this and they appear to be fine in the development branch. Whatever the problem was it appears to have been solved.



I hope my response clears things up a bit. I wish to thank you for taking the time to write to us - we really appreciate good feedback and will do our best to improve things as much as we can.

Sincerely yours,
Vladimir Milev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Chart
Asked by
Ian
Top achievements
Rank 1
Answers by
Vladimir Milev
Telerik team
Ian
Top achievements
Rank 1
Share this question
or