-
There is one problem with your code: the event handler "pieChart_DataStructureCreated" will never be called since it's defined after the chart DataSource has been set. When you set the data source, the chart data stricture including data points is created and - at the end of that process - the handler is invoked. Therefore, the handler has to be defined before the data source is set. I don't know what the handler is doing, but it seems like that doesn't cause the problem you...
-
The property Series.Label is the legend item text for a legend items related to a series. If this property is not set, Series.Id will be used. For Pie/Doughnut type of charts, legend items are related to data points. Again, DataPoint.Label will be used if it is set, otherwise DataPoint.X coordinate will be used. DataPoint.Label can be set in code behind, once the data structure is created, i.e. after Chart.DataSource is set. The other way is to assign it from data source. Yo can select the input...
-
When you have multiple series, the most common way is to provide data item type with values for all series. In this case it would be: public class TwoYearData { int Month { get ; set ; } double Value2000 { get ; set ; } double Value2001 { get ; set ; } } However, you might not know how many (and what) years are there when coding the solution. In that case we are talking “ Dynamic Series ”. That’s a feature of the charting control that makes possible creation of series at run time...
-
The problem is that you cannot create DataPoints in code. Instead, you should assign an IEnumerable object to the chart.DataSource property. This code should produce a nice chart: Chart _chart; Series _dataSeries; public class Data { public string X { get ; set ; } public double Y { get ; set ; } } private void SetupNewChart() { _chart = new Chart(); _chart.ChartKind = ChartKind.Cylinder; _dataSeries = new Series(); _chart.DataSeries.Add(_dataSeries); _chart.XValue = " X "; _dataSeries...
-
The easiest way to do this is to encapsulate your chart within a user control. This approach makes possible setting all chart properties in XAML within the wrapper control. So, when you instantiate the wrapper in code behind, the chart setup defined in XAML is used during the chart load. This approach is similar to instantiating chart in the code behind, but if you don’t use the wrapper, you have to set all chart properties in code behind, which might be less comfortable than using XAML. Removing...