Beispiel #1
0
        public static IHtmlString BarChart(this HtmlHelper html, ChartData chartData, int width, int height, double axisYMax, double axisYMin, double? axisYInterval,
                        string axisYLabelFormat, bool displayLegend,
                        string axisXTitle, string axisYTitle,
                        SeriesChartType chartType,
                        bool eachSeriesInNewChartArea, List<CustomLabels.CustomLabel> axisYCustomLabels = null)
        {
            //get chart
            if (chartData != null)
            {
                BarChart barChart = new BarChart(chartData, width, height, axisYMax, axisYMin, axisYInterval,
                                                 axisYLabelFormat, displayLegend, chartType,
                                                 eachSeriesInNewChartArea, axisYCustomLabels);

                barChart.AxisXTitle = axisXTitle;
                barChart.AxisYTitle = axisYTitle;
                
                Chart chart = barChart.Chart;

                //render
                StringBuilder control = new StringBuilder();
                HtmlTextWriter writer = new HtmlTextWriter(new System.IO.StringWriter(control));
                chart.RenderControl(writer);

                string screenReaderTable = ScreenReaderTable(chartData);

                return new MvcHtmlString("<div aria-hidden=\"true\">" + control.ToString() + "</div>" + screenReaderTable);
            }

            return new MvcHtmlString(string.Empty);
        }
        /// <summary>
        ///		Create a pseudo-random <see cref="Series">data series</see>.
        /// </summary>
        /// <param name="seriesName">
        ///		The name of the data series to produce.
        /// </param>
        /// <param name="type">
        ///		The type of chart used to represent the data series.
        /// </param>
        /// <param name="numberOfPoints">
        ///		The number of points that the data series should contain.
        /// </param>
        /// <returns>
        ///		The configured <see cref="Series"/>.
        /// </returns>
        public static Series RandomSeries(string seriesName, SeriesChartType type = SeriesChartType.Line, int numberOfPoints = 100)
        {
            if (String.IsNullOrWhiteSpace(seriesName))
                throw new ArgumentException("Argument cannot be null, empty, or entirely componsed of whitespace: 'seriesName'.", nameof(seriesName));

            if (numberOfPoints < 0)
                throw new ArgumentOutOfRangeException(nameof(numberOfPoints), numberOfPoints, "Number of data points cannot be less than 0.");

            Series series = new Series(seriesName)
            {
                ChartType = type,
                BorderWidth = 3
            };

            Random random = new Random();
            for (int dataPointX = 0; dataPointX < numberOfPoints; dataPointX++)
            {
                // Pseudo-random data point.
                double fudgeFactor = random.NextDouble();
                double dataPointY = 2.0 * Math.Sin(fudgeFactor) + Math.Sin(fudgeFactor / 4.5);
                series.Points.Add(
                    new DataPoint(dataPointX, dataPointY)
                );
            }

            return series;
        }
 /// <summary>
 ///     Overrides the properties for surfaces graphs
 /// </summary>
 /// <param name="chartType"></param>
 /// <param name="name"></param>
 /// <param name="tooltip"></param>
 /// <param name="color"></param>
 protected override void InitializeProperties(SeriesChartType chartType, string name, string tooltip,
     Color color = default(Color))
 {
     base.InitializeProperties(chartType, name, tooltip, color);
     Data.BorderDashStyle = ChartDashStyle.Dash;
     Data.BorderWidth = 2;
 }
Beispiel #4
0
        public Series CreateSeries(IList<Tuple<double, string>> results,
               SeriesChartType chartType,
               Color color)
        {
            var seriesDetail = new Series();
            seriesDetail.Name = "Sales sum";
            seriesDetail.IsValueShownAsLabel = true;
            seriesDetail.Color = color;
            seriesDetail.ChartType = chartType;
            seriesDetail.BorderWidth = 2;
            seriesDetail["DrawingStyle"] = "Cylinder";
            seriesDetail["PieDrawingStyle"] = "SoftEdge";
            DataPoint point;

            foreach (var result in results)
            {
                point = new DataPoint();
                point.AxisLabel = result.Item2;
                point.YValues = new double[] { result.Item1 };
                seriesDetail.Points.Add(point);
            }
            seriesDetail.ChartArea = "Sales Chart";

            return seriesDetail;
        }
        public ChartPanel(MetingType type, SeriesChartType charttype)
            : base()
        {
            this.type = type;
            this.ChartType = charttype;

            this.chart = new Chart();
            this.chartArea = new ChartArea();
            this.chart.Titles.Add(new Title(type.ToString()));

            this.Location = new System.Drawing.Point(0, 0);

            this.Size = new System.Drawing.Size(400, 250);
            this.Controls.Add(chart);

            this.series = createSerie();
            this.chartArea.Name = "chartArea";

            this.chart.Size = new System.Drawing.Size(400, 250);

            this.chart.Dock = DockStyle.Fill;
            this.chart.Series.Add(series);
            this.chart.Text = "chart";

            this.chart.ChartAreas.Add(chartArea);
        }
        public static void changeChartType(this Chart chart,SeriesChartType ChartType)
        {
            DataPoint[] points = new DataPoint[chart.Series.Count];
            if (ChartType == SeriesChartType.Pie)
            {
                int i = 0;
                foreach (var serie in chart.Series)
                {
                    points[i] = serie.Points.FirstOrDefault();
                    i++;
                }

                chart.Series.Clear();
                var newSerie = chart.Series.Add("Total");

                newSerie.ChartType = ChartType;

                foreach (var point in points)
                {
                    newSerie.Points.Add(point);
                }
                return;
            }

            foreach (var serie in chart.Series)
            {
                serie.ChartType = ChartType;

            }
        }
