Is it possible to create a column/line chart with multiple series like the legacy image(1st image) below? This is 3 quarters of data for two series, Responses & Average Ratings. I assign my responses data to column data source and my line data to line data source, but it looks like the second graph. Any help would be greatly appreciated.
I'm not really sure how your Y2 axis percentages map to your line values. It looks like both column and line use the Y axis. Here's some code that should get you started:private void Form1_Load(object sender, EventArgs e){ ultraChart1.ChartType = ChartType.Composite; ChartArea area = new ChartArea(); ultraChart1.CompositeChart.ChartAreas.Add(area);
AxisItem xAxisColumn = new AxisItem(); xAxisColumn.axisNumber = AxisNumber.X_Axis; xAxisColumn.DataType = AxisDataType.String; xAxisColumn.SetLabelAxisType = SetLabelAxisType.GroupBySeries; xAxisColumn.MajorGridLines.Visible = false; xAxisColumn.MinorGridLines.Visible = false; xAxisColumn.Labels.ItemFormat = AxisItemLabelFormat.ItemLabel; area.Axes.Add(xAxisColumn);
AxisItem xAxisLine = new AxisItem(); xAxisLine.axisNumber = AxisNumber.X_Axis; xAxisLine.DataType = AxisDataType.String; xAxisLine.SetLabelAxisType = SetLabelAxisType.ContinuousData; xAxisLine.MajorGridLines.Visible = false; xAxisLine.MinorGridLines.Visible = false; xAxisLine.Margin.Near.MarginType = LocationType.Percentage; xAxisLine.Margin.Near.Value = 10; xAxisLine.Margin.Far.MarginType = LocationType.Percentage; xAxisLine.Margin.Far.Value = 10; area.Axes.Add(xAxisLine);
AxisItem yAxisColumn = new AxisItem(); yAxisColumn.axisNumber = AxisNumber.Y_Axis; yAxisColumn.DataType = AxisDataType.Numeric; yAxisColumn.TickmarkStyle = AxisTickStyle.Smart; yAxisColumn.MajorGridLines.Visible = false; yAxisColumn.MinorGridLines.Visible = false; yAxisColumn.Labels.ItemFormat = AxisItemLabelFormat.DataValue; area.Axes.Add(yAxisColumn);
AxisItem yAxisLine = new AxisItem(); yAxisLine.axisNumber = AxisNumber.Y2_Axis; yAxisLine.DataType = AxisDataType.Numeric; yAxisLine.TickmarkStyle = AxisTickStyle.Smart; yAxisLine.MajorGridLines.Visible = false; yAxisLine.MinorGridLines.Visible = false; area.Axes.Add(yAxisLine);
NumericSeries seriesColumn = new NumericSeries(); seriesColumn.Points.Add(new NumericDataPoint(13.5, "1st Qtr", false)); seriesColumn.Points.Add(new NumericDataPoint(11, "2nd Qtr", false)); seriesColumn.Points.Add(new NumericDataPoint(12, "3rd Qtr", false));
NumericSeries seriesLine = new NumericSeries(); seriesLine.Points.Add(new NumericDataPoint(4, "1st Qtr", false)); seriesLine.Points.Add(new NumericDataPoint(5, "2nd Qtr", false)); seriesLine.Points.Add(new NumericDataPoint(9, "3rd Qtr", false)); ultraChart1.CompositeChart.Series.Add(seriesColumn); ultraChart1.CompositeChart.Series.Add(seriesLine);
ChartLayerAppearance columnLayer = new ChartLayerAppearance(); columnLayer.ChartType = ChartType.ColumnChart; columnLayer.AxisX = xAxisColumn; columnLayer.AxisY = yAxisColumn; columnLayer.ChartArea = area; columnLayer.Series.Add(seriesColumn); ultraChart1.CompositeChart.ChartLayers.Add(columnLayer);
ChartLayerAppearance lineLayer = new ChartLayerAppearance(); lineLayer.ChartType = ChartType.LineChart; lineLayer.AxisX = xAxisLine; lineLayer.AxisY = yAxisColumn; lineLayer.ChartArea = area; lineLayer.Series.Add(seriesLine); ultraChart1.CompositeChart.ChartLayers.Add(lineLayer); ultraChart1.Data.ZeroAligned = true;
ColumnChartAppearance columnAppearance = new ColumnChartAppearance(); columnAppearance.ColumnSpacing = 1; columnLayer.ChartTypeAppearance = columnAppearance;}
Couple of quick questions I am having trouble with. First, the chart area is running into the header text and second, I can't get the legend to display(should be bottom). Thanks for your help.
You also have to create a composite legend instead of using the default one.
CompositeLegend legend = new CompositeLegend();chart.CompositeChart.Legends.add(legend);legend.ChartLayers.add(yourChartLayers);
You can then set legend.Bounds and have the legend appear anywhere on the chart.
Nevermind, I got it. I didn't set the yAxisColumn and yAxisLine RangeMax and Range Min and the RangeType to Custom.
Looking at the last image in the post, my ranges are 4 to six on the y-axis. I've set the min/max on the y axis and set it to be zero aligned, however, it stays at min 4 and max 6 which makes my 3rd qtr value of 4 look like zero. Is there another property i'm missing? I've looked at my other charts where I've set min/max and they seem to be okay? Thanks