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

下面的類同樣可用于創(chuàng)建Y坐標類型的圖表:
- YSeries
- BarSeries
- AreaSeries
- LineSeries
- PointSeries
- HighLowAreaSeries
- HighLowBarSeries
- HighLowCloseSeries
使用代碼創(chuàng)建Y坐標圖表
- 使用BarSeries類在圖表控件中添加數(shù)據(jù)。
- 使用YPlotArea類創(chuàng)建坐標圖區(qū)域。
- 設(shè)置坐標圖位置和大小。
- 為坐標圖區(qū)域添加系列。
- 為圖表創(chuàng)建標簽和圖例。
- 創(chuàng)建圖表模板,并為其添加坐標圖區(qū)域、標簽和圖例。
- 創(chuàng)建圖表,并在其中添加一個圖表模型。
示例
下面的示例演示了如何創(chuàng)建一個Y坐標圖表,并添加未綁定的數(shù)據(jù)到控件中。
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
使用圖表設(shè)計器創(chuàng)建Y坐標圖表
- 選擇PlotArea Collection編輯器。
- 根據(jù)需要設(shè)置屬性。
(慧都控件網(wǎng)版權(quán)所有,轉(zhuǎn)載請注明出處,否則追究法律責任)
標簽:
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)