Пример #1
0
        /// <summary>
        /// 根据dataTable获取各条曲线
        /// </summary>
        /// <param name="chart">dotNetChart</param>
        /// <param name="lstFieldsY">Y轴字段</param>
        /// <param name="fieldX">X轴字段</param>
        public void getSeries(dotnetCHARTING.Chart chart, List <string> lstFieldsY, string fieldX)
        {
            DeletetongjiPNG(this._phaysicalimagepath);
            chart.TempDirectory = this._phaysicalimagepath;

            chart.SeriesCollection.Clear();

            for (int i = 0; i < lstFieldsY.Count; i++)
            {
                Series series = new Series();

                for (int j = 0; j < _dt.Rows.Count; j++)
                {
                    Element element = new Element();
                    double  y       = 0;
                    if (_dt.Rows[j][lstFieldsY[i]].ToString() != "")
                    {
                        y = double.Parse(_dt.Rows[j][lstFieldsY[i]].ToString());
                    }
                    element.YValue = y;
                    element.Name   = _dt.Rows[j][fieldX].ToString();
                    series.Elements.Add(element);
                }
                chart.SeriesCollection.Add(series);
            }
        }
Пример #2
0
        /// <summary>
        /// 柱形图
        /// </summary>
        /// <returns></returns>
        public void CreateDonut(dotnetCHARTING.Chart chart1)
        {
            chart1.Title = Title;
            chart1.FileManager.FileName = FileName;
            chart1.XAxis.Label.Text     = XName;
            chart1.YAxis.Label.Text     = this.YName;
            chart1.TempDirectory        = this.PhaysicalImagePath;
            chart1.Width       = this.PicWidth;
            chart1.Height      = this.PicHight;
            chart1.Type        = ChartType.Donut;
            chart1.Series.Type = SeriesType.Cylinder;
            chart1.Series.Name = this.SeriseName;
            //chart1.Series.Data = this.DataSoure;
            chart1.SeriesCollection.Add(getArrayData());
            chart1.DefaultSeries.DefaultElement.ShowValue = true;
            //chart1.DefaultSeries.Type = SeriesType.Cylinder;
            chart1.ShadingEffect = true;
            chart1.Use3D         = IsUse3D;
            chart1.Series.DefaultElement.ShowValue = true;

            chart1.LegendBox.Label = new dotnetCHARTING.Label("图表说明",
                                                              new Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
                                                                       134));
            //chart.LegendBox.HeaderLabel.Font = new Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
            chart1.LegendBox.Label.Font = new Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold,
                                                   System.Drawing.GraphicsUnit.Point, 134);
            //chart1.Palette = new Color[] { Color.FromArgb(0, 156, 255), Color.FromArgb(255, 99, 49), Color.FromArgb(49, 255, 49), Color.FromArgb(255, 255, 0), };
        }
        public static void ComboHorizontal(dotnetCHARTING.Chart chart, int width, int height, string title, DataTable table, string xColumn, string yColumn)
        {
            SeriesCollection SC = new SeriesCollection();
            Series           s  = new Series();

            foreach (DataRow row in table.Rows)
            {
                string  telType = row[xColumn].ToString();
                Element e       = new Element();
                e.Name          = telType;
                e.LabelTemplate = "%PercentOfTotal";
                e.YValue        = Convert.ToDouble(row[yColumn].ToString());
                s.Elements.Add(e);
            }
            SC.Add(s);
            chart.TempDirectory                      = "temp";
            chart.Use3D                              = false;
            chart.DefaultAxis.Interval               = 10;
            chart.DefaultAxis.CultureName            = "zh-CN";
            chart.Palette                            = new Color[] { Color.FromArgb(49, 255, 49), Color.FromArgb(255, 255, 0), Color.FromArgb(255, 99, 49), Color.FromArgb(0, 156, 255) };
            chart.DefaultElement.SmartLabel.AutoWrap = true;
            chart.Type = ChartType.ComboHorizontal;
            chart.Size = width + "x" + height;
            chart.DefaultElement.SmartLabel.Text = "";
            chart.Title = title;
            chart.DefaultElement.ShowValue = true;
            chart.PieLabelMode             = PieLabelMode.Outside;
            chart.ShadingEffectMode        = ShadingEffectMode.Three;
            chart.NoDataLabel.Text         = "没有数据显示";
            chart.SeriesCollection.Add(SC);
        }
