水晶报表
现在使用Aspose.Chart进行解决,但不完美的地方是,柱图之间的间距还有就是x轴使用文字而非数字,右边的标示怎样去掉,官方没有demo,摸索着,苦恼~~
1 public static Image DrawAnalysisPic(DataTable dt)
2 {
3
4 Aspose.Chart.Chart chart = new Aspose.Chart.Chart();
5 chart.Height = 300;
6 chart.Width = 500;
7 int Rc = dt.Rows.Count;
8 Series[] seriesArray = new Series[Rc];
9
10 for (int seriesIdx = 0; seriesIdx < seriesArray.Length; seriesIdx++)
11 {
12 int colIdx = seriesIdx + 1;
13 Series series = new Series();
14 series.ChartType = ChartType.Bar;
15 series.CustomAttributes.IsAreaStacked = true;
16 series.Name = dt.Rows[seriesIdx][0].ToString();
17 seriesArray[seriesIdx] = series;
18 series.IsPrimaryAxisX = true;
19 series.CustomAttributes.BarWidthRate = (float)0.5;
20 //series.CustomAttributes.IsBarHorizontal = true;//垂直
21 // series.CustomAttributes.IsBarCone = true;//尖角
22 //series.CustomAttributes.BarWidth = (float)10;
23 }
24
25
26 double minY = double.MaxValue;
27 double maxY = double.MinValue;
28
29 int i = 0;
30 for (int rowIdx = 0; rowIdx < Rc; rowIdx++)
31 {
32 i++;
33 double GenvelValue = Convert.ToDouble(dt.Rows[rowIdx][1].ToString());
34 seriesArray[rowIdx].DataPoints.Add(i, GenvelValue);
35 minY = Math.Min(minY, GenvelValue);
36 maxY = Math.Max(maxY, GenvelValue);
37 }
38
39 chart.ChartArea.AxisX.IsAutoCalc = false;
40 chart.ChartArea.AxisY.IsAutoCalc = false;
41 chart.ChartArea.AxisX.IntervalType = IntervalType.String;
42
43 chart.ChartArea.AxisX.Minimum = 0;
44 chart.ChartArea.AxisX.Maximum = Rc + 8;
45 chart.ChartArea.AxisY.Minimum = 0;
46 chart.ChartArea.AxisY.Maximum = maxY;
47 chart.ChartArea.ClusterWidthRate = 0.1F;
48
49 for (int seriesIdx = 0; seriesIdx < seriesArray.Length; seriesIdx++)
50 {
51 chart.SeriesCollection.Add(seriesArray[seriesIdx]);
52
53 }
54 chart.ChartArea.ClusterWidthRate = (float)0.8;
55 return chart.GetChartImage();
56
57 }
第一幅图已经搞定
第二幅图 还是没想到该咋弄
弄成这样的也行,如下图:
我生成的图片如下图,怎样能生成多个Y轴呢,使用的是Owc11生成的。
@戒掉戒: 可以试试highcharts,很不错的一个图片JS库:http://www.highcharts.com/