我在调试spreadchart的时候碰到如下问题:- DataTable dt = new DataTable("Test");
- DataRow dr = default(DataRow);
- dt.Columns.Add("Series1");
- dt.Columns.Add("Series2");
- dr = dt.NewRow();
- dr[0] = 1;
- dr[1] = 4;
- dt.Rows.Add(dr);
- dr = dt.NewRow();
- dr[0] = 2;
- dr[1] = 5;
- dt.Rows.Add(dr);
- dr = dt.NewRow();
- dr[0] = 3;
- dr[1] = 6;
- dt.Rows.Add(dr);
- fpSpread1.DataSource = dt;
- PieSeries ps = new PieSeries();
- FarPoint.Win.Spread.Model.CellRange cellRange = new FarPoint.Win.Spread.Model.CellRange(0, 0, 2, 2);
- fpSpread1.Sheets[0].AddChart(cellRange, typeof(FarPoint.Win.Chart.PieSeries), 400, 400, 0, 0);
复制代码 这个画出来的图单击右键是可以更改图表类型的,也就是从饼状图改成折线图什么的都可以。
但是用- XYPointSeries series0 = new XYPointSeries();
- series0.SeriesName = "Series 0";
- series0.XValues.Add(1.0);
- series0.XValues.Add(2.0);
- series0.XValues.Add(4.0);
- series0.XValues.Add(8.0);
- series0.YValues.Add(2.0);
- series0.YValues.Add(4.0);
- series0.YValues.Add(3.0);
- series0.YValues.Add(5.0);
- XYPlotArea plotArea = new XYPlotArea();
- plotArea.Location = new PointF(0.2f, 0.2f);
- plotArea.Size = new SizeF(0.6f, 0.6f);
- plotArea.Series.Add(series0);
- LabelArea label = new LabelArea();
- label.Text = "XY Point 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);
- FarPoint.Win.Spread.Chart.SpreadChart chart = new FarPoint.Win.Spread.Chart.SpreadChart();
- chart.Size = new Size(200, 200);
- chart.Location = new Point(100, 100);
- chart.Model = model;
- fpSpread1.ActiveSheet.Charts.Add(chart);
复制代码 却改不了图表类型。
我想既用后者,又能让用户改图表类型,有没有什么办法 |
|