예제 #1
0
        public static void AddSeries(
            System.Windows.Forms.DataVisualization.Charting.Chart chart,
            string seriesName,
            IEnumerable <IChartSeriesPointCollection> dataCollection,
            int optimizeLevel = 0,
            System.Windows.Forms.DataVisualization.Charting.ChartValueType chartXValueType  = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Auto,
            System.Windows.Forms.DataVisualization.Charting.SeriesChartType seriesChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine
            )
        {
            const int optimizeMinSize = 10;
            IEnumerable <IChartSeriesPointCollection> optimizedDataList;

            if (dataCollection.Count() > optimizeMinSize)
            {
                int optimizeThresold = (int)(getDeltaMedian(dataCollection) * ((double)optimizeLevel));
                Console.WriteLine("optimizeThresold {0}", optimizeThresold);

                optimizedDataList = optimizeSeriesData(dataCollection, optimizeThresold);
                Console.WriteLine("OptimizedDataList Count: {0}", optimizedDataList.Count());
            }
            else
            {
                optimizedDataList = dataCollection;
            }

            chart.Series.Add(seriesName);
            chart.Series[seriesName].XValueType = chartXValueType;
            chart.Series[seriesName].ChartType  = seriesChartType;
            chart.Series[seriesName].Points.DataBind(optimizedDataList, "Xvalue", "Yvalue", null);
        }
예제 #2
0
        /// <summary>
        /// Creator of serie from data set and name
        /// </summary>
        /// <param name="Sours">Sours data for serie</param>
        /// <param name="Name">Name of serie</param>
        /// <param name="Type">Type of serie</param>
        private void Filler(SortedDictionary <double, double> Sours, String Name, System.Windows.Forms.DataVisualization.Charting.SeriesChartType Type)
        {
            //If we don't have such serie now
            if (MainChart.Series.IsUniqueName(Name))
            {
                //Create serie
                MainChart.Series.Add(Name);

                //Define type of serie
                MainChart.Series[Name].ChartType = Type;

                //Identify legend for this series
                MainChart.Legends.Add(Name);
                MainChart.Legends[Name].Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Bottom;
                MainChart.Series[Name].Legend   = Name;
            }
            else
            {
                //Clera serie
                MainChart.Series[Name].Points.Clear();
            }

            //Define serie's data
            foreach (KeyValuePair <double, double> p in Sours)
            {
                MainChart.Series[Name].Points.AddXY(p.Key, p.Value);
            }
        }
예제 #3
0
        /// <summary>
        /// Method is used to draw graph on the chart.
        /// </summary>
        /// <param name="seriesIndex">Index of the chart (0, 1 or 2)</param>
        /// <param name="seriesChartType">Chart type (line or point.)</param>
        /// <param name="points">Points which expected to be drown.</param>
        private void DrawGraphic(
            int seriesIndex,
            System.Windows.Forms.DataVisualization.Charting.SeriesChartType seriesChartType,
            List<Point> points,
            string seriesName)
        {
            // Create series instance if it doesn't exist.
            if (chartFunction.Series.Count < seriesIndex + 1)
            {
                chartFunction.Series.Add(new System.Windows.Forms.DataVisualization.Charting.Series());
            }
            else
            {
                for (int i = seriesIndex + 1; i < chartFunction.Series.Count; i++)
                {
                    chartFunction.Series[i].Points.Clear();
                }
            }

            // remove all previous points of the special series.
            if (chartFunction.Series[seriesIndex].Points.Count > 0)
            {
                chartFunction.Series[seriesIndex].Points.Clear();
            }

            chartFunction.Series[seriesIndex].ChartType = seriesChartType;
            for (int i = 0; i < points.Count; i++)
            {
                chartFunction.Series[seriesIndex].Points.AddXY(points[i].X, points[i].Y);
            }

            chartFunction.Series[seriesIndex].Name = seriesName;
        }
