Apr 04, 2014, 9:04 AM
How can i add <Tips .. <rerender fn='function' /> in piechart in code-behind
Hi guys.
I want to create PieChart in code-behind. But i has a problem, i don't know how can i add tips in c#
Demo in https://examples2.ext.net/#/Chart/Pie/Basic/
Here is my code
Code-behind
Thanks.
I want to create PieChart in code-behind. But i has a problem, i don't know how can i add tips in c#
Demo in https://examples2.ext.net/#/Chart/Pie/Basic/
<ext:Chart
ID="Chart1"
runat="server"
Animate="true"
Shadow="true"
InsetPadding="60"
Theme="Base:gradients">
<LegendConfig Position="Right" />
<Store>
<ext:Store
runat="server"
Data="<%# Ext.Net.Examples.ChartData.GenerateData(6) %>"
AutoDataBind="true">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="Name" />
<ext:ModelField Name="Data1" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<Series>
<ext:PieSeries
AngleField="Data1"
ShowInLegend="true"
Donut="0"
Highlight="true"
HighlightSegmentMargin="20">
<Label Field="Name" Display="Rotate" Contrast="true" Font="18px Arial" />
<Tips TrackMouse="true" Width="140" Height="28">
<Renderer Fn="tipRenderer" />
</Tips>
</ext:PieSeries>
</Series>
</ext:Chart
I want to add function in code-behind, but i can't<Tips TrackMouse="true" Width="140" Height="28">
<Renderer Fn="tipRenderer" />
</Tips>
Here is my code
Code-behind
public Chart fn_Generate_PieChart(string ID, DataTable dtData)
{
Chart pieChart = new Chart() { ID = ID, Animate = true, Shadow = true, InsetPadding = 10, Legend = false, Border = false, Region = Region.Center };
Store st = new Store() { ID = "st" + ID, AutoDataBind = true };
Model md = new Model() { ID = "md" + ID };
ModelField m1 = new ModelField() { Name = "Name" };
ModelField m2 = new ModelField() { Name = "Data" };
md.Fields.Add(m1); md.Fields.Add(m2);
st.Model.Add(md);
st.DataSource = dtData;
pieChart.Store.Add(st);
pieChart.Series.Add(new PieSeries()
{
AngleField = "Data",
ShowInLegend = true,
Donut = 0,
Highlight = true,
HighlightSegmentMargin = 20,
Label = new SeriesLabel()
{
Field = new string[] { "Name" },
Display = SeriesLabelDisplay.Rotate,
Contrast = true,
Font = "14px Tahoma"
},
Tips = new ChartTip()
{
TrackMouse = true,
//How can i do that.
//<Renderer Fn="tipRenderer" />
}
});
return pieChart;
}
Please help meThanks.