Пример #4
0
 /// <summary>
 ///     横行柱形图
 /// </summary>
 /// <returns></returns>
 public void CreateComboHorizontal(dotnetCHARTING.Chart chart1)
 {
     //chart1.XAxis.StaticColumnWidth = ColumnWidth; //每个单元格的宽度
     //chart1.YAxis.StaticColumnWidth = ColumnWidth; //每个单元格的宽度
     //chart1.XAxis.NumberPercision = NumberPercision; //设置小数点
     //chart1.YAxis.Line.Width = 5;//箭头宽度
     //chart1.XAxis.Line.Width = 5;//箭头宽度
     chart1.YAxis.StaticColumnWidth = 8000; //每个单元格的宽度
     chart1.XAxis.StaticColumnWidth = 8000; //每个单元格的宽度
     chart1.Title = Title;
     chart1.FileManager.FileName = FileName;
     chart1.XAxis.Label.Text     = XName;
     chart1.YAxis.Label.Text     = YName;
     chart1.TempDirectory        = PhaysicalImagePath;
     chart1.Width       = PicWidth;
     chart1.Height      = PicHight;
     chart1.Type        = ChartType.ComboHorizontal;
     chart1.Series.Type = SeriesType.Cylinder;
     chart1.Series.Name = SeriseName;
     chart1.Series.Data = DataSoure;
     chart1.SeriesCollection.Add(getArrayData());
     chart1.DefaultSeries.DefaultElement.ShowValue = true;
     chart1.DefaultSeries.Type = SeriesType.Cylinder;
     chart1.ShadingEffect      = true;
     chart1.XAxis.Percent      = true; //启用百分比
     chart1.Use3D = IsUse3D;
     chart1.Series.DefaultElement.ShowValue = true;
 }
Пример #5
0
        /// <summary>
        /// 多序列柱形图
        /// </summary>
        /// <returns></returns>
        public void CreateCombos(dotnetCHARTING.Chart chart1)
        {
            chart1.Title = Title;
            //chart1.ChartArea.Background.Color = Color.White;//图片背景
            chart1.FileManager.FileName = FileName;
            //chart1.XAxis.Label.Text = XName;
            chart1.XAxis.StaticColumnWidth = 80;              //每个单元格的宽度
            chart1.YAxis.NumberPercision   = NumberPercision; //设置小数点
            //chart1.YAxis.Label.Text = this.YName;
            chart1.TempDirectory = this.PhaysicalImagePath;
            chart1.Width         = this.PicWidth;
            chart1.Height        = this.PicHight;
            chart1.Type          = ChartType.Combo;
            chart1.Series.Type   = SeriesType.Bar;
            chart1.Series.Name   = "图例名称" + this.SeriseName;
            //chart1.Series.Data = this.DataSoure;
            chart1.SeriesCollection.Add(getArrayData2());
            chart1.YAxis.Percent = true; //启用百分比
            chart1.DefaultSeries.DefaultElement.ShowValue = true;

            //chart1.DefaultSeries.Type = SeriesType.Bar;//
            //chart1.DefaultSeries.Type = SeriesType.Bar;//方形
            chart1.ShadingEffect = true;
            chart1.Use3D         = IsUse3D;
            chart1.Series.DefaultElement.ShowValue = true;
        }