예제 #4
0
        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Select chart line type
            switch (comboBox3.SelectedItem.ToString())
            {
            case "Spline":
                series_chart_type = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
                break;

            case "Point":
                series_chart_type = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
                break;

            case "StepLine":
                series_chart_type = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StepLine;
                break;

            case "Line":
                series_chart_type = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                break;

            case "Column":
                series_chart_type = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
                break;
            }
            graph1.ChartType = series_chart_type;
            graph2.ChartType = series_chart_type;
        }
예제 #5
0
 private void cmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     chartType = (System.Windows.Forms.DataVisualization.Charting.SeriesChartType)Enum.Parse(typeof(Utils.SeriesChartType), e.AddedItems[0].ToString());
     foreach (System.Windows.Forms.DataVisualization.Charting.Series item in cpuChart.Series)
     {
         item.ChartType = chartType;
     }
 }
예제 #6
0
        private void MonthlyChart(System.Windows.Forms.DataVisualization.Charting.Chart objChart, DataTable dt1,
                                  System.Windows.Forms.DataVisualization.Charting.SeriesChartType objDefaultChartType)
        {
            string[] XValue1 = GetXValues(dt1);
            double[] YValue1 = GetYValues(dt1);
            objChart.Series[0].Points.DataBindXY(XValue1, YValue1);
            objChart.Series[0].ChartType = objDefaultChartType;

            if (cboChartType.SelectedValue.ToStringCustom() != string.Empty)
            {
                System.Windows.Forms.DataVisualization.Charting.SeriesChartType objChartType = (System.Windows.Forms.DataVisualization.Charting.SeriesChartType)cboChartType.SelectedValue;
                objChart.Series[0].ChartType = objChartType;
            }
        }
예제 #7
0
        public static void Build(
            System.Collections.IEnumerable datas,
            string [] seriesValueFilter,
            PropertyInfo serieSelector,
            PropertyInfo xSelector,
            PropertyInfo ySelector,            
            System.Windows.Forms.DataVisualization.Charting.Chart chart,
            System.Windows.Forms.DataVisualization.Charting.SeriesChartType chartType
            )
        {
            Serie[] data = CreateChartData(datas, serieSelector, seriesValueFilter, xSelector, ySelector);

            AdjustChart(chart, data, chartType);
        }
예제 #8
0
 private void Liczby_Wykres_Click(object sender, EventArgs e)
 {
     if (chart1.Series["Kroki"].IsValueShownAsLabel == false)
     {
         chart1.Series["Kroki"].IsValueShownAsLabel = true;
         System.Windows.Forms.DataVisualization.Charting.SeriesChartType chart = 0;
         chart1.Series["Kroki"].ChartType = chart;
     }
     else if (chart1.Series["Kroki"].IsValueShownAsLabel == true)
     {
         chart1.Series["Kroki"].IsValueShownAsLabel = false;
         System.Windows.Forms.DataVisualization.Charting.SeriesChartType chart2 = (System.Windows.Forms.DataVisualization.Charting.SeriesChartType) 3;
         chart1.Series["Kroki"].ChartType = chart2;
     }
 }
