Hi,
I am creating a chart with two ColumnSeries with X-Axis containing Date and Y-Axis containing Item count. Now I want to create a stacked chart for the two series. Below is the program i have got. When I ran this, I am getting attached Chart which has X-Axis items not overlapping. For Series2, X-Axis items are again added. Even though, I am checking for the duplicates, it is adding the x-axis item.
I cannot use Date as X-Axis type because, it only supports Databound objects. Is there a way to achieve my desired behavior without X-Axis values overlapping?
Satish
private void UpdateOperationsChart()
{
SqlDataClient prodClient = new SqlDataClient(DataSource.Prod);
prodClient.Init();
DataTable table200 = prodClient.GetProvisioningOperations(OperationType.SelectedText,200);
DataTable table500 = prodClient.GetProvisioningOperations(OperationType.SelectedText,500);
ProvisioningChart.PlotArea.XAxis.TitleAppearance.Text = "Day";
ProvisioningChart.PlotArea.YAxis.TitleAppearance.Text = "Request Duration In Mins";
AxisY axisY = new AxisY();
axisY.Name = "Operation Count";
ProvisioningChart.PlotArea.AdditionalYAxes.Add(axisY);
ProvisioningChart.PlotArea.XAxis.Type = Telerik.Web.UI.HtmlChart.AxisType.Category;
ProvisioningChart.PlotArea.XAxis.AxisCrossingPoints.Add(0);
ProvisioningChart.PlotArea.XAxis.AxisCrossingPoints.Add(100);
LineSeries durationAvgSeries = new LineSeries();
durationAvgSeries.Appearance.FillStyle.BackgroundColor = System.Drawing.Color.Blue;
ColumnSeries request200Series = new ColumnSeries();
ColumnSeries request500Series = new ColumnSeries();
//request200Series.AxisName = "200";
//request500Series.AxisName = "500";
request200Series.Appearance.FillStyle.BackgroundColor = System.Drawing.Color.Green;
request500Series.Appearance.FillStyle.BackgroundColor = System.Drawing.Color.Red;
foreach (DataRow row in table200.Rows)
{
//durationAvgSeries.SeriesItems.Add(Decimal.Parse(row["AvgDurationInMin"].ToString()));
request200Series.SeriesItems.Add(Decimal.Parse(row["OperationCount"].ToString()));
AxisItem xAxisItem = new AxisItem(Convert.ToDateTime(row["Day"].ToString()).Month + "/" + Convert.ToDateTime(row["Day"].ToString()).Day);
if (!ProvisioningChart.PlotArea.XAxis.Items.Contains(xAxisItem))
ProvisioningChart.PlotArea.XAxis.Items.Add(xAxisItem);
}
foreach (DataRow row in table500.Rows)
{
//durationAvgSeries.SeriesItems.Add(Decimal.Parse(row["AvgDurationInMin"].ToString()));
request500Series.SeriesItems.Add(Decimal.Parse(row["OperationCount"].ToString()));
AxisItem xAxisItem = new AxisItem(Convert.ToDateTime(row["Day"].ToString()).Month + "/" + Convert.ToDateTime(row["Day"].ToString()).Day);
if (!ProvisioningChart.PlotArea.XAxis.Items.Contains(xAxisItem))
ProvisioningChart.PlotArea.XAxis.Items.Add(xAxisItem);
}
ProvisioningChart.PlotArea.Series.Add(request200Series);
ProvisioningChart.PlotArea.Series.Add(request500Series);
//ProvisioningChart.PlotArea.Series.Add(durationAvgSeries);
request200Series.Stacked = true;
request500Series.Name = "500";
request200Series.Name = "200";
durationAvgSeries.Name = "AvgDurationInMin";
prodClient.Close();
}
I am creating a chart with two ColumnSeries with X-Axis containing Date and Y-Axis containing Item count. Now I want to create a stacked chart for the two series. Below is the program i have got. When I ran this, I am getting attached Chart which has X-Axis items not overlapping. For Series2, X-Axis items are again added. Even though, I am checking for the duplicates, it is adding the x-axis item.
I cannot use Date as X-Axis type because, it only supports Databound objects. Is there a way to achieve my desired behavior without X-Axis values overlapping?
Satish
private void UpdateOperationsChart()
{
SqlDataClient prodClient = new SqlDataClient(DataSource.Prod);
prodClient.Init();
DataTable table200 = prodClient.GetProvisioningOperations(OperationType.SelectedText,200);
DataTable table500 = prodClient.GetProvisioningOperations(OperationType.SelectedText,500);
ProvisioningChart.PlotArea.XAxis.TitleAppearance.Text = "Day";
ProvisioningChart.PlotArea.YAxis.TitleAppearance.Text = "Request Duration In Mins";
AxisY axisY = new AxisY();
axisY.Name = "Operation Count";
ProvisioningChart.PlotArea.AdditionalYAxes.Add(axisY);
ProvisioningChart.PlotArea.XAxis.Type = Telerik.Web.UI.HtmlChart.AxisType.Category;
ProvisioningChart.PlotArea.XAxis.AxisCrossingPoints.Add(0);
ProvisioningChart.PlotArea.XAxis.AxisCrossingPoints.Add(100);
LineSeries durationAvgSeries = new LineSeries();
durationAvgSeries.Appearance.FillStyle.BackgroundColor = System.Drawing.Color.Blue;
ColumnSeries request200Series = new ColumnSeries();
ColumnSeries request500Series = new ColumnSeries();
//request200Series.AxisName = "200";
//request500Series.AxisName = "500";
request200Series.Appearance.FillStyle.BackgroundColor = System.Drawing.Color.Green;
request500Series.Appearance.FillStyle.BackgroundColor = System.Drawing.Color.Red;
foreach (DataRow row in table200.Rows)
{
//durationAvgSeries.SeriesItems.Add(Decimal.Parse(row["AvgDurationInMin"].ToString()));
request200Series.SeriesItems.Add(Decimal.Parse(row["OperationCount"].ToString()));
AxisItem xAxisItem = new AxisItem(Convert.ToDateTime(row["Day"].ToString()).Month + "/" + Convert.ToDateTime(row["Day"].ToString()).Day);
if (!ProvisioningChart.PlotArea.XAxis.Items.Contains(xAxisItem))
ProvisioningChart.PlotArea.XAxis.Items.Add(xAxisItem);
}
foreach (DataRow row in table500.Rows)
{
//durationAvgSeries.SeriesItems.Add(Decimal.Parse(row["AvgDurationInMin"].ToString()));
request500Series.SeriesItems.Add(Decimal.Parse(row["OperationCount"].ToString()));
AxisItem xAxisItem = new AxisItem(Convert.ToDateTime(row["Day"].ToString()).Month + "/" + Convert.ToDateTime(row["Day"].ToString()).Day);
if (!ProvisioningChart.PlotArea.XAxis.Items.Contains(xAxisItem))
ProvisioningChart.PlotArea.XAxis.Items.Add(xAxisItem);
}
ProvisioningChart.PlotArea.Series.Add(request200Series);
ProvisioningChart.PlotArea.Series.Add(request500Series);
//ProvisioningChart.PlotArea.Series.Add(durationAvgSeries);
request200Series.Stacked = true;
request500Series.Name = "500";
request200Series.Name = "200";
durationAvgSeries.Name = "AvgDurationInMin";
prodClient.Close();
}