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;}
Hi ,
Your sample is working fine with NurmericSeries , but the column does not show up when I use NumericTimeDataPoint, any idea ?
Thanks
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.
Thanx Max! Once again, you rock.