예제 #9
0
        /// <summary>
        /// 添加各专业的series
        /// </summary>
        /// <param name="dt">数据表</param>
        /// <param name="ChartArea">区域名</param>
        /// <param name="Legend">图例名</param>
        /// <param name="LegendToolTip">图例映射格式</param>
        /// <param name="ToolTip">点映射格式</param>
        /// <param name="ChartType">图类型</param>
        private void init_Series(DataTable dt, string ChartArea, string Legend, string LegendToolTip, string ToolTip, System.Windows.Forms.DataVisualization.Charting.SeriesChartType ChartType)
        {
            //MessageBox.Show(ChartArea + " " + Legend);
            //各专业映射
            Dictionary <string, List <int> > mpx = new Dictionary <string, List <int> >();
            Dictionary <string, List <int> > mpy = new Dictionary <string, List <int> >();

            foreach (string ms in MajorSet)
            {
                mpx[ms] = new List <int>();
                mpy[ms] = new List <int>();
            }

            foreach (DataRow dr in dt.Rows)
            {
                mpx[dr[0].ToString()].Add((int)dr[1]);
                mpy[dr[0].ToString()].Add((int)dr[2]);
            }

            string s = null;

            foreach (string ms in MajorSet)
            {
                s = ms + ChartArea;
                myChart.Series.Add(s);
                myChart.Series[s].ChartArea         = ChartArea;
                myChart.Series[s].IsVisibleInLegend = true;
                myChart.Series[s].Legend            = Legend;
                myChart.Series[s].LegendText        = ms;

                myChart.Series[s].LegendToolTip = string.Format(LegendToolTip, ms, ms, ms);
                myChart.Series[s].ToolTip       = string.Format(ToolTip, ms);

                myChart.Series[s].ChartType           = ChartType;
                myChart.Series[s].Enabled             = false;
                myChart.Series[s].IsValueShownAsLabel = true;
                if (!ChartArea.Equals("ChartAreaSum"))
                {
                    myChart.Series[s].BorderWidth = 3;
                }
                myChart.Series[s].Color = System.Drawing.Color.Blue;
                try
                {
                    myChart.Series[s].Points.DataBindXY(mpx[ms], mpy[ms]);
                }
                catch (Exception ex)
                {
                    myChart.Series[s].Points.Clear();
                    MessageBox.Show(ms + " 出现重复列\n" + ex.Message);
                }
            }
        }
        private void LoadCharts()
        {
            DataTable dt = null;

            string timeTableId = "NULL";
            string benchId = "NULL";

            Guid timeTableIdGuid;
            Guid benchIdGuid;

            if (comboBox3.SelectedIndex != -1) { timeTableId = ((ListBoxItem)comboBox3.SelectedItem).HiddenValue; }
            if (cboBench.SelectedIndex != -1) { benchId = ((ListBoxItem)cboBench.SelectedItem).HiddenValue; }

            Guid.TryParse(timeTableId, out timeTableIdGuid);
            Guid.TryParse(benchId, out benchIdGuid);

            chartMain.Series["Investment"].Points.Clear();
            chartMain.Series["Benchmark"].Points.Clear();

            System.Windows.Forms.DataVisualization.Charting.SeriesChartType lineChart = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            System.Windows.Forms.DataVisualization.Charting.SeriesChartType columnChart = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;

            chartMain.Series["Investment"].ChartType = lineChart;
            chartMain.Series["Benchmark"].ChartType = lineChart;

            chartMain.Series["Investment"].Label = "#VAL{0.0}";
            chartMain.Series["Investment"].IsValueShownAsLabel = true;

            chartMain.Series["Benchmark"].Label = null;
            chartMain.Series["Benchmark"].IsValueShownAsLabel = false;

            if (comboBox1.Text == "12 Month Rolling Return")
            {
                dt = ISP.Business.Entities.Fund.Get12MoRollingReturn(timeTableIdGuid, CurrentFund.FundId, benchIdGuid);

                chartMain.Series["Investment"].Label = null;
                chartMain.Series["Investment"].IsValueShownAsLabel = false;
            }
            else if (comboBox1.Text == "36 Month Rolling Return")
            {
                dt = ISP.Business.Entities.Fund.Get36MoRollingReturn(timeTableIdGuid, CurrentFund.FundId, benchIdGuid);

                chartMain.Series["Investment"].Label = null;
                chartMain.Series["Investment"].IsValueShownAsLabel = false;
            }
            else if (comboBox1.Text == "36 Month Rolling Standard Deviation")
            {
                dt = ISP.Business.Entities.Fund.Get36MoRollingStandardDeviation(timeTableIdGuid, CurrentFund.FundId, benchIdGuid);

                chartMain.Series["Investment"].Label = null;
                chartMain.Series["Investment"].IsValueShownAsLabel = false;
            }
            else if (comboBox1.Text == "Annualized Returns")
            {
                dt = ISP.Business.Entities.Fund.GetAnnualizedReturns(timeTableIdGuid, CurrentFund.FundId, benchIdGuid);

                chartMain.Series["Benchmark"].Label = "#VAL{0.0}";
                chartMain.Series["Benchmark"].IsValueShownAsLabel = true;

                chartMain.Series["Investment"].ChartType = columnChart;
                chartMain.Series["Benchmark"].ChartType = columnChart;
            }
            else if (comboBox1.Text == "Annual Returns")
            {
                dt = ISP.Business.Entities.Fund.GetAnnualReturns(timeTableIdGuid, CurrentFund.FundId, benchIdGuid);

                chartMain.Series["Benchmark"].Label = "#VAL{0.0}";
                chartMain.Series["Benchmark"].IsValueShownAsLabel = true;

                chartMain.Series["Investment"].ChartType = columnChart;
                chartMain.Series["Benchmark"].ChartType = columnChart;
            }
            else if (comboBox1.Text == "Standard Deviation")
            {
                dt = ISP.Business.Entities.Fund.GetStandardDevation(timeTableIdGuid, CurrentFund.FundId, benchIdGuid);

                chartMain.Series["Benchmark"].Label = "#VAL{0.0}";
                chartMain.Series["Benchmark"].IsValueShownAsLabel = true;

                chartMain.Series["Investment"].ChartType = columnChart;
                chartMain.Series["Benchmark"].ChartType = columnChart;
            }

            chartMain.Series["Investment"].XValueMember = "XAxis";
            chartMain.Series["Investment"].YValueMembers = "FundSeries";
            chartMain.Series["Benchmark"].XValueMember = "XAxis";
            chartMain.Series["Benchmark"].YValueMembers = "BenchSeries";

            chartMain.DataSource = dt;

            //
            // chartSummary
            //

            dt = ISP.Business.Entities.Fund.GetAnnualizedReturns(timeTableIdGuid, CurrentFund.FundId, benchIdGuid);

            chartSummary.Series["Investment"].Points.Clear();
            chartSummary.Series["Benchmark"].Points.Clear();

            chartSummary.Series["Investment"].XValueMember = "XAxis";
            chartSummary.Series["Investment"].YValueMembers = "FundSeries";
            chartSummary.Series["Benchmark"].XValueMember = "XAxis";
            chartSummary.Series["Benchmark"].YValueMembers = "BenchSeries";
            chartSummary.DataSource = dt;
        }
