Example #1
1
 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);
 }
Example #2
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;
 }
Example #3
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);
 }
Example #4
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);
 }
Example #5
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);
        }
Example #6
0
        public void Pie(dotnetCHARTING.Chart chart, int width, int height, string title,DataTable table, string xColumn, string yColumn)
        {
            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;
            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);
        }
Example #7
0
    private void formatoGrafico(dotnetCHARTING.Chart chGrafico, string tipo)
    {
        switch (tipo)
        {
          case "PIE":

        chGrafico.Type = ChartType.Pies;

        chGrafico.LegendBox.Visible = false;
        chGrafico.LegendBox.Template = "%Icon - %Value - %Name";
        chGrafico.LegendBox.Position = LegendBoxPosition.Bottom;

        chGrafico.DefaultElement.ShowValue = true;
        chGrafico.DefaultElement.LabelTemplate = "%Name";// [%Value]";
        chGrafico.YAxis.Percent = true;
        chGrafico.PieLabelMode = PieLabelMode.Outside;
        chGrafico.TempDirectory = "GRAPHICSTEMP";
        break;

          case "BARRAS":
        chGrafico.Type = ChartType.Combo;
        chGrafico.LegendBox.Visible = false;
        chGrafico.DefaultElement.ShowValue = true;
        chGrafico.DefaultElement.LabelTemplate = "%Name";
        chGrafico.TempDirectory = "GRAPHICSTEMP";

        break;

          case "TABLA":
        chGrafico.Type = ChartType.Combo;
        chGrafico.ChartArea.Visible = false;
        chGrafico.LegendBox.Visible = true;
        chGrafico.LegendBox.Template = "%Name%Value";
        chGrafico.DefaultElement.ShowValue = false;
        chGrafico.TempDirectory = "GRAPHICSTEMP";
        break;

        }
    }