This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
i am beginner in c#. How can i add Pieseries from code. i try this XAML
in c#
|
|
|
Hello Thanks for trying out our WPF chart controls. Your code is very close to working, all you need to do is add this code to the PieSeries tag in your xaml:
The pie series supports a couple of different data types by default. If you set the ItemsSource to be just a collection of numbers for example, the PieSeries will automatically use each number to generate each pie slice. We also provide a StringDouble data type which lets you plot pairs of strings and numbers - just like what you are doing here. So if set the ItemsSource to be a collection of our StringDouble type, then the PieSeries will automatically know how to plot this for you. KeyValuePair however is not handled by default. (though I've made a note to include this in a future version). But you can still use it by simply telling the PieSeries how to read values from it. That is what the code I posted will do for you. The DataBinding property tells the PieSeries how to get the numbers to plot in each pie slice - when using KeyValuePair, this of course should be the Value property which you will see in the code I posted. The TitleBinding property is optional, and tells the pie series what to display in the Legend. So when you run up your code including these bindings, you will see the pie chart will plot your data, and the strings you set will appear in the legend items. So setting these properties is how you can tell the pie series how to plot values such as KeyValuePair and even custom data objects that you implement yourself. If you use our StringDouble datatype though, you won't need to set these properties as the pie series will automatically know which properties to use. I hope this helps you continue using the PieChart control. Let me know if you have further questions about any of this. -Jason Fauchelle |
|