У меня большая проблема для рисования двух разных диаграмм в одной и той же форме ...
У меня есть одна форма, в которой я представил круговую диаграмму с данными, поступающими из базы данных, которая работала нормально .....
и мне удалось, что, когда я нажимаю на определенную часть на круговой диаграмме, я хочу показать два разных графика .. до события клика я справился, но я не могу показать два разных графика....
и это мой приведенный ниже код ...
public void mschart1_MouseClick(object sender, MouseEventArgs e)
{
// here i am checking the condition to hit the exact location in chart
Series serries;
Series series2 = null;
DataTable new1 = null;
new1 = mData.accountstatus();
DataTable new2 = null;
new2 = mdata2.Totals(dtpStartDate.Value, dtpenddate.Value);
mschart1.ChartAreas.Clear();
mschart1.Titles.Clear();
mschart1.Series.Clear();
area = "area1";
mschart1.ChartAreas.Add(area);
serries = mschart1.Series.Add(area);
serries.ChartArea = area;
title = mschart1.Titles.Add("title1");
title.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
title.Alignment = ContentAlignment.TopLeft;
title.DockedToChartArea = area;
mschart1.Titles.Add("").DockedToChartArea = area;
area = "area2";
mschart1.ChartAreas.Add(area);
series2 = mschart1.Series.Add(area);
series2.ChartArea = area;
title = mschart1.Titles.Add("title2");
title.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
title.Alignment = ContentAlignment.TopLeft;
title.DockedToChartArea = area;
mschart1.Titles.Add("").DockedToChartArea = area;
foreach (Title chartTitle in mschart1.Titles)
{
chartTitle.IsDockedInsideChartArea = false;
}
foreach (ChartArea chartArea in mschart1.ChartAreas)
{
chartArea.Area3DStyle.Enable3D = true;
chartArea.AxisX.LabelStyle.IsEndLabelVisible = true;
}
if (area == "area2")
{
foreach (Series charttypes in mschart1.Series)
{
charttypes.ChartType = SeriesChartType.Pie;
charttypes["PielabelStyle"] = "Outside";
charttypes["DoughnutRadius"] = "30";
charttypes["PieDrawingStyle"] = "SoftEdge";
charttypes.BackGradientStyle = GradientStyle.DiagonalLeft;
}
}
if (area == "area1")
{
foreach (Series chartareas in mschart1.Series)
{
chartareas.ChartType = SeriesChartType.StackedColumn;
chartareas["ColumnDrawingStyle"] = "SoftEdge";
chartareas["LabelStyle"] = "Top";
chartareas.IsValueShownAsLabel = true;
chartareas.BackGradientStyle = GradientStyle.DiagonalLeft;
}
}
foreach (Legend legend in mschart1.Legends)
{
legend.Enabled = false;
}
if (new2 == null)
{
series2.Points.Clear();
series2.Points.AddXY("no data", 0);
}
if(new1 == null)
{
serries.Points.Clear();
serries.Points.AddXY("no data", 0);
}
mschart1.Series["area1"].Points.DataBindXY(new2.Rows, "data1", new2.Rows, "Value");
mschart1.Series["area2"].Points.DataBindXY(new1.Rows, "name", new2.Rows, "count");
if (area == "area1")
{
foreach (Series charttypes in mschart1.Series)
{
foreach (DataPoint point in charttypes.Points)
{
switch (point.AxisLabel)
{
case "case1": point.Color = Color.Cyan; break;
case "case2": point.Color = Color.Green; break;
}
point.Label = string.Format("{0:0} - {1}", point.YValues[0], point.AxisLabel);
}
}
}
if (area == "area2")
{
foreach (Series chartareas in mschart1.Series)
{
foreach (DataPoint point in chartareas.Points)
{
switch (point.AxisLabel)
{
case "case23": point.Color = Color.Green; break;
case "case 24": point.Color = Color.Blue; break;
}
point.Label = string.Format("{0:0}", point.YValues[0]);
}
}
}
}
моя проблема, когда я нажимаю на график в определенной области, он отображает две диаграммы, но обе диаграммы одинаковые.. (Я хочу два разных типа диаграмм, как я уже упоминал в приведенном ниже коде)
поможет ли кто-нибудь в этом вопросе ......
Большое спасибо ...