コード例 #1
0
        public void Create(Chart chart, string title, Excel.DataTable table, string xColumn, string yColumn, string style, bool user3D)
        {
            chart.Palette = new Color[] { Color.FromArgb(49, 255, 49), Color.FromArgb(255, 255, 0), Color.FromArgb(255, 99, 49), Color.FromArgb(0, 156, 255),
                                          Color.FromArgb(255, 125, 49), Color.FromArgb(125, 255, 49), Color.FromArgb(0, 255, 49) };
            chart.Use3D = user3D;
            SeriesCollection mySC = getRandomData(table, xColumn, yColumn);

            if (string.IsNullOrEmpty(style) || style == "线形")
            {
                chart.Type = ChartType.Combo;
                mySC       = getRandomData2(table, xColumn, yColumn);
            }
            else if (style == "柱形")
            {
                chart.Type = ChartType.Combo;
            }
            else if (style == "金字塔")
            {
                chart.Type = ChartType.MultipleGrouped;
                chart.DefaultSeries.Type = SeriesTypeMultiple.Pyramid;
            }
            else if (style == "圆锥")
            {
                chart.Type = ChartType.MultipleGrouped;
                chart.DefaultSeries.Type = SeriesTypeMultiple.Cone;
            }
            chart.Title = title;
            if (string.IsNullOrEmpty(style) || style == "线形")
            {
                chart.DefaultSeries.Type = SeriesType.Line;
            }

            chart.DefaultElement.ShowValue = true;
            chart.PieLabelMode             = PieLabelMode.Outside;
            chart.ShadingEffectMode        = ShadingEffectMode.Three;
            chart.NoDataLabel.Text         = "没有数据显示";
            chart.SeriesCollection.Add(mySC);
        }