Beispiel #7
0
 /// <summary>
 /// Same as appendDynamicChart(), but call drawChart2() instead of drawChart().
 /// </summary>
 /// <param name="panel"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 /// <param name="dt"></param>
 /// <param name="ChartName"></param>
 /// <param name="seriesName"></param>
 /// <param name="TitleX"></param>
 /// <param name="TitleY"></param>
 /// <param name="ChartType"></param>
 public void appendDynamicChart2(Panel panel, int width, int height,
     DataTable dt, string ChartName, string[] seriesName, string TitleX, string TitleY, SeriesChartType ChartType = SeriesChartType.Line)
 {
     Chart c = new Chart();
     c.Width = width;
     c.Height = height;
     this.drawChart2(c, dt, TitleX, TitleY, ChartType);
     panel.Controls.Add(c);
 }
Beispiel #8
0
 public void ShowChart(DataSet ds, string member, string valueX, string valueY, SeriesChartType type)
 {
     Binding_ChartDefect.DataSource = ds;
     Binding_ChartDefect.DataMember = member;
     Chart_All.DataBindCrossTable(Binding_ChartDefect, valueX, valueX, valueY, "");
     foreach (Series series in Chart_All.Series) {
         series.ChartType = type;
     }
 }
        public static void ChartSetup(Chart chart, String seriesName, int borderWidth, Color color, SeriesChartType chartType, ChartValueType xValueType) {
            Series newSeries = new Series(seriesName);
            newSeries.ChartType = chartType;
            newSeries.BorderWidth = borderWidth;
            newSeries.Color = color;
            newSeries.XValueType = xValueType;
            chart.Series.Add(newSeries);

        }
 public static Series RandomSeries(string seriesName, SeriesChartType type = SeriesChartType.Line, int points = 100)
 {
     var series = new Series(seriesName) {ChartType = type};
     foreach (var i in Enumerable.Range(0, points))
     {
         var rng = ThreadLocalRandom.Current.NextDouble();
         series.Points.Add(new DataPoint(i, 2.0*Math.Sin(rng) + Math.Sin(rng/4.5)));
     }
     series.BorderWidth = 3;
     return series;
 }
Beispiel #11
0
 public static void CreateSeries(this Chart chart, string name, Dictionary<int, double> data, SeriesChartType chartType = SeriesChartType.Line, bool markers = false, bool interactive = false)
 {
     chart.Series.Add(name);
     chart.Series[name].ChartType = chartType;
     foreach (var item in data)
         chart.Series[name].Points.AddXY(item.Key, item.Value);
     chart.Series[name].MarkerSize = 10;
     chart.Series[name].MarkerStyle = markers ? MarkerStyle.Circle : MarkerStyle.None;
     if(interactive)
         chart.Series[name].MapAreaAttributes ="id=\"#SER-#INDEX\" class=\"InteractiveArea\"";
 }
Beispiel #12
0
 public static void AddSeries(string seriesName, SeriesChartType chartType, ref Chart _chart)
 {
     if (_chart.Series.Any(i => i.Name == seriesName))
     {
         _chart.Series.Remove(_chart.Series.Where(i => i.Name == seriesName).FirstOrDefault());
     }
     var series = new Series()
     {
         Name = seriesName,
         ChartType = chartType  
     };
     _chart.Series.Add(series);
 }
Beispiel #13
0
        public void NewSerie(String id, int[] y_data, Color colorSerie, SeriesChartType chartType)
        {
            this.chart.Series.Add(id);
            this.chart.Series[id].ChartType = chartType; ;
            this.chart.Series[id].ChartArea = "ChartArea1";
            this.chart.Series[id].Color = colorSerie;

            int yy;
            for (int idx = 0; idx < y_data.Length; idx++)
            {
                yy = y_data[idx];
                this.chart.Series[id].Points.AddXY(idx + 1, yy);
            }

            this.chart.Legends[0].Enabled = false;

        }
Beispiel #14
0
 public static IHtmlString BarChart(this HtmlHelper html, ChartData chartData, int width, int height, double axisYMax, double axisYMin, double? axisYInterval,
                 string axisYLabelFormat, bool displayLegend, SeriesChartType chartType, 
                 bool eachSeriesInNewChartArea, List<CustomLabels.CustomLabel> axisYCustomLabels = null)
 {
     return BarChart(html,
                     chartData,
                     width,
                     height,
                     axisYMax,
                     axisYMin,
                     axisYInterval,
                     axisYLabelFormat,
                     displayLegend,
                     null,
                     null,
                     chartType,
                     eachSeriesInNewChartArea,
                     axisYCustomLabels);
 }
Beispiel #15
0
 public static void AddSeriesAndPoints(string seriesName, SeriesChartType chartType, string legendText, System.Drawing.Color color, 
     Dictionary<string, decimal> dataValues, string pointLabelFormat, ref Chart _chart, bool showLabels = true)
 {
     if (dataValues != null && dataValues.Count > 0)
     {
         if (_chart.Series.Any(i=>i.Name == seriesName))
         {
             _chart.Series.Remove(_chart.Series.Where(i=>i.Name == seriesName).FirstOrDefault());
         }
         var series = new Series()
         {
             Name = seriesName,
             ChartType = chartType,
             Color = color,
             LegendText = string.IsNullOrEmpty(legendText) ? string.Empty : legendText,
             BorderColor = System.Drawing.Color.White,
             IsValueShownAsLabel = showLabels
         };
         if (string.IsNullOrEmpty(legendText))
         {
             series.IsValueShownAsLabel = false;
         }
         foreach (KeyValuePair<string, decimal> data in dataValues)
         {
             series.Points.AddXY(data.Key, data.Value);
             var _point = series.Points.Last();
             //if (_point.YValues[0] > 0)
             //{
             _point.Label = showLabels 
                 ? string.Format(CultureInfo.CreateSpecificCulture("ru-Ru"), pointLabelFormat, _point.YValues[0])
                 : string.Empty;
                 _point.Font = new System.Drawing.Font("Arial", 10);
                 _point.AxisLabel = _point.AxisLabel.Length > 20 
                     ? string.Format("{0}...", _point.AxisLabel.Substring(0, 20))
                     : _point.AxisLabel;
                 _point.IsValueShownAsLabel = showLabels;
             //}
         }
         _chart.Series.Add(series);
     }
 }
