Hi Jason,
Thanks for contacting Syncfusion support. We have analyzed your query and prepared sample based on your requirement. Currently we are not having support category axis (binding string values for axis). So for the pie chart we have bound only the Y-values and chart will consider the index as X-value. In the sample, we have retrieved data from the database and bound this data to the chart. Please follow the below code example.
[CS]
var data = PullData();
ChartDataBindModel Series1Model = new ChartDataBindModel();
Series1Model.DataSource = data;
Series1Model.YNames = new string[] { "YValue" };
ChartSeries series1 = new ChartSeries();
series1.Type = ChartSeriesType.Pie;
|
In the above code we bound “data” as datasource for the series. Data contains string and integer value. For the YNames we have bound “YValue” in the data. Now the chart will be render like below.
If the DisplayText is set as true, then y-values are displayed in the labels for pie chart. Please refer the below screenshot.
If you want to modify this labels with the x-values bound for the datasource please follow the below code.
series1.Style.DisplayText = true;
or (int k = 0; k < data.Count; k++)
{
series1.Styles[k].Text = data[k].XValue;
}
|
In the above code, we have set displaytext as true and changed the label text for the each points with the string values from the database. Now the chart labels will modified like below.
We have prepared sample as per your requirement. Please find the sample from below location
Sample link:
http://www.syncfusion.com/downloads/support/forum/123394/ze/Pie-1320397341
Regards,
Sanjith.