Пример #6
0
        public void Pie(dotnetCHARTING.Chart chart, int width, int height, string title, System.Data.DataTable table, string xColumn, string yColumn)
        {
            dotnetCHARTING.SeriesCollection SC = new dotnetCHARTING.SeriesCollection();
            dotnetCHARTING.Series           s  = new dotnetCHARTING.Series("");
            DataView view = new DataView(table);

            view.Sort = yColumn + "  desc";
            int index = 0;

            System.Data.DataTable table2 = view.ToTable();
            Element otherE = new Element("其他");

            bool   other    = false;
            double otherSum = 0;

            foreach (DataRow row in table2.Rows)
            {
                if (index > 9)
                {
                    otherSum            += Convert.ToDouble(row[yColumn].ToString());
                    otherE.LabelTemplate = "%PercentOfTotal";
                    other = true;
                    continue;
                }
                string telType = row[xColumn].ToString();
                telType = SetXColumn(telType);
                Element e = new Element(telType);
                e.LabelTemplate = "%PercentOfTotal";

                e.YValue = Convert.ToDouble(row[yColumn].ToString());
                s.Elements.Add(e);
                index++;
            }
            if (other)
            {
                s.Elements.Add(otherE);
            }
            chart.TitleBox.Position = TitleBoxPosition.FullWithLegend;
            otherE.YValue           = otherSum;
            SC.Add(s);
            chart.TempDirectory            = "temp";
            chart.Use3D                    = false;
            chart.DefaultAxis.FormatString = "N";
            chart.DefaultAxis.CultureName  = "zh-CN";
            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, 156, 255), Color.FromArgb(0, 156, 0), Color.FromArgb(0, 156, 99), Color.FromArgb(0, 99, 255), Color.FromArgb(99, 156, 255),
                                                           Color.FromArgb(0, 0, 99), Color.FromArgb(0, 156, 126) };
            chart.DefaultElement.SmartLabel.AutoWrap = true;
            chart.Type = ChartType.Pies;
            chart.Size = width + "x" + height;
            chart.DefaultElement.SmartLabel.Text = "";
            chart.Title = title;
            chart.DefaultElement.ShowValue           = true;
            chart.PieLabelMode                       = PieLabelMode.Outside;
            chart.ShadingEffectMode                  = ShadingEffectMode.Three;
            chart.DefaultElement.SmartLabel.AutoWrap = true;
            chart.NoDataLabel.Text                   = "没有数据显示";
            chart.SeriesCollection.Add(SC);
        }
Пример #7
0
        /// <summary>
        /// 柱形图
        /// </summary>
        /// <returns></returns>
        public void CreateCombo(dotnetCHARTING.Chart chart1)
        {
            chart1.Title = Title;
            //chart1.ChartArea.Background.Color = Color.White;//图片背景
            //chart1.BackColor = Color.FromArgb(0xe1, 0xe1, 0xe1);//整个图表的背景颜色(外延伸部分)
            chart1.TitleBox.CornerTopLeft = BoxCorner.Square;      //标题框四角的样式
            chart1.LegendBox.Position     = LegendBoxPosition.Top; //提示说明框的位置
            chart1.FileManager.FileName   = FileName;
            chart1.XAxis.Label.Text       = XName;
            //chart1.XAxis.StaticColumnWidth = 100;//每个单元格的宽度
            //chart1.XAxis.StaticColumnWidth = ColumnWidth; //每个单元格的宽度

            chart1.YAxis.Label.Text = this.YName;
            chart1.TempDirectory    = this.PhaysicalImagePath;
            chart1.Width            = this.PicWidth;
            chart1.Height           = this.PicHight;
            chart1.Type             = ChartType.Combo;
            chart1.Series.Type      = SeriesType.Bar;
            chart1.Series.Name      = this.SeriseName;
            //chart1.Series.Data = this.DataSoure;
            chart1.SeriesCollection.Add(getArrayData());
            //chart1.DefaultSeries.DefaultElement.ShowValue = true;

            //chart1.DefaultSeries.Type = SeriesType.Bar;//
            //chart1.DefaultSeries.Type = SeriesType.Bar;//方形
            chart1.ShadingEffect = true;
            chart1.Use3D         = IsUse3D;
            //chart1.YAxis.NumberPercision = NumberPercision; //设置小数点
            chart1.YAxis.NumberPrecision = 2;    //很多朋友在使用的时候发现不能显示小数,同事帮忙解决。
            chart1.YAxis.Maximum         = 110;
            chart1.YAxis.Percent         = true; //启用百分比
            //BarBrush = new SolidBrush(Color.FromArgb(AP3, BarBrushColor[i % 12]));
            chart1.Series.DefaultElement.ShowValue = true;

            //刻度
            chart1.XAxis.Name             = Title;
            chart1.YAxis.TickLabelPadding = 0;
            chart1.YAxis.Line.StartCap    = System.Drawing.Drawing2D.LineCap.Square;
            chart1.YAxis.Line.EndCap      = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
            chart1.YAxis.Line.Width       = 5;//左侧label
            chart1.YAxis.Line.Color       = Color.Gray;
            //chart1.YAxis.Interval = 50;间隔大小
            //chart1.YAxis.LabelMarker = new ElementMarker().Type;


            //X轴说明
            //chart1.XAxis.Label.Font = new Font("Arial Black", 9, FontStyle.Bold);
            //chart1.XAxis.Line.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
            //chart1.XAxis.Line.Width = 2;
            chart1.XAxis.StaticColumnWidth = 80; //每个单元格的宽度
            chart1.XAxis.SweepAngle        = 45;
            //chart1.XAxis.Line.Color = Color.Gray;
            //chart1.XAxis.MinorInterval = 5;
            //chart1.DefaultBox.Visible = true;
        }
