开发者

Programmatically controlling Chart in Silverlight toolkit

I want to control the x and y 开发者_运维问答axis of a multi series line charts available in Silverlight toolkit from the C# code. I am not able to find any appropriate example using google. Any kind of example or pointers would be appreciated!

EDIT:

This is what I have done so far:

<toolkit:Chart Canvas.Left="104" Canvas.Top="18" Name="chartCompare" Title="Compare Series" Height="285" Width="892">
<toolkit:LineSeries
         Title="SP1"
         Name="Series1"/>
</toolkit:Chart>

And in the code behind I am trying this:

Series1.ItemsSource = ObjectList;

Series1.IndependentValuePath = "Val1";
Series1.DependentValuePath = "Val2";

Where ObjectList is a List of Objects which has val1 and val2 as its property. But it is throwing an error when I run this in Line "Series1.ItemsSource = ObjectList;" saying "Object reference not set to an instance of an object..". I have initialised and set its value just in the line before it. Actually I have set this as an item source for a data grid in the line before it and it works fine.


i tried your example and i got "out of index" exeption

this form is better

   LineSeries Series1 = new LineSeries();
    Series1.IndependentValuePath = "Val1";
    Series1.DependentValuePath = "Val2";
    Series1.ItemsSource = ObjectList;
    chart.Series.Add(Series1);


I need to add this before using the Series1:

//Line to be inserted
LineSeries Series1 = chart.Series[0] as LineSeries;

Series1.IndependentValuePath = "Val1";
Series1.DependentValuePath = "Val2";
Series1.ItemsSource = ObjectList;

Thanks...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