C# Code:
Chart c = new Chart();
c.BackColor = Color.FromArgb(217, 224, 236);
c.Titles.Add(new Title());
c.Titles[0].Text = "Bar and Line, Two Y Axes";
c.Titles[0].Color = Color.Yellow;
c.ChartArea.LegendBox.IsVisible = false;
c.FrameBorder.BorderType = BorderType.LinesCrossed;
c.FrameBorder.LineStep = 10;
c.ChartArea.AxisY2.IsMajorGridVisible = false;
Series s0 = new Series();
s0.IsPrimaryAxisY = true;
c.ChartArea.AxisY.DefaultLabel.Color = s0.DefaultDataPoint.Color = s0.DefaultDataPoint.BorderColor = Color.Green;
s0.ChartType = ChartType.Line;
for (int i = 1; i < 8; i++)
s0.DataPoints.Add(new DataPoint(i, i*i));
c.SeriesCollection.Add(s0);
Series s1 = new Series();
s1.IsPrimaryAxisY = false;
c.ChartArea.AxisY2.DefaultLabel.Color = s1.DefaultDataPoint.Color = Color.Blue;
s1.ChartType = ChartType.Bar;
for (int i = 1; i < 8; i++)
s1.DataPoints.Add(new DataPoint(i, i*i*i));
c.SeriesCollection.Add(s1);
c.BackColor = Color.FromArgb(217, 224, 236);
c.Titles.Add(new Title());
c.Titles[0].Text = "Bar and Line, Two Y Axes";
c.Titles[0].Color = Color.Yellow;
c.ChartArea.LegendBox.IsVisible = false;
c.FrameBorder.BorderType = BorderType.LinesCrossed;
c.FrameBorder.LineStep = 10;
c.ChartArea.AxisY2.IsMajorGridVisible = false;
Series s0 = new Series();
s0.IsPrimaryAxisY = true;
c.ChartArea.AxisY.DefaultLabel.Color = s0.DefaultDataPoint.Color = s0.DefaultDataPoint.BorderColor = Color.Green;
s0.ChartType = ChartType.Line;
for (int i = 1; i < 8; i++)
s0.DataPoints.Add(new DataPoint(i, i*i));
c.SeriesCollection.Add(s0);
Series s1 = new Series();
s1.IsPrimaryAxisY = false;
c.ChartArea.AxisY2.DefaultLabel.Color = s1.DefaultDataPoint.Color = Color.Blue;
s1.ChartType = ChartType.Bar;
for (int i = 1; i < 8; i++)
s1.DataPoints.Add(new DataPoint(i, i*i*i));
c.SeriesCollection.Add(s1);
VB.NET Code:
Dim c As Chart = New Chart
c.BackColor = Color.FromArgb(217, 224, 236)
c.Titles.Add(New Title)
c.Titles(0).Text = "Bar and Line, Two Y Axes"
c.Titles(0).Color = Color.Yellow
c.ChartArea.LegendBox.IsVisible = False
c.FrameBorder.BorderType = BorderType.LinesCrossed
c.FrameBorder.LineStep = 10
c.ChartArea.AxisY2.IsMajorGridVisible = False
Dim s0 As Series = New Series
s0.IsPrimaryAxisY = True
c.ChartArea.AxisY.DefaultLabel.Color = Color.Green
s0.DefaultDataPoint.Color = Color.Green
s0.DefaultDataPoint.BorderColor = Color.Green
s0.ChartType = ChartType.Line
Dim i As Integer
For i = 1 To 8 - 1
s0.DataPoints.Add(New DataPoint(i, i * i))
Next
c.SeriesCollection.Add(s0)
Dim s1 As Series = New Series
s1.IsPrimaryAxisY = False
c.ChartArea.AxisY2.DefaultLabel.Color = Color.Blue
s1.DefaultDataPoint.Color = Color.Blue
s1.ChartType = ChartType.Bar
For i = 1 To 8 - 1
s1.DataPoints.Add(New DataPoint(i, i * i * i))
Next
c.SeriesCollection.Add(s1)
效果如下:c.BackColor = Color.FromArgb(217, 224, 236)
c.Titles.Add(New Title)
c.Titles(0).Text = "Bar and Line, Two Y Axes"
c.Titles(0).Color = Color.Yellow
c.ChartArea.LegendBox.IsVisible = False
c.FrameBorder.BorderType = BorderType.LinesCrossed
c.FrameBorder.LineStep = 10
c.ChartArea.AxisY2.IsMajorGridVisible = False
Dim s0 As Series = New Series
s0.IsPrimaryAxisY = True
c.ChartArea.AxisY.DefaultLabel.Color = Color.Green
s0.DefaultDataPoint.Color = Color.Green
s0.DefaultDataPoint.BorderColor = Color.Green
s0.ChartType = ChartType.Line
Dim i As Integer
For i = 1 To 8 - 1
s0.DataPoints.Add(New DataPoint(i, i * i))
Next
c.SeriesCollection.Add(s0)
Dim s1 As Series = New Series
s1.IsPrimaryAxisY = False
c.ChartArea.AxisY2.DefaultLabel.Color = Color.Blue
s1.DefaultDataPoint.Color = Color.Blue
s1.ChartType = ChartType.Bar
For i = 1 To 8 - 1
s1.DataPoints.Add(New DataPoint(i, i * i * i))
Next
c.SeriesCollection.Add(s1)