Beispiel #16
0
        /// <summary>
        /// Creates the actual chart and passes back the memory stream containing the chart.
        /// </summary>
        /// <param name="xAxis"></param>
        /// <param name="yAxis"></param>
        /// <param name="title"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public byte[] CreateChart(string[] xAxis, decimal[] yAxis, string title, SeriesChartType type)
        {
            // get a prepped chart
            var chart = PrepChart(title);

            // add in the data
            var series = chart.Series.Add("Series1");
            series.ChartType = type;
            series.YValueType = ChartValueType.Int32;
            series.XValueType = ChartValueType.String;
            series.BorderColor = Color.Azure;
            series.ShadowOffset = 2;
            series.Points.DataBindXY(xAxis, yAxis);

            chart.Series["Series1"]["PieLabelStyle"] = "Outside";

            // Save Chart to MemoryStream
            MemoryStream ms = new MemoryStream();
            chart.SaveImage(ms, ChartImageFormat.Png);

            return ms.GetBuffer();
        }
Beispiel #17
0
        public ChartPanel(MetingType type, SeriesChartType charttype,bool showTitle)
            : base()
        {
            this.type = type;
            this.ChartType = charttype;

            this.chart = new Chart();
            this.chartArea = new ChartArea();
            if(showTitle)
                this.chart.Titles.Add(new Title(type.ToString()));

            this.Location = new System.Drawing.Point(0, 0);
            this.Dock = DockStyle.Top;
            this.Size = new System.Drawing.Size(300, 200);
            this.Controls.Add(chart);

            this.series = createSerie();
            this.chartArea.Name = "chartArea";

            this.chart.Size = new System.Drawing.Size(300, 200);

            this.chart.BackColor = System.Drawing.Color.WhiteSmoke;
            this.chart.Dock = DockStyle.Top;
            this.chart.Series.Add(series);
            this.chart.Text = "chart";

            this.chart.ChartAreas.Add(chartArea);
            List<Meting> test = new List<Meting>();
            test.Add(new Meting(104, 0, 0, 0, 0, 0, 0, 0, 0));
            test.Add(new Meting(110, 0, 0, 0, 0, 0, 0, 0, 0));
            test.Add(new Meting(130, 0, 0, 0, 0, 0, 0, 0, 0));
            test.Add(new Meting(150, 0, 0, 0, 0, 0, 0, 0, 0));
            test.Add(new Meting(180, 0, 0, 0, 0, 0, 0, 0, 0));
            test.Add(new Meting(200, 0, 0, 0, 0, 0, 0, 0, 0));
            updateChart(test);
        }
Beispiel #18
0
 /// <summary>
 /// Метод задания параметров линии
 /// </summary>
 /// <param name="ChartArea">Название чарта к которому привязана линия</param>
 /// <param name="XValueType">????</param>
 /// <param name="Line">тип линии</param>
 /// <param name="BorderWidth">толщина линии</param>
 public Series extSeries(string ChartArea, ChartValueType XValueType, SeriesChartType Line, int BorderWidth)
 {
     Series series = new Series();
     series.ChartArea = ChartArea;
     series.XValueType = XValueType;
     series.ChartType = Line;
     series.BorderWidth = BorderWidth;
     return series;
 }
Beispiel #19
0
        public static string GroupDiagramSave(ExcelDocument document, string dirPath, SeriesChartType type)
        {
            dirPath += "\\" + document.DocumentName;
            foreach (var profileItem in document.ProfilesListContent)
            {
                string dirName = dirPath + "\\" + profileItem.Name;
                Directory.CreateDirectory(dirName);
                int chartNum = 1;
                foreach (var questionItem in profileItem.Questions)
                {
                    var questionInfo = GetQuestionInfo(questionItem, profileItem, document);

                    Chart currentChart = new Chart();
                    currentChart.Width  = 1920;
                    currentChart.Height = 1080;

                    ChartArea chartArea = new ChartArea();
                    chartArea.Name = "ChartArea1";
                    currentChart.ChartAreas.Add(chartArea);

                    currentChart = CreateDefaultChart(currentChart, questionInfo, questionItem, type);
                    currentChart = SettingDefaultChart(currentChart, currentChart.Series.ToList());

                    currentChart.SaveImage(dirName + "\\Chart" + chartNum + ".png", ChartImageFormat.Png);
                    chartNum++;
                }
            }

            return(dirPath);
        }
    private Series addSeries(IEnumerable<DateTime> dates, IEnumerable<decimal>[] valueLists,
                             string seriesName, SeriesChartType chartType, Color color, MarkerStyle markerStyle)
    {
        Series series = new Series(seriesName);
        chPortfolioFutureValue.Series.Add(series);

        series.LegendText = seriesName;
        series.XValueType = ChartValueTypes.DateTime;
        series.EmptyPointStyle.Color = Color.Transparent;
        series.BorderWidth = 2;
        series.Color = color;
        series.MarkerStyle = markerStyle;

        if (dates.Count() == 1 && chartType != SeriesChartType.SplineRange)
        {
            series.Type = SeriesChartType.Point;
            series.MarkerSize = 8;
        }
        else
            series.Type = chartType;

        series.Points.DataBindXY(dates, valueLists);

        return series;
    }
 private Series addSeries(IEnumerable<DateTime> dates, IEnumerable<decimal> valueList,
                          string seriesName, SeriesChartType chartType, Color color, MarkerStyle markerStyle)
 {
     return addSeries(dates, new IEnumerable<decimal>[] { valueList }, seriesName, chartType, color, markerStyle);
 }