Пример #8
0
        /// <summary>
        /// 设置曲线类型
        /// </summary>
        /// <param name="chart">dotNetChart</param>
        /// <param name="chartType">dotNetChart类型</param>
        /// <param name="seriesType">dotNetChart曲线类型</param>
        private void setChartType(dotnetCHARTING.Chart chart,
                                  dotnetCHARTING.ChartType chartType, dotnetCHARTING.SeriesType seriesType)
        {
            chart.Type = chartType;

            for (int i = 0; i < chart.SeriesCollection.Count; i++)
            {
                chart.SeriesCollection[i].Type = seriesType;
                chart.SeriesCollection[i].Name = this._lstName[i];
            }
        }
Пример #9
0
        /// <summary>
        /// 根据sql 语句获取各条曲线
        /// </summary>
        /// <param name="chart">dotNetChart</param>
        /// <param name="strLst">用于存放sql语句的List</param>
        public void getSeries(dotnetCHARTING.Chart chart, string strConn)
        {
            DeletetongjiPNG(this._phaysicalimagepath);
            chart.TempDirectory = this._phaysicalimagepath;

            chart.SeriesCollection.Clear();

            DataEngine _de = new DataEngine();//图片数据源

            _de.ConnectionString = strConn;

            for (int i = 0; i < this._lstSql.Count; i++)
            {
                _de.SqlStatement = this._lstSql[i];
                chart.SeriesCollection.Add(_de.GetSeries());
            }
        }
Пример #10
0
        /// <summary>
        /// 饼图
        /// </summary>
        /// <returns></returns>
        public void CreatePie(dotnetCHARTING.Chart chart)
        {
            chart.Title         = this._title;
            chart.TempDirectory = this._phaysicalimagepath;
            chart.Width         = this._picwidth;
            chart.Height        = this._pichight;
            chart.Type          = ChartType.Pie;
            chart.Series.Type   = SeriesType.Cylinder;
            chart.Series.Name   = this._seriesname;

            chart.ShadingEffect = true;
            chart.Use3D         = false;
            chart.DefaultSeries.DefaultElement.Transparency = 20;
            chart.DefaultSeries.DefaultElement.ShowValue    = true;
            chart.PieLabelMode = PieLabelMode.Outside;
            chart.SeriesCollection.Add(getArrayData());
            chart.Series.DefaultElement.ShowValue = true;
        }
Пример #11
0
 /// <summary>
 /// 曲线图
 /// </summary>
 /// <returns></returns>
 public void CreateLine(dotnetCHARTING.Chart chart)
 {
     chart.Title            = this._title;
     chart.XAxis.Label.Text = this._xtitle;
     chart.YAxis.Label.Text = this._ytitle;
     chart.TempDirectory    = this._phaysicalimagepath;
     chart.Width            = this._picwidth;
     chart.Height           = this._pichight;
     chart.Type             = ChartType.Combo;
     chart.Series.Type      = SeriesType.Line;
     chart.Series.Name      = this._seriesname;
     chart.Series.Data      = this._dt;
     chart.SeriesCollection.Add();
     chart.DefaultSeries.DefaultElement.ShowValue = true;
     chart.ShadingEffect = true;
     chart.Use3D         = false;
     chart.Series.DefaultElement.ShowValue = true;
 }
Пример #12
0
        /// <summary>
        /// 设置曲线的基本属性
        /// </summary>
        /// <param name="chart">dotNetChart</param>
        /// <param name="Title">标题</param>
        /// <param name="XTitle">x座标名称</param>
        /// <param name="YTitle">y座标名称</param>
        private void setChart(dotnetCHARTING.Chart chart)
        {
            chart.Title            = this._title;
            chart.XAxis.Label.Text = this._xtitle;
            chart.YAxis.Label.Text = this._ytitle;

            if (this._picwidth > 0)
            {
                chart.Width = this._picwidth;
            }
            if (this._pichight > 0)
            {
                chart.Height = this._pichight;
            }

            chart.Series.DefaultElement.ShowValue        = true;
            chart.DefaultSeries.DefaultElement.ShowValue = true;
        }
