.aspx code:
ImageStorageMode="UseImageLocation" Width="600px"
ImageLocation="~/images/TempCharts">
IsStartedFromZero="False">
ImageStorageMode="UseImageLocation" Width="600px"
ImageLocation="~/images/TempCharts" DataSourceID="sdsPieProductsIn">
.aspx.cs code:
public void DrawPieChart()
{
DataView dv = (DataView)sdsPieProductsIn.Select(DataSourceSelectArguments.Empty);
ArrayList xValues = new ArrayList();
ArrayList yValues = new ArrayList();
PieChartProductsIn.ChartAreas["PieChartArea"].Area3DStyle.Enable3D = true;
PieChartProductsIn.Titles["PieTitle"].Text = "Fordeling";
for (int i = 0; i < dv.Count; i++)
{
xValues.Add(dv[i][6].ToString());
yValues.Add(dv[i][11].ToString());
}
PieChartProductsIn.Series.Add("ProductsIn");
PieChartProductsIn.Series["ProductsIn"].Points.DataBindXY(xValues, yValues);
PieChartProductsIn.Series["ProductsIn"].ChartType = SeriesChartType.Pie;
}
public void DrawGraph()
{
DataView dv = (DataView)sdsGetRegistrations.Select(DataSourceSelectArguments.Empty);
Label1.Text = dv[0][24].ToString();
chartBridgeRegs.DataSource = sdsGetRegistrations;
if (RadioButtonList1.SelectedValue == "1")
chartBridgeRegs.Titles["Title1"].Text = "Indvejninger på brovægt";
if (RadioButtonList1.SelectedValue == "2")
chartBridgeRegs.Titles["Title1"].Text = "Udvejninger på brovægt";
if (RadioButtonList1.SelectedValue == "0")
chartBridgeRegs.Titles["Title1"].Text = "Ind- og udvejninger på brovægt";
chartBridgeRegs.ChartAreas["ChartArea1"].AxisY.Minimum = 0;
chartBridgeRegs.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false;
chartBridgeRegs.Series.Add("Indvejning");
chartBridgeRegs.Series["Indvejning"].XValueMember = "RegTime";
chartBridgeRegs.Series["Indvejning"].YValueMembers = "Amount";
chartBridgeRegs.Series["Indvejning"].ShadowColor = System.Drawing.Color.DarkGray;
chartBridgeRegs.Series["Indvejning"].ShadowOffset = 2;
chartBridgeRegs.Series["Indvejning"].ChartType = SeriesChartType.Column;
chartBridgeRegs.Series["Indvejning"]["PointWidth"] = "0.2";
chartBridgeRegs.Series["Indvejning"].IsValueShownAsLabel = true;
chartBridgeRegs.Series["Indvejning"]["BarLabelStyle"] = "Center";
chartBridgeRegs.Series["Indvejning"].ToolTip = "Vægt: #VALY kg \nDato: #VALX";
chartBridgeRegs.Series["Indvejning"]["DrawingStyle"] = "Cylinder";
chartBridgeRegs.Legends.Add(new Legend("Indvejning"));
chartBridgeRegs.Legends["Indvejning"].Docking = Docking.Bottom;
chartBridgeRegs.DataBind();
//Sætter farver på søjler
for (int i = 0; i < dv.Count; i++)
{
if (dv[i][21].ToString() == "1")
{
chartBridgeRegs.Series["Indvejning"].Points[i].Color = System.Drawing.Color.CornflowerBlue;
chartBridgeRegs.Series["Indvejning"].Points[i].BackSecondaryColor = System.Drawing.Color.SkyBlue;
chartBridgeRegs.Series["Indvejning"].Points[i].BackGradientStyle = GradientStyle.DiagonalLeft;
}
if (dv[i][21].ToString() == "0")
{
chartBridgeRegs.Series["Indvejning"].Points[i].Color = System.Drawing.Color.Red;
chartBridgeRegs.Series["Indvejning"].Points[i].BackSecondaryColor = System.Drawing.Color.PaleVioletRed;
chartBridgeRegs.Series["Indvejning"].Points[i].BackGradientStyle = GradientStyle.DiagonalLeft;
}
}
}
DrawGraph() and DrawPieChart() are called on a button click when the user has selected the data necessary to retrieve the data from the SqlDataSources.
Hope someone can help me with this.
Regards
Søren Augustesen
ImageLocation="~/images/TempCharts">
ImageLocation="~/images/TempCharts" DataSourceID="sdsPieProductsIn">
.aspx.cs code:
public void DrawPieChart()
{
DataView dv = (DataView)sdsPieProductsIn.Select(DataSourceSelectArguments.Empty);
ArrayList xValues = new ArrayList();
ArrayList yValues = new ArrayList();
PieChartProductsIn.ChartAreas["PieChartArea"].Area3DStyle.Enable3D = true;
PieChartProductsIn.Titles["PieTitle"].Text = "Fordeling";
for (int i = 0; i < dv.Count; i++)
{
xValues.Add(dv[i][6].ToString());
yValues.Add(dv[i][11].ToString());
}
PieChartProductsIn.Series.Add("ProductsIn");
PieChartProductsIn.Series["ProductsIn"].Points.DataBindXY(xValues, yValues);
PieChartProductsIn.Series["ProductsIn"].ChartType = SeriesChartType.Pie;
}
public void DrawGraph()
{
DataView dv = (DataView)sdsGetRegistrations.Select(DataSourceSelectArguments.Empty);
Label1.Text = dv[0][24].ToString();
chartBridgeRegs.DataSource = sdsGetRegistrations;
if (RadioButtonList1.SelectedValue == "1")
chartBridgeRegs.Titles["Title1"].Text = "Indvejninger på brovægt";
if (RadioButtonList1.SelectedValue == "2")
chartBridgeRegs.Titles["Title1"].Text = "Udvejninger på brovægt";
if (RadioButtonList1.SelectedValue == "0")
chartBridgeRegs.Titles["Title1"].Text = "Ind- og udvejninger på brovægt";
chartBridgeRegs.ChartAreas["ChartArea1"].AxisY.Minimum = 0;
chartBridgeRegs.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false;
chartBridgeRegs.Series.Add("Indvejning");
chartBridgeRegs.Series["Indvejning"].XValueMember = "RegTime";
chartBridgeRegs.Series["Indvejning"].YValueMembers = "Amount";
chartBridgeRegs.Series["Indvejning"].ShadowColor = System.Drawing.Color.DarkGray;
chartBridgeRegs.Series["Indvejning"].ShadowOffset = 2;
chartBridgeRegs.Series["Indvejning"].ChartType = SeriesChartType.Column;
chartBridgeRegs.Series["Indvejning"]["PointWidth"] = "0.2";
chartBridgeRegs.Series["Indvejning"].IsValueShownAsLabel = true;
chartBridgeRegs.Series["Indvejning"]["BarLabelStyle"] = "Center";
chartBridgeRegs.Series["Indvejning"].ToolTip = "Vægt: #VALY kg \nDato: #VALX";
chartBridgeRegs.Series["Indvejning"]["DrawingStyle"] = "Cylinder";
chartBridgeRegs.Legends.Add(new Legend("Indvejning"));
chartBridgeRegs.Legends["Indvejning"].Docking = Docking.Bottom;
chartBridgeRegs.DataBind();
//Sætter farver på søjler
for (int i = 0; i < dv.Count; i++)
{
if (dv[i][21].ToString() == "1")
{
chartBridgeRegs.Series["Indvejning"].Points[i].Color = System.Drawing.Color.CornflowerBlue;
chartBridgeRegs.Series["Indvejning"].Points[i].BackSecondaryColor = System.Drawing.Color.SkyBlue;
chartBridgeRegs.Series["Indvejning"].Points[i].BackGradientStyle = GradientStyle.DiagonalLeft;
}
if (dv[i][21].ToString() == "0")
{
chartBridgeRegs.Series["Indvejning"].Points[i].Color = System.Drawing.Color.Red;
chartBridgeRegs.Series["Indvejning"].Points[i].BackSecondaryColor = System.Drawing.Color.PaleVioletRed;
chartBridgeRegs.Series["Indvejning"].Points[i].BackGradientStyle = GradientStyle.DiagonalLeft;
}
}
}
DrawGraph() and DrawPieChart() are called on a button click when the user has selected the data necessary to retrieve the data from the SqlDataSources.
Hope someone can help me with this.
Regards
Søren Augustesen
Comments
Post a Comment