320
Need code samples for creating Area and Bar chart types in composite chart.
posted

Hi,

I am using composite chart to display the chart types like Line, Scatter, Area and Bar chart. In my code, the Line and Scatter charts are working fine. But the Area and Bar charts are not appearing in the composite chart. Could you please suggest me the right steps to follow in displaying the Area and Bar charts in the composite chart?

Note: I have reffered the Axis Requirements in the Infragistics online help, they suggesting to use the following requirements for composite chart...

Chart TypeX-AxisY-AxisY2-Axis

Area (2D)

Both:

AxisDataType=String/Time

and

SetLabelAxisType=Continuous

AxisDataType=Numeric

n/a

Bar (2D)

AxisDataType=Numeric

AxisDataType=String

SetLabelAxisType=GroupBySeries

n/a

 But in my requirement, I need to use "X-axis as Time/Numeric" & "Y-axis as Numeric" for both Area and Bar chart. Please suggest me a solution. 

Thanks & Regards,

Raaj

Parents Reply Children
  • 320
    posted in reply to Dave Frischknecht

    Hi Dave,

    I will provide you sample screen shots for the BAR and AREA chart taken from the DevXpress chart.

    I am using the Ultra chart with type composite chart to display BAR and AREA charts in ultra chart.

    Sample BAR chart with X-axis(Date) and Y-axis(Numeric):

    Sample BAR chart with X-axis(Numeric) and Y-axis(Numeric):

    Sample AREA chart with X-axis(Date) and Y-axis(Numeric):

    Sample AREA chart with X-axis(Numeric) and Y-axis(Numeric):

    To bind the values, I have using the below codes.

    NumericSeries

     

     

    NumSeries = new NumericSeries();

    NumSeries.Data.LabelColumn = xMemberData.ToString();

    NumSeries.Data.ValueColumn = yMemberData.ToString();

    NumSeries.Data.DataSource = dtTemp;

    NumSeries.DataBind();

    series = NumSeries;

     

     

     

    And to bind the series with the composite chart, I will be using the below codes..

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    chartPreview.ChartType =

     

    ChartType.Composite;

     

     

     

    ChartArea area1 = new ChartArea();

    chartPreview.CompositeChart.ChartAreas.Add(area1);

     

     

     

    CompositeLegend legend = new CompositeLegend(chartPreview);

     

     

     

    AxisItem x = new AxisItem(chartPreview, AxisNumber.X_Axis);

     

     

     

    AxisItem y = new AxisItem(chartPreview, AxisNumber.Y_Axis);

     

     

     

    AxisItem y2 = new AxisItem(chartPreview, AxisNumber.Y2_Axis);

     

     

     

    // AxisItem x2 = new AxisItem(chartPreview, AxisNumber.X2_Axis);

     

     

     

    UserGraph graph = UserGraphFromCurrentSettings();

     

     

     

    ChartLayerCollection LayerY1Collection = new ChartLayerCollection(chartPreview);

     

     

     

    ChartLayerCollection LayerY2Collection = new ChartLayerCollection(chartPreview);

     

     

     

    ChartLayerAppearance layerY1 = null;

     

     

     

    ChartLayerAppearance layerY2 = null;

     

     

     

    //*** for Y1 Axes

     

     

     

    if (graph != null && nbgY1Axis.ItemLinks.Count != 0)

    {

     

     

     

    for (int Y1 = 0; Y1 < nbgY1Axis.ItemLinks.Count; Y1++)

    {

    layerY1 =

     

    new ChartLayerAppearance(chartPreview);

    layerY1.Key = graph.AxisY1Variables[Y1].Name.ToString();

    layerY1.ChartType = UpdateSeries(graph.AxisY1Variables[Y1].SeriesType.ToString());

    LayerY1Collection.Add(layerY1);

    }

    }

     

     

     

     

     

    //*** for Y2 Axes

     

     

    if (graph != null && nbgY2Axis.ItemLinks.Count != 0)

    {

     

     

    for (int Y2 = 0; Y2 < nbgY2Axis.ItemLinks.Count; Y2++)

    {

    layerY2 =

     

    new ChartLayerAppearance(chartPreview);

    layerY2.Key = graph.AxisY2Variables[Y2].Name.ToString();

    layerY2.ChartType = UpdateSeries(graph.AxisY2Variables[Y2].SeriesType.ToString());

    LayerY2Collection.Add(layerY2);

    }

    }

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    LayerY1Collection[Y11].ChartArea = area1;

    LayerY1Collection[Y11].AxisX = x;

    LayerY1Collection[Y11].AxisY = y;

     

     

     

     

    if

    (area1.Axes.Count == 0)

    {

    area1.Axes.Add(x);

    area1.Axes.Add(y);

    }

    LayerY1Collection[Y11].AxisX.Extent = 75;

    LayerY1Collection[Y11].AxisY.Extent = 75;

     

     

     

    //***** common settings for X-axis and Y-axis

    LayerY1Collection[Y11].Visible = true;

    LayerY1Collection[Y11].AxisX.Visible =

     

    true;

    LayerY1Collection[Y11].AxisX.Labels.Visible = t

     

    rue;

    LayerY1Collection[Y11].AxisX.ScrollScale.Visible = f

     

    alse;

    LayerY1Collection[Y11].AxisX.RangeType =

     

    AxisRangeType.Automatic;

    LayerY1Collection[Y11].AxisX.TickmarkStyle =

     

    AxisTickStyle.Smart;

    LayerY1Collection[Y11].AxisY.Visible =

     

    true;

    LayerY1Collection[Y11].AxisY.Labels.Visible = t

     

    rue;

    LayerY1Collection[Y11].AxisY.ScrollScale.Visible = f

     

    alse;

    LayerY1Collection[Y11].AxisY.RangeType =

     

    AxisRangeType.Automatic;

    LayerY1Collection[Y11].AxisY.TickmarkStyle =

     

    AxisTickStyle.Smart;

     

    //***** For Y1 Axis layer **************

     

     

     

     

    if (LayerY1Collection[Y11].ChartType.ToString().Contains(SeriesType.Area.ToString()))

    {

    LayerY1Collection[Y11].ChartType =

     

    ChartType.AreaChart;

     

     

     

    if (IsDateSeries)

    {

    x.DataType =

     

    AxisDataType.Time;

    y.DataType =

     

    AxisDataType.Numeric;

    x.SetLabelAxisType =

     

    SetLabelAxisType.ContinuousData;

    LayerY1Collection[Y11].AxisX.TickmarkIntervalType =

     

    AxisIntervalType.Months;

    LayerY1Collection[Y11].AxisX.Labels.ItemFormat =

     

    AxisItemLabelFormat.Custom;

    LayerY1Collection[Y11].AxisX.Labels.ItemFormatString =

     

    "<DATA_VALUE:MM/dd/yyyy>";

    LayerY1Collection[Y11].AxisX.Labels.Orientation =

     

    TextOrientation.Custom;

    LayerY1Collection[Y11].AxisX.Labels.OrientationAngle = -40;

    LayerY1Collection[Y11].AxisY.Labels.ItemFormat =

     

    AxisItemLabelFormat.Custom;

    LayerY1Collection[Y11].AxisY.Labels.ItemFormatString =

     

    "<DATA_VALUE:00.0000>";

    }

     

     

     

    else

    {

    x.DataType =

     

    AxisDataType.String;

    y.DataType =

     

    AxisDataType.Numeric;

    x.SetLabelAxisType =

     

    SetLabelAxisType.ContinuousData;

     

    LayerY1Collection[Y11].AxisX.Labels.Orientation = TextOrientation.VerticalLeftFacing;

     

     

     

    LayerY1Collection[Y11].AxisX.Labels.ItemFormat = AxisItemLabelFormat.ItemLabel;

    LayerY1Collection[Y11].AxisY.Labels.ItemFormat =

     

    AxisItemLabelFormat.DataValue;

    LayerY1Collection[Y11].AxisY.Labels.ItemFormatString =

     

    "<DATA_VALUE:00.0000>";

    }

    }

     

     

     

    else if (LayerY1Collection[Y11].ChartType.ToString().Contains(SeriesType.Bar.ToString()))

    {

    LayerY1Collection[Y11].ChartType =

     

    ChartType.BarChart;

     

     

     

    if (IsDateSeries)

    {

    x.DataType =

     

    AxisDataType.Numeric;

    y.DataType =

     

    AxisDataType.String;

    y.SetLabelAxisType =

     

    SetLabelAxisType.GroupBySeries;

     

     

     

    BarChartAppearance barAppearance = new BarChartAppearance();

    barAppearance.NullHandling =

     

    NullHandling.Zero;

    barAppearance.BarSpacing = 1;

    LayerY1Collection[Y11].ChartTypeAppearance = barAppearance;

    LayerY1Collection[Y11].AxisX.TickmarkIntervalType =

     

    AxisIntervalType.Months;

    LayerY1Collection[Y11].AxisX.Labels.ItemFormat =

     

    AxisItemLabelFormat.ItemLabel;

    LayerY1Collection[Y11].AxisX.Labels.Orientation =

     

    TextOrientation.Custom;

    LayerY1Collection[Y11].AxisX.Labels.OrientationAngle = -40;

    LayerY1Collection[Y11].AxisY.Labels.ItemFormat =

     

    AxisItemLabelFormat.DataValue;

    }

     

     

     

    else

    {

    x.DataType =

     

    AxisDataType.Numeric;

    y.DataType = A

     

    xisDataType.String;

    y.SetLabelAxisType =

     

    SetLabelAxisType.GroupBySeries;

    LayerY1Collection[Y11].AxisX.Labels.ItemFormat =

     

    AxisItemLabelFormat.DataValue;

    LayerY1Collection[Y11].AxisX.Labels.ItemFormatString =

     

    "<DATA_VALUE:00.0000>";

     

    LayerY1Collection[Y11].AxisY.Labels.Orientation = TextOrientation.Custom;

    LayerY1Collection[Y11].AxisY.Labels.OrientationAngle = 0;

     

     

     

    LayerY1Collection[Y11].AxisY.Labels.ItemFormat = AxisItemLabelFormat.ItemLabel;

     

     

     

     

     

     

     

    BarChartAppearance barAppearance = new BarChartAppearance(chartPreview);

    barAppearance.NullHandling =

     

    NullHandling.Zero;

    barAppearance.BarSpacing = 2;

    barAppearance.SeriesSpacing = 2;

     

     

     

    LayerY1CollectioRaajn[Y11].ChartTypeAppearance = barAppearance;

    }

    }

     

     

    Regards,

    Raaj