Пример #13
0
 /// <summary>
 /// 生成统计图片
 /// </summary>
 /// <param name="chart"></param>
 /// <param name="type">图形类别,如柱状,折线型</param>
 public void CreateStatisticPic(dotnetCHARTING.Chart chart)
 {
     chart.Title                = this.Title;
     chart.XAxis.Label.Text     = this.XTitle;
     chart.YAxis.Label.Text     = this.YTitle;
     chart.TempDirectory        = this.PhaysicalImagePath;
     chart.FileManager.FileName = this.FileName;
     chart.Width                = this.PicWidth;
     chart.Height               = this.PicHight;
     chart.Type = ChartType.Combo;
     //chart.Series.Type = this.Type;//生成对比的线型图时不适用
     chart.DefaultSeries.Type = this.Type; //统一使用默认的序列图类型属性
     chart.Series.Name        = this.SeriesName;
     chart.SeriesCollection.Add(this.DataSource);
     chart.DefaultSeries.DefaultElement.ShowValue = true;
     chart.ShadingEffect = true;
     chart.Use3D         = this.Use3D;
     chart.Series.DefaultElement.ShowValue = true;
 }
Пример #14
0
        /// <summary>
        /// 饼图
        /// </summary>
        /// <returns></returns>
        public void CreatePie(dotnetCHARTING.Chart chart1)
        {
            chart1.Title = Title;
            // chart1.LegendBox.Label = new dotnetCHARTING.Label("图表说明", new Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134));
            //chart.LegendBox.HeaderLabel.Font = new Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
            //chart1.LegendBox.Label.Font = new Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
            //chart1.Palette = new Color[] { Color.FromArgb(0, 156, 255), Color.FromArgb(255, 99, 49), Color.FromArgb(49, 255, 49), Color.FromArgb(255, 255, 0), };

            chart1.ChartArea.Background.Color = Color.White; //图片背景
            chart1.FileManager.FileName       = FileName;
            chart1.XAxis.Label.Text           = XName;
            chart1.XAxis.StaticColumnWidth    = ColumnWidth; //每个单元格的宽度
            chart1.XAxis.Label.Color          = Color.Red;
            chart1.YAxis.Label.Text           = this.YName;
            chart1.YAxis.Label.Color          = Color.Black;
            chart1.YAxis.NumberPercision      = NumberPercision; //设置小数点
            chart1.TempDirectory = this.PhaysicalImagePath;
            chart1.Width         = this.PicWidth;
            chart1.Height        = this.PicHight;
            //chart1.Type = ChartType.ComboSideBySide;
            chart1.Type          = ChartType.Pie;
            chart1.Series.Type   = SeriesType.Cylinder;
            chart1.Series.Name   = this.SeriseName;
            chart1.ShadingEffect = true;
            //chart1.ShadingEffect = false;
            chart1.Use3D = IsUse3D;
            //chart1.DefaultSeries.DefaultElement.Transparency = 60;
            chart1.DefaultSeries.DefaultElement.ShowValue = true;
            //chart1.DefaultSeries.Type = SeriesType.Column;
            chart1.PieLabelMode = PieLabelMode.Outside;
            chart1.SeriesCollection.Add(getArrayData());
            chart1.Series.DefaultElement.ShowValue = true;

            //SeriesCollection mySC = getArrayData();

            // Add the random data.
            //chart1.SeriesCollection.Add(mySC);

            //chart1.LegendBox.Label = new dotnetCHARTING.Label("图表说明", new Font("Microsoft Sans Serif", 20F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134));
            ////chart.LegendBox.HeaderLabel.Font = new Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
            //chart1.LegendBox.Label.Font = new Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
        }