예제 #11
0
 void cargarchar(System.Windows.Forms.DataVisualization.Charting.Chart cha, string x, string y, string serie, System.Windows.Forms.DataVisualization.Charting.SeriesChartType at = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Bar)
 {
     cha.Series.Add(serie);
     cha.Series[serie].ChartType = at;
     cha.Series[serie].Points.AddXY(x, y);
     cha.Series[serie].MarkerStep = 1;
 }
예제 #12
0
        private static void AdjustChart(System.Windows.Forms.DataVisualization.Charting.Chart chart, Serie[] data, System.Windows.Forms.DataVisualization.Charting.SeriesChartType chartType)
        {
            chart.SuspendLayout();

            chart.Series.Clear();

            foreach (var item in chart.ChartAreas)
            {
                item.AxisX.IsStartedFromZero = false;
                item.AxisY.IsStartedFromZero = false;
            }

            foreach (var item in data)
            {
                var ns = chart.Series.Add(item.Name.ToString());
                ns.ChartType = chartType;

                foreach (var point in item.Points)
                {
                  if (point.Y is ENG.NR2003.Types.RaceGap)
                    ns.Points.AddXY(point.X, (point.Y as ENG.NR2003.Types.RaceGap).Time.TotalMiliseconds);
                  else
                    ns.Points.AddXY(point.X, point.Y);
                }
            }

            chart.ResumeLayout();
        }