Spread Windows Forms允許你使用代碼或者設計器創建一個Y坐標圖表。下圖展示了一個Y坐標Bar類型的圖表。
Spread.NET下載

下面的類同樣可用于創建Y坐標類型的圖表:
- YSeries
- BarSeries
- AreaSeries
- LineSeries
- PointSeries
- HighLowAreaSeries
- HighLowBarSeries
- HighLowCloseSeries
使用代碼創建Y坐標圖表
- 使用BarSeries類在圖表控件中添加數據。
- 使用YPlotArea類創建坐標圖區域。
- 設置坐標圖位置和大小。
- 為坐標圖區域添加系列。
- 為圖表創建標簽和圖例。
- 創建圖表模板,并為其添加坐標圖區域、標簽和圖例。
- 創建圖表,并在其中添加一個圖表模型。
示例
下面的示例演示了如何創建一個Y坐標圖表,并添加未綁定的數據到控件中。
C#
BarSeries series = new BarSeries();
series.SeriesName = "Series 0";
series.Values.Add(2.0);
series.Values.Add(4.0);
series.Values.Add(3.0);
series.Values.Add(5.0);
YPlotArea plotArea = new YPlotArea();
plotArea.Location = new PointF(0.2f, 0.2f);
plotArea.Size = new SizeF(0.6f, 0.6f);
plotArea.Series.Add(series);
LabelArea label = new LabelArea();
label.Text = "Bar Chart";
label.Location = new PointF(0.5f, 0.02f);
label.AlignmentX = 0.5f;
label.AlignmentY = 0.0f;
LegendArea legend = new LegendArea();
legend.Location = new PointF(0.98f, 0.5f);
legend.AlignmentX = 1.0f;
legend.AlignmentY = 0.5f;
ChartModel model = new ChartModel();
model.LabelAreas.Add(label);
model.LegendAreas.Add(legend);
model.PlotAreas.Add(plotArea);
chart2DControl1.Model = model;
VB
Dim series As New FarPoint.Win.Chart.BarSeries()
series.SeriesName = "Series 0"
series.Values.Add(2.0)
series.Values.Add(4.0)
series.Values.Add(3.0)
series.Values.Add(5.0)
Dim plotArea As New FarPoint.Win.Chart.YPlotArea()
plotArea.Location = New PointF(0.2F, 0.2F)
plotArea.Size = New SizeF(0.6F, 0.6F)
plotArea.Series.Add(series)
Dim label As New FarPoint.Win.Chart.LabelArea()
label.Text = "Bar Chart"
label.Location = New PointF(0.5F, 0.02F)
label.AlignmentX = 0.5F
label.AlignmentY = 0.0F
Dim legend As New FarPoint.Win.Chart.LegendArea()
legend.Location = New PointF(0.98F, 0.5F)
legend.AlignmentX = 1.0F
legend.AlignmentY = 0.5F
Dim model As New FarPoint.Win.Chart.ChartModel()
model.LabelAreas.Add(label)
model.LegendAreas.Add(legend)
model.PlotAreas.Add(plotArea)
chart2DControl1.Model = model
使用圖表設計器創建Y坐標圖表
- 選擇PlotArea Collection編輯器。
- 根據需要設置屬性。
(慧都控件網版權所有,轉載請注明出處,否則追究法律責任)
標簽:
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網