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
205
Scatter chart not showing in Column & Scatter composite chart
posted

Hi,

I'm trying to create a composite series containing Column Bar Chart & Scatter Chart.  The chart shows column chart but not the scatter chart.  Below is the code used for it: 

            UltraChart ultraChart = new UltraChart();
            ultraChart.ChartType = ChartType.Composite;
            ChartArea area = new ChartArea();
            ultraChart.CompositeChart.ChartAreas.Add(area);

            // String X axis for volumes
            AxisItem axisX = new AxisItem();
            axisX.OrientationType = AxisNumber.X_Axis;
            axisX.DataType = AxisDataType.String;
            axisX.SetLabelAxisType = SetLabelAxisType.GroupBySeries;
            axisX.Labels.ItemFormatString = "<ITEM_LABEL>";
            axisX.Labels.Orientation = TextOrientation.VerticalLeftFacing;

            // Numeric X axis for scatter
            AxisItem axisXNumeric = new AxisItem();
            axisXNumeric.OrientationType = AxisNumber.X_Axis;
            axisXNumeric.DataType = AxisDataType.Numeric;
            axisXNumeric.Labels.ItemFormatString = "<ITEM_LABEL>";
            axisXNumeric.Labels.Orientation = TextOrientation.VerticalLeftFacing;

            // Y axis for volumes
            AxisItem axisY = new AxisItem();
            axisY.OrientationType = AxisNumber.Y_Axis;
            axisY.DataType = AxisDataType.Numeric;
            axisY.Labels.ItemFormatString = "<DATA_VALUE:0.#>";

            // Y2 axis for scatter
            AxisItem axisY2 = new AxisItem();
            axisY2.OrientationType = AxisNumber.Y2_Axis;
            axisY2.DataType = AxisDataType.Numeric;
            axisY2.Labels.ItemFormatString = "<DATA_VALUE:##.##>";
            axisY2.Visible = true;

            // Add series
            NumericSeries volumeSeries = GetVolumeSeries();
            NumericSeries scatterSeries = GetScatterSeries();
            ultraChart.CompositeChart.Series.Add(volumeSeries);
            ultraChart.CompositeChart.Series.Add(scatterSeries);

            // Add axes
            area.Axes.Add(axisX);
            area.Axes.Add(axisXNumeric);
            area.Axes.Add(axisY);
            area.Axes.Add(axisY2);

            // Create ColumnChart layer
            ChartLayerAppearance columnChartLayer = new ChartLayerAppearance();
            columnChartLayer.ChartType = ChartType.ColumnChart;
            ((ColumnChartAppearance)columnChartLayer.ChartTypeAppearance).SeriesSpacing = 2;
            columnChartLayer.ChartArea = area;
            columnChartLayer.AxisX = axisX;
            columnChartLayer.AxisY = axisY;
            columnChartLayer.Series.Add(volumeSeries);

            // Create ScatterChart layer
            ChartLayerAppearance scatterChartLayer = new ChartLayerAppearance();
            scatterChartLayer.ChartType = ChartType.ScatterChart;
            ScatterChartAppearance scatterChart = ((ScatterChartAppearance)scatterChartLayer.ChartTypeAppearance);
            scatterChart.ColumnX = 0;
            scatterChart.ColumnY = 1;
            scatterChartLayer.ChartArea = area;
            scatterChartLayer.AxisX = axisXNumeric;
            scatterChartLayer.AxisY2 = axisY2;
            scatterChartLayer.Series.Add(scatterSeries);

            // Add layers
            ultraChart.CompositeChart.ChartLayers.Add(columnChartLayer);
            ultraChart.CompositeChart.ChartLayers.Add(scatterChartLayer);

            ultraChart.Dock = DockStyle.Fill;
            this.Controls.Add(ultraChart);

Anyone suggest what's missing here?  Thanks in advance.

Here is the chart pic for ref.