回复 1楼xjmhz的帖子
请参考以下代码:
- private void Form1_Load(object sender, EventArgs e)
- {
- DataTable dt = new DataTable("Test");
- DataRow dr = default(DataRow);
- dt.Columns.Add("Series0");
- dt.Columns.Add("Series1");
-
- dr = dt.NewRow();
- dr[0] = 2;
- dr[1] = 1;
- dt.Rows.Add(dr);
- dr = dt.NewRow();
- dr[0] = 4;
- dr[1] = 2;
- dt.Rows.Add(dr);
- dr = dt.NewRow();
- dr[0] = 3;
- dr[1] = 4;
-
- FarPoint.Win.Chart.BarSeries series = new FarPoint.Win.Chart.BarSeries();
- series.Values.DataSource = dt;
- series.Values.DataField = dt.Columns[0].ColumnName;
-
- FarPoint.Win.Chart.YPlotArea plotArea = new FarPoint.Win.Chart.YPlotArea();
- FarPoint.Win.Chart.ChartModel model = new FarPoint.Win.Chart.ChartModel();
- plotArea.Location = new PointF(0.2F, 0.2F);
- plotArea.Size = new SizeF(0.6F, 0.6F);
- plotArea.Series.Add(series);
- model.PlotAreas.Add(plotArea);
-
- SpreadChart chart = fpSpread1.Sheets[0].AddChart(0, 0, typeof(FarPoint.Win.Chart.BarSeries), 400, 400, 0, 0);
- chart.Model = model;
- }
复制代码 |