Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
Composite Chart: Getting all values to show up when charts data do not match.
posted

I am trying to get a Composite chart with multiple line charts to display correctly.

 The scenario is I have a date range from 11/1/2008 - 11/18/2008.  Chart 1 has data for all the dates and chart 2 has data through the 16th.  The problem is that the chart always stops at the 16th and does not show data for the 17th and 18th.

The code below has some commented lines where if I plot a value of 0 for those cases then the lines show up as 0.  However I just want the line for Chart 2 to end and for Chart 1 to continue.

 Here is the code I am using:

StrategyEffectivenessUC.ChartType = ChartType.Composite;

DataTable dt = m_PSSBO.StrategiesGetForDateRangeByStudentPlan(StudentPlanId, ChartDateStart.SelectedDate, ChartDateEnd.SelectedDate);

CompositeLegend chartLegend = new CompositeLegend();

chartLegend.Bounds = new Rectangle(0, 83, 12, 15);

chartLegend.BoundsMeasureType = MeasureType.Percentage;

chartLegend.PE.ElementType = PaintElementType.Gradient;

chartLegend.PE.FillGradientStyle = GradientStyle.ForwardDiagonal;

chartLegend.PE.Fill = Color.CornflowerBlue;

chartLegend.PE.FillStopColor = Color.Transparent;

chartLegend.Border.CornerRadius = 5;

chartLegend.Border.Thickness = 0;

StrategyEffectivenessUC.CompositeChart.Legends.Add(chartLegend);

ChartArea chartArea = new ChartArea();

StrategyEffectivenessUC.CompositeChart.ChartAreas.Add(chartArea);

AxisItem axisX = new AxisItem();

axisX.OrientationType = AxisNumber.X_Axis;

axisX.DataType = AxisDataType.String;

axisX.SetLabelAxisType = SetLabelAxisType.ContinuousData;

axisX.Labels.ItemFormatString = "<ITEM_LABEL>";

axisX.LineThickness = 1;

axisX.TickmarkStyle =
AxisTickStyle.Smart;

axisX.Labels.Orientation = TextOrientation.VerticalLeftFacing;

AxisItem axisY = new AxisItem();

axisY.OrientationType = AxisNumber.Y_Axis;

axisY.DataType = AxisDataType.Numeric;axisY.RangeType = AxisRangeType.Custom;

axisY.RangeMax = dt.Rows.Count;

axisY.RangeMin = 0;

axisY.LineThickness = 1;

axisY.TickmarkStyle =
AxisTickStyle.DataInterval;

axisY.TickmarkInterval = 1;

axisY.Labels.ItemFormatString =
"<DATA_VALUE>";

chartArea.Axes.Add(axisX);

chartArea.Axes.Add(axisY);

ChartLayerAppearance chartlayerAppearance;

NumericSeries ns;

LineChartAppearance lca;

int count = 1;

foreach (DataRow dr in dt.Rows)

{

chartlayerAppearance =
new ChartLayerAppearance();chartlayerAppearance.ChartType = ChartType.LineChart;

chartlayerAppearance.ChartArea = chartArea;

chartlayerAppearance.LegendItem =
LegendItemType.Series;

chartlayerAppearance.AxisX = axisX;

chartlayerAppearance.AxisY = axisY;

 

int strategyId = Convert.ToInt32(dr["StrategyId"]);

DataTable dtDates = m_PSSBO.ChartStrategyGetForRange(StudentPlanId, strategyId, ChartDateStart.SelectedDate, ChartDateEnd.SelectedDate, false);

ns = new NumericSeries();

 

ns.Label = strategyId.ToString();

int ratingValue = Convert.ToInt32(dtDates.Rows[0]["RatingValue"]); foreach (DataRow drS in dtDates.Rows)

{

if (Convert.ToBoolean(drS["Used"]))

ns.Points.Add(new NumericDataPoint(count, drS["SessionDate"].ToString(), false));

//else

// ns.Points.Add(new NumericDataPoint(0, drS["SessionDate"].ToString(), false));

}

 

lca =
new LineChartAppearance();

lca.LineAppearances.Add(GetLineStyle(ratingValue));

chartlayerAppearance.ChartTypeAppearance = lca;

chartlayerAppearance.Series.Add(ns);

 

StrategyEffectivenessUC.CompositeChart.ChartLayers.Add(chartlayerAppearance);

 

chartLegend.ChartLayers.Add(chartlayerAppearance);

count++;

}

 

public LineAppearance GetLineStyle(int RatingAverage)

{

LineAppearance la = new LineAppearance();

la.Thickness = 4;

switch (RatingAverage)

{

case 1:

la.LineStyle.DrawStyle = LineDrawStyle.Dash;

break;

case 2:

la.LineStyle.DrawStyle = LineDrawStyle.DashDot;

break;

case 3:

la.LineStyle.DrawStyle = LineDrawStyle.DashDotDot;

break;

case 4:

la.LineStyle.DrawStyle = LineDrawStyle.Dot;

break;

case 5:

la.LineStyle.DrawStyle = LineDrawStyle.Solid;

break;

default:

break;

}

return la;

}

Parents
  • 28496
    Offline posted

    the X-axis uses the minimum number of points in all series to determine its range.  try setting axisX.DataType = Time and creating NumericTimeSeries instead of NumericSeries for your data.

     

Reply Children
No Data