Пример #15
0
 /// <summary>
 /// 柱形图
 /// </summary>
 /// <returns></returns>
 public void CreateCombo1(dotnetCHARTING.Chart chart1)
 {
     chart1.Title = Title;
     chart1.FileManager.FileName = FileName;
     chart1.XAxis.Label.Text     = XName;
     chart1.YAxis.Label.Text     = this.YName;
     chart1.TempDirectory        = this.PhaysicalImagePath;
     chart1.Width       = this.PicWidth;
     chart1.Height      = this.PicHight;
     chart1.Type        = ChartType.Combo;
     chart1.Series.Type = SeriesType.Cylinder;
     chart1.Series.Name = this.SeriseName;
     //chart1.Series.Data = this.DataSoure;
     chart1.SeriesCollection.Add(getArrayData());
     chart1.DefaultSeries.DefaultElement.ShowValue = true;
     chart1.DefaultSeries.Type = SeriesType.Cylinder;
     chart1.ShadingEffect      = true;
     chart1.Use3D = IsUse3D;
     chart1.Series.DefaultElement.ShowValue = true;
 }
Пример #16
0
        public void Create(dotnetCHARTING.Chart chart, string title, 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;
            dotnetCHARTING.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);
        }
Пример #17
0
        public void Create(dotnetCHARTING.Chart chart, string title, List <DataTable> tables, List <DateTime> dates, string xColumn, string yColumn, string style, bool user3D, string targetUrl)
        {
            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;
            chart.Type  = ChartType.Combo;
            chart.Title = title;
            chart.DefaultSeries.Type = SeriesTypeMultiple.Pyramid;
            dotnetCHARTING.SeriesCollection SC = new dotnetCHARTING.SeriesCollection();

            for (int i = 0; i < dates.Count; i++)
            {
                string dtStr            = dates[i].ToString("yyyy-MM-dd");
                dotnetCHARTING.Series s = new dotnetCHARTING.Series(dtStr);
                foreach (DataRow r in tables[i].Rows)
                {
                    Element e = new Element(r[xColumn].ToString());
                    e.URLTarget             = "_self";
                    e.LegendEntry.URL       = string.Concat(targetUrl, dtStr);
                    e.LegendEntry.URLTarget = "_self";
                    e.URL    = string.Concat(targetUrl, dtStr);
                    e.YValue = Convert.ToDouble(r[yColumn]);
                    s.Elements.Add(e);
                    SC.Add(s);
                }
            }
            chart.DefaultElement.ShowValue = true;
            if (string.IsNullOrEmpty(style) || style == "线形")
            {
                chart.DefaultSeries.Type = SeriesType.Line;
            }
            chart.PieLabelMode      = PieLabelMode.Outside;
            chart.ShadingEffectMode = ShadingEffectMode.Three;
            chart.NoDataLabel.Text  = "没有数据显示";
            chart.SeriesCollection.Add(SC);
        }
Пример #18
0
        /// <summary>
        /// 曲线图
        /// </summary>
        /// <returns></returns>
        public void CreateLine(dotnetCHARTING.Chart chart1)
        {
            chart1.Title = Title;
            chart1.FileManager.FileName = FileName;
            chart1.XAxis.Label.Text     = XName;
            chart1.XAxis.Label.Color    = Color.Red;
            //chart1.XAxis.Label.Font = System.Drawing.Font.FromHdc(11);

            chart1.YAxis.Label.Text  = this.YName;
            chart1.YAxis.Label.Color = Color.Black;
            chart1.TempDirectory     = this.PhaysicalImagePath;
            chart1.Width             = this.PicWidth;
            chart1.Height            = this.PicHight;
            chart1.Type = ChartType.Combo;
            //此处一定要用DefaultSeries.Type = SeriesType.Line 否则没效果
            chart1.DefaultSeries.Type = SeriesType.Line;
            chart1.Series.Name        = this.SeriseName;
            chart1.Series.Data        = this.DataSoure;
            chart1.SeriesCollection.Add();
            chart1.DefaultSeries.DefaultElement.ShowValue = true;
            chart1.ShadingEffect = false;
            chart1.Use3D         = IsUse3D;
            chart1.Series.DefaultElement.ShowValue = true;
        }