Beispiel #22
0
        public static Chart CreateDefaultChart(Chart currentChart, Tuple <Dictionary <string, int>, int, int> questionInfo, ExcelQuestion excelQuestion, SeriesChartType seriesType, bool add = false)
        {
            string question = excelQuestion.GetForSeries();
            Dictionary <string, int> points = questionInfo.Item1;
            int respondedCount = questionInfo.Item2;

            currentChart.Series.Add(question);
            currentChart.Series[question].ChartType = seriesType;
            currentChart.Series[question].Color     = Form1.CompanyColor.Values.ToList()[0];

            if (!add)
            {
                currentChart.Titles.Add(CommonService.CreateTitle("mainTitle", question));
                currentChart.Titles.Add(CommonService.CreateTitle("allTitle", "Всего " + respondedCount + " ответивших участников"));
            }

            foreach (var item in points)
            {
                currentChart.Series[question].Points.AddXY(item.Key, item.Value);
            }

            if (currentChart.Series[question].ChartType == SeriesChartType.Pie || currentChart.Series[question].ChartType == SeriesChartType.Doughnut)
            {
                int colorIndex = 0;
                foreach (var item in currentChart.Series[question].Points)
                {
                    if (item.YValues[0] == 0)
                    {
                        item.LabelForeColor = Color.Transparent;
                    }
                    item.Color = Form1.CompanyColor.Values.ToList()[colorIndex];
                    colorIndex++;
                }

                currentChart.Series[question].LabelForeColor = Color.White;
            }
            else
            {
                currentChart.Series[question].LabelForeColor = Color.Black;
            }

            if (!add)
            {
                Legend legend = CommonService.CreateLegend(currentChart.Series[question], "mainLegend");
                currentChart.Legends.Add(legend);
            }

            return(currentChart);
        }
Beispiel #23
0
        /**
           * <summary>
           * Method that creates a graph with the specified data from the dataSelection parameter, as the type specified
           * by the chartType parameter, with the specified number of projects from the count paramater and in the direction
           * specified by the direction parameter.
           * </summary>
           */
        private void CreateGraph(string dataSelection, SeriesChartType chartType, int count, string direction)
        {
            dataContext = new DatabaseClassesDataContext();

             //Gets the HourPrice configured in the Web.Config's AppSettings section
             hourPrice = Convert.ToDouble(ConfigurationManager.AppSettings["HourPrice"]);

             //Query that gets the Project name, customer name and the latest balance for each SLA project
             var balanceAmountQuery = (from project in dataContext.Projects
                                   join slaProjects in dataContext.SLAProjects on project.ProjectNo equals slaProjects.ProjectNo
                                   join customer in dataContext.Customers on project.CustomerNo equals customer.CustomerNo
                                   join balance in
                                      (
                                         from b in dataContext.Balances
                                         orderby b.LastUpdate descending, b.Year descending, b.Period descending
                                         select new { ProjectNo = b.ProjectNo, BalanceAmount = b.Amount }
                                      ) on project.ProjectNo equals balance.ProjectNo into balanceGroup
                                   from balance in balanceGroup.DefaultIfEmpty().Take(1)
                                   select new
                                   {
                                      ProjectName = project.Name,
                                      CustomerName = customer.Name,
                                      BalanceAmount = balance.BalanceAmount != null ? balance.BalanceAmount : 0.0
                                   }).Distinct();

             //Query that gets the project name, customer name and the product of the sum of the hours spent
             //multiplied with the hour price
             var hoursSpentQuery = (from project in dataContext.Projects
                                join slaProjects in dataContext.SLAProjects on project.ProjectNo equals slaProjects.ProjectNo
                                join customer in dataContext.Customers on project.CustomerNo equals customer.CustomerNo
                                join tripletexImport in
                                   (
                                      from ti in dataContext.TripletexImports
                                      group ti by ti.ProjectNo into g
                                      select new { ProjectNo = g.Key, HoursSpent = g.Sum(p => p.Hours) }
                                      ) on project.ProjectNo equals tripletexImport.ProjectNo into tripletexImportGroup
                                from hoursSpent in tripletexImportGroup.DefaultIfEmpty()
                                select new
                                {
                                   ProjectName = project.Name,
                                   CustomerName = customer.Name,
                                   HoursSpent = hoursSpent.HoursSpent != null ? hoursSpent.HoursSpent * hourPrice : 0.0,
                                }).Distinct();

             //Query that gets the project name, customer name and the sum of the total sales amount for a SLA project.
             var totalSalesAmountQuery = (from project in dataContext.Projects
                                      join slaProjects in dataContext.SLAProjects on project.ProjectNo equals slaProjects.ProjectNo
                                      join customer in dataContext.Customers on project.CustomerNo equals customer.CustomerNo
                                      join salesFigures in
                                         (
                                            from sf in dataContext.SalesFigures
                                            group sf by sf.ProjectNo into g
                                            select new { ProjectNo = g.Key, TotalSalesAmount = g.Sum(p => p.TotalSalesAmount) }
                                         ) on project.ProjectNo equals salesFigures.ProjectNo into salesFiguresGroup
                                      from salesFigures in salesFiguresGroup.DefaultIfEmpty()
                                      select new
                                      {
                                         ProjectName = project.Name,
                                         CustomerName = customer.Name,
                                         TotalSalesAmount = salesFigures.TotalSalesAmount != null ? salesFigures.TotalSalesAmount : 0.0
                                      }).Distinct();

             if(dataSelection.Equals(BALANCE_AMOUNT)) {
            if (direction.Equals(DESC))
            {
               //Takes the <count> projects from the result in descending order, ordered by BalanceAmount
               Graph.DataSource = balanceAmountQuery.OrderByDescending(p => p.BalanceAmount).Take(count);
            }
            else
            {
               //Takes the <count> projects from the result in ascending order, ordered by BalanceAmount
               Graph.DataSource = balanceAmountQuery.OrderBy(p => p.BalanceAmount).Take(count);
            }
             }
             else if (dataSelection.Equals(HOURS_SPENT))
             {
            if (direction.Equals(DESC))
            {
               //Takes the <count> projects from the result in descending order, ordered by Hours spent
               Graph.DataSource = hoursSpentQuery.OrderByDescending(p => p.HoursSpent).Take(count);
            }
            else
            {
               //Takes the <count> projects from the result in ascending order, ordered by Hours spent
               Graph.DataSource = hoursSpentQuery.OrderBy(p => p.HoursSpent).Take(count);
            }
             }
             else if (dataSelection.Equals(TOTAL_SALES_AMOUNT))
             {
            if (direction.Equals(DESC))
            {
               //Takes the <count> projects from the result in descending order, ordered by Total Sales Amount
               Graph.DataSource = totalSalesAmountQuery.OrderByDescending(p => p.TotalSalesAmount).Take(count);
            }
            else
            {
               //Takes the <count> projects from the result in ascending order, ordered by Total Sales Amount
               Graph.DataSource = totalSalesAmountQuery.OrderBy(p => p.TotalSalesAmount).Take(count);
            }
             }

             //Creates the graph
             Series series = new Series("Series1");
             series.ChartArea = "ChartArea1";
             series.ChartType = chartType;
             series.XValueMember = "ProjectName";
             series.YValueMembers = dataSelection;
             series["PointWidth"] = "0.5";
             Graph.Series.Add(series);

             //Binds the data to the Graph
             Graph.DataBind();
        }
Beispiel #24
0
 public static Series WithType(this Series s, SeriesChartType type)
 {
     s.ChartType = type;
     return(s);
 }
Beispiel #25
0
 public static Series AddSeries(this Chart chart, string seriesname, string chartarea, SeriesChartType seriestype)
 {
     Series series = new Series(seriesname);
     series.ChartArea = chartarea;
     series.ChartType = seriestype;
     series.Name = seriesname;
     if (chart.Palette == ChartColorPalette.None)
     {
         series.Color = chart.PaletteCustomColors[chart.Series.Count % chart.PaletteCustomColors.Length];
     }
     else
     {
         series.Color = ChartColorPalette.Pastel.GetColorPaletteColor(chart.Series.Count);
     }
     if (seriestype == SeriesChartType.Stock || seriestype == SeriesChartType.Candlestick)
     {
         series["PriceUpColor"] = System.Drawing.Color.FromArgb(0, 154, 39).ToArgb().ToString();
         series["PriceDownColor"] = System.Drawing.Color.FromArgb(173, 12, 33).ToArgb().ToString();
         series.YValuesPerPoint = 4;
         series.BorderWidth = 2;
         series.Color = System.Drawing.Color.Black;
     }
     else
     {
         if (seriestype == SeriesChartType.Line)
         {
             series.BorderWidth = 2;
             series.EmptyPointStyle.Color = series.Color;
             series.EmptyPointStyle.BorderWidth = 2;
         }
         else
         {
             if (seriestype == SeriesChartType.Point)
             {
                 series.MarkerStyle = MarkerStyle.Circle;
                 series.MarkerSize = 8;
             }
         }
     }
     chart.Series.Add(series);
     return series;
 }
Beispiel #26
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 public Plot()
 {
     this.IsSeriesPlot = false;
     this.SeriesIndex = -1;
     this.Splitter = " ?, ?";
     this.a = 1;
     this.b = 0;
     this.ChartType = SeriesChartType.FastLine;
     this.MarkerSize = 5;
     this.MarkerStyle = MarkerStyle.Square;
     this.YAxisType = AxisType.Primary;
 }
Beispiel #27
0
        /// <summary>
        /// グラフにデータ系列を新規追加
        /// </summary>
        /// <param name="Name">系列名</param>
        /// <param name="ComNumber">監視対象COM</param>
        /// <param name="a">表示値→物理値の一次変換係数(y=ax+b)</param>
        /// <param name="b">表示値→物理値の一次変換係数(y=ax+b)</param>
        /// <param name="Label">データ抽出に使用する正規表現</param>
        /// <param name="isSecondaryAxis">y軸に第2軸を使用</param>
        /// <param name="Type">グラフの種類</param>
        private void addSeries(string Name, int ComNumber, double a, double b, string Label, bool isSecondaryAxis, SeriesChartType Type)
        {
            foreach (Plot Plot in this.DataSeries.Values)
            {
                if (Plot.Series == Name)
                {
                    MessageBox.Show("既にその系列名は使用されています");
                    return;
                }
            }
            if (ComNumber < 0 || ComNumber > this.P.MAX_PORT_NUMBER)
            {
                MessageBox.Show("ポート番号の指定が無効です");
                return;
            }

            Plot p = new Plot();
            p.a = a;
            p.b = b;
            p.comNumber = ComNumber;
            p.COM = "COM" + ComNumber.ToString();
            p.Series = Name;
            p.Label = Label;
            p.MarkerStyle = this.dafaultMarkerStyle;
            p.MarkerSize = this.defaultMarkerSize;
            if (isSecondaryAxis)
            {
                p.YAxisType = AxisType.Secondary;
            }
            else
            {
                p.YAxisType = AxisType.Primary;
            }
            p.ChartType = Type;

            addSeries(p);
        }
