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
475
Multiple axis in linechart
posted

Hi,

Am trying to create a line chart with multiple axis. I made the chart type as composite and then created two layers with chart type as linechart.

But it drwas as many lines as the number of datapoints. How can I get it to draw two line charts each using different Y axis?

 

this.ultraChart1.ChartType = ChartType.Composite;

ultraChart1.ColorModel.ModelStyle = ColorModels.CustomSkin;

ultraChart1.ColorModel.Skin.PEs.Add(new PaintElement(Color.Red));

ultraChart1.ColorModel.Skin.PEs.Add(new PaintElement(Color.Blue));

this.ultraChart1.Legend.Visible = true;

this.ultraChart1.Legend.Location = LegendLocation.Top;

NumericSeries scl = new NumericSeries();

NumericSeries scl1 = new NumericSeries();

scl.Points.Add((new NumericDataPoint(20, "1", false)));

scl1.Points.Add((new NumericDataPoint(30, "1", false)));

scl.Points.Add((new NumericDataPoint(50, "2", false)));

scl1.Points.Add((new NumericDataPoint(50, "6", false)));

scl.Points.Add((new NumericDataPoint(90, "4", false)));

scl1.Points.Add((new NumericDataPoint(60, "8", false)));

scl.Label = "UnScheduledPrincipal";scl1.Label = "Interest";

 

 

ChartArea area1 = new ChartArea();this.ultraChart1.CompositeChart.ChartAreas.Add(area1);

 

 

AxisItem axisX = new AxisItem();

axisX.OrientationType = AxisNumber.X_Axis;

axisX.DataType = AxisDataType.Numeric;

axisX.TickmarkStyle = AxisTickStyle.Smart;

axisX.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto;

axisX.Labels.Orientation = TextOrientation.VerticalLeftFacing;

axisX.Labels.ItemFormatString = "<DATA_VALUE:0.0>";

area1.Axes.Add(axisX);

AxisItem axisY1 = new AxisItem();

axisY1.OrientationType = AxisNumber.Y_Axis;

axisY1.DataType = AxisDataType.Numeric;

axisY1.TickmarkStyle = AxisTickStyle.Smart;

axisY1.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto;

axisY1.Labels.Orientation = TextOrientation.Horizontal;

axisY1.Labels.ItemFormatString = "<DATA_VALUE:0.0>";

area1.Axes.Add(axisY1);

AxisItem axisY2 = new AxisItem();

axisY2.OrientationType = AxisNumber.Y2_Axis;

axisY2.DataType = AxisDataType.Numeric;

axisY2.TickmarkStyle = AxisTickStyle.Smart;

axisY2.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto;

axisY2.Labels.Orientation = TextOrientation.Horizontal;

axisY2.Labels.ItemFormatString = "<DATA_VALUE:0.0>";

area1.Axes.Add(axisY2);

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

LineChartLayer1.Series.Add(scl);

LineChartLayer1.ChartArea = area1;

LineChartLayer1.AxisX = axisX;

LineChartLayer1.AxisY = axisY1;

this.ultraChart1.CompositeChart.ChartLayers.Add(LineChartLayer1);

 

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

lineChartLayer2.Series.Add(scl1);

lineChartLayer2.ChartArea = area1;

lineChartLayer2.AxisX = axisX;

lineChartLayer2.AxisY = axisY2;

this.ultraChart1.CompositeChart.ChartLayers.Add(lineChartLayer2);

Parents
No Data
Reply Children
No Data