예제 #1
0
        private void UpdateChart()
        {
            try
            {
                chart1.Series.Clear();

                int topicN = 0;
                foreach (DbTopic t in core.GetTopics())
                {
                    chart1.Series.Add(t.Alias[1]);
                    chart1.Series[t.Alias[1]].ChartType   = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
                    chart1.Series[t.Alias[1]].BorderWidth = 2;
                    chart1.Series[t.Alias[1]].XValueType  = ChartValueType.DateTime;
                    if (topicN > 10)
                    {
                        chart1.Series[t.Alias[1]].BorderDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
                    }
                    topicN++;
                }

                int      intervalsToShow = 30;
                TimeSpan interval        = TimeSpan.FromSeconds(0);

                IEnumerable <DbTimeBlock> tbs = null;
                if (comboBoxTime.SelectedIndex == 0)
                {
                    interval = core.TS_quick;
                }
                else if (comboBoxTime.SelectedIndex == 1)
                {
                    interval = core.TS_short;
                }
                else if (comboBoxTime.SelectedIndex == 2)
                {
                    interval = core.TS_medium;
                }
                else if (comboBoxTime.SelectedIndex == 3)
                {
                    interval = core.TS_long;
                }

                tbs = core.GetTimeBlocks(interval, intervalsToShow);

                //DateTime graphTime = DateTime.Now.Add(TimeSpan.FromTicks(-(intervalsToShow-1) * interval.Ticks));

                chart1.ChartAreas[0].AxisX.LabelStyle.Format = "MM-dd|HH:mm";

                foreach (DbTimeBlock tb in tbs)
                {
                    foreach (DbTopic t in core.GetTopics())
                    {
                        if (tb.TopicAR.ContainsKey(t))
                        {
                            if (sortByCol == 2)
                            {
                                chart1.Series[t.Alias[1]].Points.AddXY(tb.Start, tb.TopicAR[t].Popularity);
                            }
                            if (sortByCol == 3)
                            {
                                chart1.Series[t.Alias[1]].Points.AddXY(tb.Start, tb.TopicAR[t].PosVal);
                            }
                            if (sortByCol == 4)
                            {
                                chart1.Series[t.Alias[1]].Points.AddXY(tb.Start, tb.TopicAR[t].NegVal);
                            }
                            if (sortByCol == 5)
                            {
                                chart1.Series[t.Alias[1]].Points.AddXY(tb.Start, tb.TopicAR[t].Ambiguity);
                            }
                        }
                    }
                    //graphTime = graphTime.Add(interval);
                }
            }
            catch (Exception e)
            {
                Console.Out.WriteLine("\n@Chart: fallo al cargar datos o dibujar gráfico\n");
            }
        }