c# - Need to get the pie chart with % values -


my aspx part

<div runat="server" id="divmain">     <asp:chart id="chart1" runat="server" datasourceid="sqldatasource1">         <series>             <asp:series name="series1" charttype="pie">             <points>                  //i want part come code-behind                  //<asp:datapoint axislabel="1 star"  yvalues="100" />                 //<asp:datapoint axislabel="2 star" yvalues="123" />                 //<asp:datapoint axislabel="3 star" yvalues="155" />                 //<asp:datapoint axislabel="4 star" yvalues="245" />              </points>             </asp:series>         </series>         <chartareas>             <asp:chartarea name="chartarea1">              </asp:chartarea>         </chartareas>         <legends>             <asp:legend title="test abc" />         </legends>     </asp:chart>   </div> 

my code-behind follows down:

protected void page_load(object sender, eventargs e) {     double[] yvalues = { 10, 27.5, 7, 12, 45.5 };     string[] xnames = { "mike", "john", "william", "george", "alex" };      series series1 = new  series("pie");     series1.charttype = seriescharttype.pie;     series1.borderwidth = 3;     series1.shadowoffset = 2;     chart1.series[0].points.databindxy(xnames, yvalues);     divmain.controls.add(chart1); } 

but getting following exception: "the datasourceid of chart1 must id of control of type idatasource. control id sqldatasource1 not found."

remove datasourceid="sqldatasource1" element chart in aspx page, not exist, , don't need try fill data chart programatically.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -