filmov
tv
How to set asp net chart control ChartType property dynamically

Показать описание
Text version of the video
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
Slides
ASP.NET Charts Playlist
All ASP .NET Chart Control Text Articles and Slides
All Dot Net and SQL Server Tutorials in English
All Dot Net and SQL Server Tutorials in Arabic
There are 2 ways to set the ChartType property
1. Declaratively in the HTML using ChartType attribute as shown below.
[Series]
[asp:Series Name="Series1" ChartArea="ChartArea1" ChartType="Pie"]
[Points]
[asp:DataPoint AxisLabel="Mark" YValues="800,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Steve" YValues="900,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="John" YValues="700,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Mary" YValues="900,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Ben" YValues="600,0,0,0,0,0" /]
[/Points]
[/asp:Series]
[/Series]
2. Programatically in code. We want to display all the different ChartTypes available in a DropDownList. When the user selects an option from the DropDownList we want to set the selected chart type as the value for the ChartType property dynamically in code.
[div style="font-family:Arial"]
[table style="border: 1px solid black"]
[tr]
[td]
[b]Select Chart Type :[/b]
[/td]
[td]
[asp:DropDownList ID="ddlChartType" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlChartType_SelectedIndexChanged"]
[/asp:DropDownList]
[/td]
[/tr]
[tr]
[td colspan="2"]
[asp:Chart ID="Chart1" runat="server" Width="350px"]
[Titles]
[asp:Title Text="Total marks of students"]
[/asp:Title]
[/Titles]
[Series]
[asp:Series Name="Series1" ChartArea="ChartArea1" ChartType="Pie"]
[Points]
[asp:DataPoint AxisLabel="Mark" YValues="800,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Steve" YValues="900,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="John" YValues="700,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Mary" YValues="900,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Ben" YValues="600,0,0,0,0,0" /]
[/Points]
[/asp:Series]
[/Series]
[ChartAreas]
[asp:ChartArea Name="ChartArea1"]
[AxisX Title="Student Name"]
[/AxisX]
[AxisY Title="Total Marks"]
[/AxisY]
[/asp:ChartArea]
[/ChartAreas]
[/asp:Chart]
[/td]
[/tr]
[/table]
[/div]
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
Slides
ASP.NET Charts Playlist
All ASP .NET Chart Control Text Articles and Slides
All Dot Net and SQL Server Tutorials in English
All Dot Net and SQL Server Tutorials in Arabic
There are 2 ways to set the ChartType property
1. Declaratively in the HTML using ChartType attribute as shown below.
[Series]
[asp:Series Name="Series1" ChartArea="ChartArea1" ChartType="Pie"]
[Points]
[asp:DataPoint AxisLabel="Mark" YValues="800,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Steve" YValues="900,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="John" YValues="700,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Mary" YValues="900,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Ben" YValues="600,0,0,0,0,0" /]
[/Points]
[/asp:Series]
[/Series]
2. Programatically in code. We want to display all the different ChartTypes available in a DropDownList. When the user selects an option from the DropDownList we want to set the selected chart type as the value for the ChartType property dynamically in code.
[div style="font-family:Arial"]
[table style="border: 1px solid black"]
[tr]
[td]
[b]Select Chart Type :[/b]
[/td]
[td]
[asp:DropDownList ID="ddlChartType" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlChartType_SelectedIndexChanged"]
[/asp:DropDownList]
[/td]
[/tr]
[tr]
[td colspan="2"]
[asp:Chart ID="Chart1" runat="server" Width="350px"]
[Titles]
[asp:Title Text="Total marks of students"]
[/asp:Title]
[/Titles]
[Series]
[asp:Series Name="Series1" ChartArea="ChartArea1" ChartType="Pie"]
[Points]
[asp:DataPoint AxisLabel="Mark" YValues="800,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Steve" YValues="900,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="John" YValues="700,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Mary" YValues="900,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Ben" YValues="600,0,0,0,0,0" /]
[/Points]
[/asp:Series]
[/Series]
[ChartAreas]
[asp:ChartArea Name="ChartArea1"]
[AxisX Title="Student Name"]
[/AxisX]
[AxisY Title="Total Marks"]
[/AxisY]
[/asp:ChartArea]
[/ChartAreas]
[/asp:Chart]
[/td]
[/tr]
[/table]
[/div]
Комментарии