回复 1楼婧友521的帖子
你好,Legend 标签对应的值为 Series 下属性 SeriesName 属性,测试代码如下:
-
- System.Data.DataTable dt = new System.Data.DataTable("Test");
- System.Data.DataRow dr = default(System.Data.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] = 2;
- dt.Rows.Add(dr);
- FarPoint.Web.Chart.BarSeries series = new FarPoint.Web.Chart.BarSeries();
- series.SeriesName = "系列1";
- series.CategoryNames.Add("电器");
- series.CategoryNames.Add("家具");
- series.CategoryNames.Add("药品");
- series.Values.DataSource = dt;
- series.Values.DataField = dt.Columns[0].ColumnName;
- FarPoint.Web.Chart.BarSeries series1 = new FarPoint.Web.Chart.BarSeries();
- series1.SeriesName = "系列2";
- series1.Values.DataSource = dt;
- series1.Values.DataField = dt.Columns[1].ColumnName;
- LegendArea legend = new LegendArea();
- legend.Location = new PointF(0.98f, 0.5f);
- legend.AlignmentX = 1.0f;
- legend.AlignmentY = 0.5f;
- FarPoint.Web.Chart.YPlotArea plotArea = new FarPoint.Web.Chart.YPlotArea();
- plotArea.Location = new System.Drawing.PointF(0.2F, 0.2F);
- plotArea.Size = new System.Drawing.SizeF(0.6F, 0.6F);
- plotArea.Series.Add(series);
- plotArea.Series.Add(series1);
- FarPoint.Web.Chart.ChartModel model = new FarPoint.Web.Chart.ChartModel();
- model.PlotAreas.Add(plotArea);
- model.LegendAreas.Add(legend);
- FarPoint.Web.Spread.Chart.SpreadChart chart = new FarPoint.Web.Spread.Chart.SpreadChart();
- chart.Model = model;
- FpSpread1.Sheets[0].Charts.Add(chart);
复制代码 |