/// <summary> /// 柱状图 /// </summary> /// <returns></returns> public string GenerateBarChart() { int[] data = new int[] { 1027, 98, 36, 374, 473, 54, 126, 22, 147, 20, 188, 58 }; string[] axisLabels = new string[] { "AA", "BB", "BB", "DD", "EE", "FF", "GG", "HH", "II", "JJ", "KK", "LL" }; BarChart barChart = new BarChart(500, 250, BarChartOrientation.Vertical, BarChartStyle.Grouped); barChart.SetTitle("三日内更新数据"); ChartAxis axisX = new ChartAxis(ChartAxisType.Bottom, axisLabels); ChartAxis axisY = new ChartAxis(ChartAxisType.Left); axisY.SetRange(0, barChart.findMaxValue(data)); barChart.AddAxis(axisX); barChart.AddAxis(axisY); barChart.SetData(barChart.ConvertToPorcent(data)); return(barChart.GetUrl()); }
public static string horizontalStackedTest() { int[] data1 = new int[] { 10, 5, 20, 15 }; int[] data2 = new int[] { 10, 10, 10, 10 }; List <int[]> dataset = new List <int[]>(); dataset.Add(data1); dataset.Add(data2); BarChart barChart = new BarChart(150, 150, BarChartOrientation.Horizontal, BarChartStyle.Stacked); barChart.SetTitle("Horizontal Stacked"); barChart.AddAxis(new ChartAxis(ChartAxisType.Bottom)); barChart.AddAxis(new ChartAxis(ChartAxisType.Left)); barChart.SetData(dataset); barChart.SetDatasetColors(new string[] { "FF0000", "00AA00" }); return(barChart.GetUrl()); }
public static string verticalGroupedTest() { int[] data1 = new int[] { 10, 5, 20 }; int[] data2 = new int[] { 30, 35, 15 }; List <int[]> dataset = new List <int[]>(); dataset.Add(data1); dataset.Add(data2); BarChart barChart = new BarChart(300, 150, BarChartOrientation.Vertical, BarChartStyle.Grouped); barChart.SetTitle("Vertical Grouped"); barChart.AddAxis(new ChartAxis(ChartAxisType.Bottom)); barChart.AddAxis(new ChartAxis(ChartAxisType.Left)); barChart.SetData(dataset); barChart.SetDatasetColors(new string[] { "FF0000", "00AA00" }); return(barChart.GetUrl()); }