Beispiel #28
0
        protected virtual void ApplyMSChartData(YZRequest request, JObject rv, ReportMSChartView view, DataTable dataTable)
        {
            Chart chart = new Chart();

            YZChartHelper.ApplayChartStyle(chart);

            //设置报表大小
            chart.Width  = new Unit(view.ReportWidth, UnitType.Pixel);
            chart.Height = new Unit(view.ReportHeight, UnitType.Pixel);

            //添加主副标题
            chart.Titles[0].Text      = view.ReportTitle;
            chart.Titles[0].Alignment = ContentAlignment.TopCenter;

            //设置注释
            if (view.Series.Count >= 2)
            {
                chart.Legends.Add(new Legend("Default"));
                chart.Legends[0].Docking     = Docking.Bottom;
                chart.Legends[0].BackColor   = Color.Transparent;
                chart.Legends[0].Alignment   = StringAlignment.Center;
                chart.Legends[0].BorderColor = Color.Black;
            }

            //添加系列
            BPMObjectNameCollection denySeries = JArray.Parse(request.GetString("DenySeries", "[]")).ToObject <BPMObjectNameCollection>();

            foreach (ReportSeries reportSeries in view.Series)
            {
                if (denySeries.Contains(reportSeries.Name))
                {
                    continue;
                }

                Series series = new Series(reportSeries.Name);
                chart.Series.Add(series);

                series.ShadowColor   = Color.Transparent;
                series.BorderColor   = Color.FromArgb(180, 26, 59, 105);
                series.Color         = Color.FromArgb(180, reportSeries.Color);
                series.XValueMember  = view.XAxisColumnName;
                series.YValueMembers = reportSeries.DataColumnName;
                series.Tag           = reportSeries;
            }

            //应用客户设置
            SeriesChartType chartType = request.GetEnum <SeriesChartType>("ChartType", view.ChartType);
            bool            enable3D  = request.GetBool("Enable3D", false);
            int             rotation  = request.GetInt32("Rotation", 0);

            foreach (Series chartSeries in chart.Series)
            {
                chartSeries.ChartType = chartType;
            }

            if (enable3D)
            {
                foreach (ChartArea chartArea in chart.ChartAreas)
                {
                    chartArea.Area3DStyle.Enable3D = true;
                    chartArea.Area3DStyle.Rotation = rotation;
                }
            }

            //执行绑定
            chart.DataSource = dataTable;
            chart.DataBind();

            //应用数据显示
            foreach (Series series in chart.Series)
            {
                foreach (DataPoint point in series.Points)
                {
                    point.Label = point.YValues[0].ToString() + (series.Tag as ReportSeries).Unit;
                }
            }

            //生成报表图片
            string imageId = Guid.NewGuid().ToString();

            using (MemoryStream stream = new MemoryStream())
            {
                chart.SaveImage(stream, ChartImageFormat.Png);
                ChartManager.CurrentStore.Save(imageId, stream.ToArray(), "mschart.png", null);
            }

            rv["chartid"] = imageId;
            rv["width"]   = chart.Width.Value;
            rv["height"]  = chart.Height.Value;
        }
Beispiel #29
0
    /// <summary>
    /// Generates a Weekly summation series for the passed cashflows
    /// </summary>
    /// <param name="dataToReport"></param>
    /// <param name="seriesName"></param>
    /// <param name="chartType"></param>
    /// <returns></returns>
    public static Series getWeeklySummationSeries(List <cashFlow> dataToReport, string seriesName, SeriesChartType chartType, Color displayColor)
    {
        Series outputSeries = new Series(seriesName);

        outputSeries.ChartType = chartType;
        outputSeries.Color     = displayColor;

        if (dataToReport.Count() > 0)
        {
            foreach (DayOfWeek day in Enum.GetValues(typeof(DayOfWeek)).OfType <DayOfWeek>().ToList())
            {
                outputSeries.Points.AddXY(day.ToString(), dataToReport.Where(x => x.flowDate.DayOfWeek == day).Sum(x => x.amount));
            }
        }
        return(outputSeries);
    }
