回复 1楼婧友521的帖子
测试代码:
- protected void Page_Load(object sender, EventArgs e)
- {
- if (IsPostBack)
- return;
- DataTable dt = new DataTable("Test");
- DataRow dr = default(System.Data.DataRow);
- dt.Columns.Add("名称");
- dt.Columns.Add("数量");
- dr = dt.NewRow();
- dr[0] = "电器";
- dr[1] = 0.8;
- dt.Rows.Add(dr);
- dr = dt.NewRow();
- dr[0] = "服装";
- dr[1] = 0.14;
- dt.Rows.Add(dr);
- dr = dt.NewRow();
- dr[0] = "家具";
- dr[1] = 0.10;
- dt.Rows.Add(dr);
- FarPoint.Web.Chart.BarSeries series = new FarPoint.Web.Chart.BarSeries();
- series.Values.DataSource = dt;
- series.Values.DataField = dt.Columns[1].ColumnName;
- series.VaryColors = true;
- series.CategoryNames.Add("电器");
- series.CategoryNames.Add("服装");
- series.CategoryNames.Add("家具");
- //设置显示数值
- series.LabelVisible = true;
- //设置 Percentage 形式显示
- series.LabelNumberFormat = "00.0%";
- 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);
- LegendArea legend = new LegendArea();
- legend.Location = new PointF(0.98f, 0.5f);
- legend.AlignmentX = 1.0f;
- legend.AlignmentY = 0.5f;
- LabelArea label = new LabelArea();
- label.Text = "产品分布";
- label.Location = new PointF(0.5f, 0.02f);
- label.AlignmentX = 0.5f;
- label.AlignmentY = 0.0f;
- FarPoint.Web.Chart.ChartModel model = new FarPoint.Web.Chart.ChartModel();
- model.PlotAreas.Add(plotArea);
- model.LegendAreas.Add(legend);
- model.LabelAreas.Add(label);
-
- FarPoint.Web.Spread.Chart.SpreadChart chart = new FarPoint.Web.Spread.Chart.SpreadChart();
- chart.ViewType = ChartViewType.View3D;
- chart.Model = model;
- FpSpread1.Sheets[0].Charts.Add(chart);
- }
复制代码 |