When makeing a PieSeries chart with telerik:RadHtmlChart
Would it be possible and if so how would you set the DataFieldY attribute to the name of the fist column in an Excel upload?
<telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Transitions="false" Width="450"
Height="450" Skin="Silk">
<Legend>
<Appearance Visible="false"></Appearance>
</Legend>
<PlotArea>
<Series>
<telerik:PieSeries DataFieldY="Number" NameField="Fruit" ExplodeField="IsExploded">
</telerik:PieSeries>
</Series>
</PlotArea>
</telerik:RadHtmlChart>
This would need to be done by client-side binding.
public string chartData = "[{'Fruit': 'Apple','Number': 8, 'Color': 'Blue'},{'Fruit': 'Orange','Number': 4, 'Color': 'Purple'},{'Fruit': 'Banana','Number': 3, 'Color': 'Red'},{'Fruit': 'Grapes','Number': 12, 'Color': 'Pink'},{'Fruit': 'Peace','Number': 2, 'Color': 'Orange'}]";
var jsonChartData = "<%=chartData%>";
var RadHtmlChart1 = $find('<%=RadHtmlChart1.ClientID %>');
RadHtmlChart1.set_dataSource(jsonChartData);
RadHtmlChart1.set_transitions(true);
RadHtmlChart1.repaint();
You can't do that directly. The control can work with several data sources:
JavaScript arrays of JSON literals (as you have pasted)
an IEnumerable collection (provided by a declarative data source control like SqlDataSource; or a List; or a DataTable, you get the idea)
Excel files are neither.
You would need to parse the excel file somehow to get the needed collection:
perhaps the Microsoft Interop assemblies can help
or the Telerik SpreadProcessing (e.g.,
ICellValue value = this.radSpreadsheet.ActiveWorksheet.Cells[0, 1].GetValue().Value;, taken from http://www.telerik.com/forums/basic-xslx-import-export-functionality-through-a-dataset)some other solution is certainly available