Пример #19
0
        public void Pie2(dotnetCHARTING.Chart chart, string title, DataTable table,
                         string xColumn, string yColumn, string style,
                         int displayNum, string targetUrl, string format,
                         string legendBoxPos, bool user3d)
        {
            SeriesCollection SC   = new SeriesCollection();
            Series           s    = new Series("");
            DataView         view = new DataView(table);

            view.Sort = yColumn + "  desc";
            int          index    = 0;
            DataTable    table2   = view.ToTable();
            Element      otherE   = new Element("其他");
            bool         other    = false;
            double       otherSum = 0;
            Color        c        = Color.FromArgb(49, 255, 49);
            Random       r        = new Random(255);
            Color        c1       = Color.FromArgb(255, 49, 255);
            List <Color> list     = new List <Color>();

            list.Add(c);
            list.Add(c1);
            for (int i = 0; i < displayNum; i++)
            {
                Color cc = Color.FromArgb((c.A + r.Next(50000)) % 255, (c.B + r.Next(456)) % 255, (c.G + r.Next(1207)) % 100);
                list.Add(cc);
            }
            if (legendBoxPos.ToLower() == "title")
            {
                chart.TitleBox.Position = TitleBoxPosition.FullWithLegend;
            }
            foreach (DataRow row in table2.Rows)
            {
                if (index > displayNum)
                {
                    otherSum            += Convert.ToDouble(row[yColumn].ToString());
                    otherE.LabelTemplate = "%Name: %PercentOfTotal";
                    other = true;
                    continue;
                }
                string telType = row[xColumn].ToString();
                telType = SetXColumn(telType);
                Element e = new Element(telType);
                e.ToolTip                = telType;
                e.LabelTemplate          = "%PercentOfTotal";
                e.LegendEntry.HeaderMode = LegendEntryHeaderMode.RepeatOnEachColumn;
                e.LegendEntry.SortOrder  = 0;
                if (!string.IsNullOrEmpty(targetUrl))
                {
                    e.LegendEntry.URL       = targetUrl + telType;
                    e.LegendEntry.URLTarget = "_self";
                    e.URL       = targetUrl + telType;
                    e.URLTarget = "_self";
                }
                e.YValue = Convert.ToDouble(row[yColumn].ToString());
                s.Elements.Add(e);
                index++;
            }
            if (other)
            {
                s.Elements.Add(otherE);
            }
            otherE.YValue          = otherSum;
            otherE.SmartLabel.Text = "其他";
            SC.Add(s);
            chart.TempDirectory                      = "temp";
            chart.Use3D                              = user3d;
            chart.DefaultAxis.FormatString           = "N";
            chart.DefaultAxis.CultureName            = "zh-CN";
            chart.Palette                            = list.ToArray();
            chart.DefaultElement.SmartLabel.AutoWrap = true;
            if (style == "饼形")
            {
                chart.Type = ChartType.Pies;
            }
            else if (style == "柱形")
            {
                chart.Type = ChartType.Combo;
            }
            else if (style == "横柱形")
            {
                chart.Type = ChartType.ComboHorizontal;
            }
            else if (style == "图片柱形")
            {
                chart.Type = ChartType.Combo;
                chart.DefaultSeries.ImageBarTemplate = "ethernetcable";
            }
            else if (style == "雷达")
            {
                chart.Type = ChartType.Radar;
            }
            else if (style == "圆锥")
            {
                chart.Type = ChartType.MultipleGrouped;
                chart.DefaultSeries.Type = SeriesTypeMultiple.Cone;
            }
            chart.Title                             = title;
            chart.PieLabelMode                      = PieLabelMode.Automatic;
            chart.DefaultElement.ShowValue          = true;
            chart.ShadingEffectMode                 = ShadingEffectMode.Three;
            chart.LegendBox.DefaultEntry.PaddingTop = 5;
            switch (format)
            {
            case "Jpg":
            {
                chart.ImageFormat = ImageFormat.Jpg;
                break;
            }

            case "Png":
            {
                chart.ImageFormat = ImageFormat.Png;
                break;
            }

            case "Swf":
            {
                chart.ImageFormat = ImageFormat.Swf;
                break;
            }
            }
            chart.DefaultElement.SmartLabel.AutoWrap = true;
            chart.NoDataLabel.Text = "没有数据显示";
            chart.SeriesCollection.Add(SC);
        }
Пример #20
0
 public void Pie2(dotnetCHARTING.Chart chart, string title, DataTable table, string xColumn, string yColumn, string style, int displayNum, string targetUrl)
 {
     Pie2(chart, title, table, xColumn, yColumn, style, displayNum, targetUrl, "Jpg", "", false);
 }