Beispiel #30
0
        public static void CreateSeries(Chart mainChart, ChartArea mainChartArea, SeriesChartType chartType, Color colorChoice, string datatype)
        {
            //Reset
            mainChart.Titles.Clear();
            mainChart.Series.Clear();
            Series data = new Series();
            data.Name = datatype;
            data.LabelForeColor = Color.White;
            data.ChartType = chartType;
            data.Color = colorChoice;
            data.ChartType = chartType;
            //mainChart.Titles.Add(datatype);
            mainChartArea.AxisX.LabelStyle.ForeColor = Color.White;
            mainChartArea.AxisY.LabelStyle.ForeColor = Color.White;
            mainChartArea.AxisX.Title = "Match (Oldest to Latest)";
            mainChartArea.AxisX.TitleFont = new Font("Microsoft Sans Serif", 16, FontStyle.Bold);
            mainChartArea.AxisY.TitleFont = new Font("Microsoft Sans Serif", 16, FontStyle.Bold);
            mainChartArea.AxisY.Title = datatype;
            //mainChartArea.AxisY.LabelStyle.ForeColor = Color.White;
            //mainChart.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.White;
            //mainChart.ChartAreas[0].AxisY.LabelStyle.ForeColor = Color.White;
            mainChart.Series.Add(data);
            mainChart.Series[0].LabelForeColor = Color.White;
            mainChart.Series[0].BorderWidth = 5;
            double max = 10;
            int chartnum = 1;
            switch (datatype)
            {
                case "KDA":
                    max = 0;
                    chartnum = 1;
                    for (int match = RankMatchHistory.Count() - 1; match >= 0; match--)
                    {
                        if (Display_Filter(match) == true)
                        {
                            double kills = Convert.ToDouble(RankMatchHistory[match].kills);
                            double deaths = Convert.ToDouble(RankMatchHistory[match].deaths);
                            double assists = Convert.ToDouble(RankMatchHistory[match].assists);
                            if (deaths == 0) { deaths = 1; }
                            double kda = (kills + assists) / deaths;
                            mainChart.Series[datatype].Points.AddXY(chartnum, kda);
                            if (kda > max) { max = kda * 1.25; }
                            chartnum++;
                        }
                    }
                    break;
                case "Kills":
                    max = 0;
                    chartnum = 1;
                    for (int match = RankMatchHistory.Count() - 1; match >= 0; match--)
                    {
                        if (Display_Filter(match) == true)
                        {
                            double kills = Convert.ToDouble(RankMatchHistory[match].kills);
                            mainChart.Series[datatype].Points.AddXY(chartnum, kills);
                            if (kills > max) { max = kills * 1.25; }
                            chartnum++;
                        }
                    }
                    break;
                case "Deaths":
                    max = 0;
                    chartnum = 1;
                    for (int match = RankMatchHistory.Count() - 1; match >= 0; match--)
                    {
                        if (Display_Filter(match) == true)
                        {
                            double deaths = Convert.ToDouble(RankMatchHistory[match].deaths);
                            mainChart.Series[datatype].Points.AddXY(chartnum, deaths);
                            if (deaths > max) { max = deaths * 1.25; }
                            chartnum++;
                        }
                    }
                    break;
                case "Assists":
                    max = 0;
                    chartnum = 1;
                    for (int match = RankMatchHistory.Count() - 1; match >= 0; match--)
                    {
                        if (Display_Filter(match) == true)
                        {
                            double assists = Convert.ToDouble(RankMatchHistory[match].assists);
                            mainChart.Series[datatype].Points.AddXY(chartnum, assists);
                            if (assists > max) { max = assists * 1.25; }
                            chartnum++;
                        }
                    }
                    break;
                case "Level":
                    max = 0;
                    chartnum = 1;
                    for (int match = RankMatchHistory.Count() - 1; match >= 0; match--)
                    {
                        if (Display_Filter(match) == true)
                        {
                            double level = Convert.ToDouble(RankMatchHistory[match].level);
                            mainChart.Series[datatype].Points.AddXY(chartnum, level);
                            if (level > max) { max = level * 1.25; }
                            chartnum++;
                        }
                    }
                    break;
                case "Gold":
                    max = 0;
                    chartnum = 1;
                    for (int match = RankMatchHistory.Count() - 1; match >= 0; match--)
                    {
                        if (Display_Filter(match) == true)
                        {
                            double gold = Convert.ToDouble(RankMatchHistory[match].gold);
                            mainChart.Series[datatype].Points.AddXY(chartnum, gold);
                            if (gold > max) { max = gold * 1.25; }
                            chartnum++;
                        }
                    }
                    break;
                case "Creep Score":
                    chartnum = 1;
                    max = 0;
                    for (int match = RankMatchHistory.Count() - 1; match >= 0; match--)
                    {
                        if (Display_Filter(match) == true)
                        {
                            double cs = Convert.ToDouble(RankMatchHistory[match].cs);
                            mainChart.Series[datatype].Points.AddXY(chartnum, cs);
                            if (cs > max) { max = cs * 1.25; }
                            chartnum++;
                        }
                    }
                    break;
                case "Towers Destroyed":
                    max = 0;
                    chartnum = 1;
                    for (int match = RankMatchHistory.Count() - 1; match >= 0; match--)
                    {
                        if (Display_Filter(match) == true)
                        {
                            double towers = Convert.ToDouble(RankMatchHistory[match].towers);
                            mainChart.Series[datatype].Points.AddXY(chartnum, towers);
                            if (towers > max) { max = towers * 1.25; }
                            chartnum++;
                        }
                    }
                    break;
                case "Wards Placed":
                    chartnum = 1;
                    max = 0;
                    for (int match = RankMatchHistory.Count() - 1; match >= 0; match--)
                    {
                        if (Display_Filter(match) == true)
                        {
                            double wards = Convert.ToDouble(RankMatchHistory[match].wards);
                            mainChart.Series[datatype].Points.AddXY(chartnum, wards);
                            if (wards > max) { max = wards * 1.25; }
                            chartnum++;
                        }
                    }
                    break;
                case "Pink Wards Placed":
                    chartnum = 1;
                    max = 0;
                    for (int match = RankMatchHistory.Count() - 1; match >= 0; match--)
                    {
                        if (Display_Filter(match) == true)
                        {
                            double visionwards = Convert.ToDouble(RankMatchHistory[match].visionwards);
                            mainChart.Series[datatype].Points.AddXY(chartnum, visionwards);
                            if (visionwards > max) { max = visionwards * 1.25; }
                            chartnum++;
                        }
                    }
                    break;
                case "Match Length":
                    chartnum = 1;
                    max = 0;
                    for (int match = RankMatchHistory.Count() - 1; match >= 0; match--)
                    {
                        if (Display_Filter(match) == true)
                        {
                            double time = Convert.ToDouble(RankMatchHistory[match].time);
                            mainChart.Series[datatype].Points.AddXY(chartnum, time / 60);
                            if (time / 60 > max) { max = (time / 60) * 1.25; }
                            chartnum++;
                        }

                    }
                    break;

            }
            mainChart.ChartAreas[0].AxisY.Maximum = max;
            if (mainChart.Series[0].Points.Count() == 1)
            {
                mainChart.Series[0].ChartType = SeriesChartType.Point;
            }
            //mainChart.Series[datatype].Points.AddXY();
        }
 /// <summary>
 /// Initializes graph properties using provided parameters
 /// </summary>
 /// <param name="chartType"></param>
 /// <param name="name"></param>
 /// <param name="tooltip"></param>
 /// <param name="color"></param>
 /// <returns></returns>
 protected virtual void InitializeProperties(SeriesChartType chartType, string name, string tooltip, Color color)
 {
     Data.BorderDashStyle = ChartDashStyle.Solid;
     Data.BorderWidth = 4;
     Data.ChartType = chartType;
     Data.LegendText = name;
     Data.LegendToolTip = tooltip;
     Data.Color = color;
     Data.Name = name;
 }