Пример #21
0
        public void Pie2(dotnetCHARTING.Chart chart, string title, DataTable table, string xColumn, string yColumn, string style, int displayNum)
        {
            SeriesCollection SC   = new SeriesCollection();
            Series           s    = new Series("");
            DataView         view = new DataView(table);

            view.Sort = yColumn + "  desc";
            int          index    = 0;
            DataTable    table2   = view.ToTable();
            Element      otherE   = new Element("其他");
            bool         other    = false;
            double       otherSum = 0;
            Color        c        = Color.FromArgb(49, 255, 49);
            Random       r        = new Random(255);
            Color        c1       = Color.FromArgb(255, 49, 255);
            List <Color> list     = new List <Color>();

            list.Add(c);
            list.Add(c1);
            for (int i = 0; i < displayNum; i++)
            {
                Color cc = Color.FromArgb((c.A + r.Next(10000)) % 255, (c.B + r.Next(456)) % 255, (c.G + r.Next(1027)) % 100);
                list.Add(cc);
            }
            foreach (DataRow row in table2.Rows)
            {
                if (index > displayNum - 2)
                {
                    otherSum            += Convert.ToDouble(row[yColumn].ToString());
                    otherE.LabelTemplate = "%PercentOfTotal";
                    other = true;
                    continue;
                }
                string telType = row[xColumn].ToString();
                telType = SetXColumn(telType);
                Element e = new Element(telType);
                e.LabelTemplate   = "%PercentOfTotal";
                e.SmartLabel.Text = telType;


                e.YValue = Convert.ToDouble(row[yColumn].ToString());
                s.Elements.Add(e);
                index++;
            }
            if (other)
            {
                s.Elements.Add(otherE);
            }
            otherE.YValue          = otherSum;
            otherE.SmartLabel.Text = "其他";
            SC.Add(s);
            chart.TempDirectory                      = "temp";
            chart.Use3D                              = false;
            chart.DefaultAxis.FormatString           = "N";
            chart.DefaultAxis.CultureName            = "zh-CN";
            chart.Palette                            = list.ToArray();
            chart.DefaultElement.SmartLabel.AutoWrap = true;
            if (style == "饼形")
            {
                chart.Type = ChartType.Pies;
            }
            else if (style == "柱形")
            {
                chart.Type = ChartType.Combo;
            }
            else if (style == "横柱形")
            {
                chart.Type = ChartType.ComboHorizontal;
            }
            else if (style == "图片柱形")
            {
                chart.Type = ChartType.Combo;
                chart.DefaultSeries.ImageBarTemplate = "ethernetcable";
            }
            else if (style == "雷达")
            {
                chart.Type = ChartType.Radar;
            }
            else if (style == "圆锥")
            {
                chart.Type = ChartType.MultipleGrouped;
                chart.DefaultSeries.Type = SeriesTypeMultiple.Cone;
            }
            chart.DefaultElement.SmartLabel.Text = "";
            chart.Title = title;
            chart.DefaultElement.ShowValue           = true;
            chart.PieLabelMode                       = PieLabelMode.Outside;
            chart.ShadingEffectMode                  = ShadingEffectMode.Three;
            chart.DefaultElement.SmartLabel.AutoWrap = true;
            chart.NoDataLabel.Text                   = "没有数据显示";
            chart.SeriesCollection.Add(SC);
        }
Пример #22
0
 /// <summary>
 /// 柱状图
 /// </summary>
 /// <param name="chart">dotNetChart</param>
 public void CreateBar(dotnetCHARTING.Chart chart)
 {
     setChart(chart);
     setChartType(chart, dotnetCHARTING.ChartType.Combo, dotnetCHARTING.SeriesType.Cylinder);
 }
Пример #23
0
 /// <summary>
 /// 饼状图
 /// </summary>
 /// <param name="chart">dotNetChart</param>
 public void CreatePie(dotnetCHARTING.Chart chart)
 {
     setChart(chart);
     setChartType(chart, dotnetCHARTING.ChartType.Pie, dotnetCHARTING.SeriesType.Cylinder);
 }
Пример #24
0
 /// <summary>
 /// 线形图
 /// </summary>
 /// <param name="chart">dotNetChart</param>
 public void CreateLines(dotnetCHARTING.Chart chart)
 {
     setChart(chart);
     setChartType(chart, dotnetCHARTING.ChartType.Combo, dotnetCHARTING.SeriesType.Line);
 }