Beispiel #32
0
        private void InitializeGraphs(Chart chart, SeriesChartType type, double yMin, double yMax)
        {
            chart.Legends.Clear();

            var series = chart.Series[0];
            if(chart.Series.Count > 1)
                chart.Series[1].ChartType = SeriesChartType.Point;
            var chartArea = chart.ChartAreas[0];

            series.ChartType = type;

            series.XValueType = ChartValueType.Int32;

            chartArea.AxisX.ScrollBar.Enabled = true;
            chartArea.AxisX.ScrollBar.IsPositionedInside = false;
            chartArea.AxisX.ScaleView.Size = 10000;
            chartArea.AxisX.MajorTickMark.Interval = 1250;
            chartArea.AxisX.MajorGrid.Interval = 1250;
            chartArea.CursorX.AutoScroll = true;
            chartArea.CursorX.IsUserEnabled = true;
            chartArea.CursorX.IsUserSelectionEnabled = true;
            chartArea.AxisX.ScaleView.Zoomable = true;

            chartArea.AxisX.Minimum = 0;

            //chartArea.AxisY.Minimum = yMin;
            //chartArea.AxisY.Maximum = yMax;
        }
Beispiel #33
0
    private Series createSeries(string seriesName, Color color, SeriesChartType chartType, MarkerStyle markerStyle,
                                IEnumerable<DateTime> dates, params IEnumerable<decimal>[] valueLists)
    {
        Series series = new Series(seriesName);

        series.LegendText = seriesName;
        series.XValueType = ChartValueTypes.DateTime;
        series.EmptyPointStyle.Color = Color.Transparent;
        series.BorderWidth = 2;
        series.Color = color;
        series.MarkerStyle = markerStyle;

        if (dates.Count() == 1 && chartType != SeriesChartType.SplineRange)
        {
            series.Type = SeriesChartType.Point;
            series.MarkerSize = 8;
        }
        else
            series.Type = chartType;

        series.YValuesPerPoint = valueLists.Length;
        series.Points.DataBindXY(dates, valueLists);

        return series;
    }
        /// <summary>
        /// 返回考试分析常用图形
        /// </summary>
        /// <param name="examReportModels">考试报表Models</param>
        /// <param name="seriesChartType">图形类型</param>
        /// <returns></returns>
        public Chart Get考试分析常用图形(ExamReportModels examReportModels, SeriesChartType seriesChartType)
        {
            /* 考试分析Chart */
            Chart chart = Get考试分析Chart(examReportModels);

            /* list考试分析 */
            List<考试分析> list考试分析 = examReportModels.考试分析;
            List<string> listX = list考试分析[0].间隔值列表;

            ChartArea chartArea = Get考试分析ChartArea();

            chartArea.AxisY.Title = "人数";
            chartArea.AxisY.TextOrientation = TextOrientation.Stacked;
            chartArea.AxisY.LineColor = Color.FromArgb(64, 64, 64, 64);
            chartArea.AxisY.LabelStyle.Font = new Font("Trebuchet MS", 8, FontStyle.Bold);
            chartArea.AxisY.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);

            chartArea.AxisX.Title = "分数段";
            chartArea.AxisX.LineColor = Color.FromArgb(64, 64, 64, 64);
            chartArea.AxisX.LabelStyle.Font = new Font("Trebuchet MS", 8, FontStyle.Bold);
            chartArea.AxisX.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);

            chart.ChartAreas.Add(chartArea);

            //加旁边显示
            Legend legend = new Legend();
            legend.ShadowOffset = 3;
            legend.BackColor = Color.Transparent;
            legend.Font = new Font("Trebuchet MS", 8, FontStyle.Bold);
            chart.Legends.Add(legend);

            for (int i = 0; i < list考试分析.Count; i++)
            {
                Series series = new Series();
                series["PointWidth"] = "0.6";
                series["BarLabelStyle"] = "Center";
                series["DrawingStyle"] = "Cylinder";
                series.BorderWidth = 3;
                series.ShadowOffset = 2;
                series.Name = list考试分析[i].部门名;
                series.ChartType = seriesChartType;
                series.IsValueShownAsLabel = true;
                series.Points.DataBindXY(listX, list考试分析[i].人数列表);
                chart.Series.Add(series);
            }

            return chart;
        }
        /// <summary>
        /// 返回考试分析特殊图形
        /// </summary>
        /// <param name="examReportModels">考试报表Models</param>
        /// <param name="seriesChartType">图形类型</param>
        /// <returns></returns>
        public Chart Get考试分析特殊图形(ExamReportModels examReportModels, SeriesChartType seriesChartType)
        {
            /* 考试分析Chart */
            Chart chart = Get考试分析Chart(examReportModels);

            /* list考试分析 */
            List<考试分析> list考试分析 = examReportModels.考试分析;
            List<string> listX = list考试分析[0].间隔值列表;

            for (int i = 0; i < list考试分析.Count; i++)
            {
                ChartArea chartArea = Get考试分析ChartArea();
                List<int> listY = list考试分析[i].人数列表;
                //chartArea.Area3DStyle.Enable3D = true;
                chart.ChartAreas.Add(chartArea);

                Legend legend = new Legend();
                legend.Title = "分数段";
                legend.BackColor = Color.Transparent;
                legend.Font = new Font("Trebuchet MS", 8, FontStyle.Bold);
                legend.DockedToChartArea = chartArea.Name;
                legend.Enabled = true;
                legend.ShadowOffset = 3;
                chart.Legends.Add(legend);

                Series series = new Series();
                series.BorderWidth = 3;
                series.ShadowOffset = 2;
                series.Legend = legend.Name;
                series.Label = "#PERCENT{P1}";
                series.ChartType = seriesChartType;

                series["PieDrawingStyle"] = "SoftEdge";
                series.ChartArea = chartArea.Name;
                for (int k = 0; k < listX.Count; k++)
                {
                    DataPoint point = new DataPoint();
                    point.LegendText = listX[k];
                    point.YValues[0] = listY[k];
                    series.Points.Add(point);
                }
                chart.Series.Add(series);
            }

            return chart;
        }
Beispiel #36
0
 protected void UpdateChartSeries(SeriesType Type, SeriesChartType ChartType, bool bEnabled)
 {
     NetworkChart.Series[( int )Type].ChartType = ChartType;
     NetworkChart.Series[( int )Type].Enabled   = bEnabled;
     ChartListBox.SetItemChecked(( int )Type, bEnabled);
 }