private string AnnotationCallback(string text)
        {
            for (int i = 0; i < SeriesCount; i++)
            {
                ChartSerie    s        = (ChartSerie)prop.GetType().GetProperty("Graph_series" + i.ToString()).GetValue(prop, null);
                CustomYSensor sensor   = s.DataSource_source;
                string        name     = "None";
                string        avgvalue = "N/A";
                string        minvalue = "N/A";
                string        maxvalue = "N/A";
                string        unit     = "";
                if (!(sensor is NullYSensor))
                {
                    string resolution = YDataRenderer.FloatToStrformats[Math.Min(sensor.get_resolution().ToString().Length, 6)];
                    name = s.legend != "" ? s.legend : sensor.get_friendlyName();
                    if (sensor.isOnline())
                    {
                        avgvalue = sensor.get_lastAvgValue().ToString(resolution);
                        minvalue = sensor.get_lastMinValue().ToString(resolution);
                        maxvalue = sensor.get_lastMaxValue().ToString(resolution);
                    }
                    unit = sensor.get_unit();
                }
                text = text.Replace("$NAME" + (i + 1).ToString() + "$", name);
                text = text.Replace("$AVGVALUE" + (i + 1).ToString() + "$", avgvalue);
                text = text.Replace("$MAXVALUE" + (i + 1).ToString() + "$", maxvalue);
                text = text.Replace("$MINVALUE" + (i + 1).ToString() + "$", minvalue);
                text = text.Replace("$UNIT" + (i + 1).ToString() + "$", unit);
            }


            return(text);
        }
Пример #2
0
        public ChartSerie GetChartDataForSector(String ptf, String sector)
        {
            if (ptf.Contains("Ecart_"))
            {
                return(GetChartDataForSectorGap(ptf, sector));
            }

            String sql = "SELECT DATE, SUM([" + ptf + "]) * 100 as ptf" +
                         " FROM DATA_FACTSET WHERE SECTOR_LABEL = '" + sector + "' GROUP BY DATE ORDER BY DATE";

            List <KeyValuePair <String, double> > tmp = _connection.sqlToListKeyValuePairDouble(sql);

            ChartSerie res = new ChartSerie();

            res.Label = sector;

            tmp = GetfinDeMois(tmp);
            tmp = GetLastDates(tmp, 12);

            res.Data = new RadObservableCollection <ChartPoint>();
            foreach (var item in tmp)
            {
                if (item.Key != "")
                {
                    res.Data.Add(new ChartPoint(item.Key.Substring(0, 10), item.Value, sector));
                }
            }

            return(res);
        }
Пример #3
0
        /*************************
        *    Charts
        *************************/
        public ChartSerie GetChartDataForCountry(String ptf, String country)
        {
            country = GetShortCountry(country);
            if (ptf.Contains("Ecart_"))
            {
                return(GetChartDataForCountryGap(ptf, country));
            }

            String sql = "SELECT DATE, SUM([" + ptf + "]) * 100 as ptf" +
                         " FROM DATA_FACTSET WHERE COUNTRY = '" + country + "' GROUP BY DATE ORDER BY DATE";

            List <KeyValuePair <String, double> > tmp = _connection.sqlToListKeyValuePairDouble(sql);

            ChartSerie res = new ChartSerie();

            res.Label = GetFullCountry(country);

            tmp = GetfinDeMois(tmp);
            tmp = GetLastDates(tmp, 12);

            res.Data = new RadObservableCollection <ChartPoint>();
            foreach (var item in tmp)
            {
                if (item.Key != "")
                {
                    res.Data.Add(new ChartPoint(item.Key.Substring(0, 10), item.Value, GetFullCountry(country)));
                }
            }

            return(res);
        }
        public void DataLoggerProgress()
        {
            int progress    = 0;
            int sensorCount = 0;

            if (!prop.Graph_showRecordedData)
            {
                Text = prop.Form_Text;
                return;
            }

            foreach (var p in typeof(GraphFormProperties).GetProperties())
            {
                string name = p.Name;
                if (name.StartsWith("Graph_series"))
                {
                    ChartSerie s = (ChartSerie)p.GetValue(prop, null);
                    if (!(s.DataSource_source is NullYSensor))
                    {
                        progress += s.DataSource_source.getGetaLoadProgress();
                        sensorCount++;
                    }
                }
            }

            if ((progress < 100 * sensorCount) && (sensorCount > 0))
            {
                Text = prop.Form_Text + " (loading from datalogger, " + (progress / sensorCount).ToString() + "%)";
            }
            else
            {
                Text = prop.Form_Text;
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            //加载测试文档
            Workbook workbook = new Workbook();

            workbook.LoadFromFile("test.xlsx");

            //获取第一个工作薄以及其中的第一个图表
            Worksheet sheet = workbook.Worksheets[0];
            Chart     chart = sheet.Charts[0];

            //获取图表中的指定系列
            ChartSerie serie1 = chart.Series[1];

            //添加数据标签,并设置数据标签样式
            serie1.DataPoints.DefaultDataPoint.DataLabels.HasValue = true;
            serie1.DataPoints.DefaultDataPoint.DataLabels.FrameFormat.Fill.FillType  = ShapeFillType.SolidColor;
            serie1.DataPoints.DefaultDataPoint.DataLabels.FrameFormat.Fill.ForeColor = Color.White;
            serie1.DataPoints.DefaultDataPoint.DataLabels.FrameFormat.Border.Pattern = ChartLinePatternType.Solid;
            serie1.DataPoints.DefaultDataPoint.DataLabels.FrameFormat.Border.Color   = Color.Green;


            ////使用文档中其他单元格的数据自定义datalabel
            //ChartSerie serie2 = chart.Series[2];
            //serie2.DataPoints.DefaultDataPoint.DataLabels.ValueFromCell = sheet.Range["B4:E4"];
            ////添加数据标注
            //serie2.DataPoints.DefaultDataPoint.DataLabels.HasWedgeCallout = true;

            //保存文档
            workbook.SaveToFile("AddDataLable.xlsx");
            System.Diagnostics.Process.Start("AddDataLable.xlsx");
        }
 public void showRecordedDatachanged()
 {
     if (prop == null)
     {
         return;
     }
     for (int i = 0; i < SeriesCount; i++)
     {
         ChartSerie s = (ChartSerie)prop.GetType().GetProperty("Graph_series" + i.ToString()).GetValue(prop, null);
         SourceChanged(i, s.DataSource_source);
     }
 }
        public void SensorValuecallback(CustomYSensor source, YMeasure M)
        {
            if (prop == null)
            {
                return;
            }

            //     if (FirstLiveValue == 0) FirstLiveValue = M.get_endTimeUTC();

            for (int i = 0; i < SeriesCount; i++)
            {
                ChartSerie s = seriesProperties[i];
                if (s.DataSource_source == source)
                {
                    if (!s.DataSource_source.isOnline())
                    {
                        offlineMessages[i] = s.DataSource_source.get_friendlyName() + " is OFFLINE";
                        showOffline[i]     = true;
                        updateOfflinePanel();


                        return;
                    }

                    showOffline[i] = false;
                    updateOfflinePanel();

                    int index = s.DataSource_source.curData.Count - 1;


                    switch (s.DataSource_datatype)
                    {
                    case 1: _cartesianChart.series[i].AddPoint(new pointXY {
                            x = s.DataSource_source.minData[index].DateTime, y = s.DataSource_source.minData[index].Value
                        }); break;

                    case 2: _cartesianChart.series[i].AddPoint(new pointXY {
                            x = s.DataSource_source.maxData[index].DateTime, y = s.DataSource_source.maxData[index].Value
                        }); break;

                    default:
                        _cartesianChart.series[i].AddPoint(new pointXY {
                            x = s.DataSource_source.curData[index].DateTime, y = s.DataSource_source.curData[index].Value
                        }); break;
                    }
                    _cartesianChart.series[i].unit = s.DataSource_source.get_unit();
                }
            }
        }
Пример #8
0
        private ChartSerie <List <long?> > GetMonthlyTimesSerie(EnterExitRanges timers)
        {
            var dict = new Dictionary <int, List <DateTime?> >();

            for (var i = 1; i < _timeBuilder.GetMonths(); i++)
            {
                dict.Add(i, new List <DateTime?> {
                    null, null
                });
            }

            foreach (var timer in timers.EnterTimers)
            {
                dict[timer.Date.Day][0] = _timeBuilder.UpdateTime(_timeGetter.Now, timer.Time);
            }

            foreach (var timer in timers.ExitTimers)
            {
                dict[timer.Date.Day][1] = _timeBuilder.UpdateTime(_timeGetter.Now, timer.Time);
            }

            var chartSerie = new ChartSerie <List <long?> >();

            for (var i = 1; i < _timeBuilder.GetMonths(); i++)
            {
                var inst = dict[i];

                var extremes = CalculateExtremes(inst);

                if (extremes.Item1.HasValue && extremes.Item2.HasValue)
                {
                    chartSerie.data.Add(new List <long?>()
                    {
                        _timeBuilder.ToJavascriptTicks(extremes.Item1.Value,
                                                       _timeZoneInfo),
                        _timeBuilder.ToJavascriptTicks(extremes.Item2.Value,
                                                       _timeZoneInfo)
                    });
                }
                else
                {
                    chartSerie.data.Add(new List <long?> {
                        null, null
                    });
                }
            }
            return(chartSerie);
        }
Пример #9
0
        public IActionResult GetMonthlySells()
        {
            IActionResult result;

            try
            {
                var response = new MonthSellsResponse();
                // get purchase
                var purchases = this.purchaseService.Get();
                if (purchases != null && purchases.Any())
                {
                    purchases = purchases.Where(x => x.StateId == (int)Enums.PurchaseState.Paid).ToList();
                    var categories = purchases.Select(x => x.CreationDate.Date).Distinct();

                    response.Categories = categories.Select(x => x.Date.ToString("dd-MM-yyyy")).ToList();
                    var serie = new ChartSerie()
                    {
                        Name = "Total diario",
                        Data = new List <object>()
                    };
                    foreach (var category in categories)
                    {
                        int value             = 0;
                        var categoryPurchases = purchases.Where(x => x.CreationDate.Date.Equals(category.Date)).ToList();

                        foreach (var categoryPurchase in categoryPurchases)
                        {
                            value += categoryPurchase.Total;
                        }

                        serie.Data.Add(value);
                    }

                    response.Serie = serie;
                }

                result = Ok(JsonConvert.SerializeObject(response));
            }
            catch (Exception ex)
            {
                result = BadRequest(ex.Message);
            }

            return(result);
        }
        private void clearDataLogger(object sender, EventArgs e)
        {
            if (System.Windows.Forms.MessageBox.Show("Do you really want to erase contents of all dataloggers related to this graph?",
                                                     "Erase dataloggers contents?",
                                                     MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            List <YDataLogger> loggers = new List <YDataLogger>();

            for (int i = 0; i < SeriesCount; i++)
            {
                ChartSerie    s      = (ChartSerie)prop.GetType().GetProperty("Graph_series" + i.ToString()).GetValue(prop, null);
                CustomYSensor sensor = s.DataSource_source;
                if (!(sensor is NullYSensor))
                {
                    sensor.stopDataloggerloading();
                    string serial = sensor.get_hardwareId();
                    int    n      = serial.IndexOf(".");
                    serial = serial.Substring(0, n);
                    YDataLogger d = YDataLogger.FindDataLogger(serial + ".dataLogger");
                    if (d.isOnline())
                    {
                        if (loggers.IndexOf(d) < 0)
                        {
                            loggers.Add(d);
                        }
                    }
                }
            }

            for (int i = 0; i < loggers.Count; i++)
            {
                loggers[i].forgetAllDataStreams();
                loggers[i].set_recording(YDataLogger.RECORDING_ON);
            }

            bool tmp = prop.Graph_showRecordedData;

            prop.Graph_showRecordedData = false;
            truncateView();
            prop.Graph_showRecordedData = tmp;
        }
Пример #11
0
        private ChartSerie <double?> GetMonthlyLunchTotalsSerie(EnterExitRanges timers)
        {
            var enterExitsLunch = new Dictionary <int, List <DateTime?> >();

            for (var i = 1; i < _timeBuilder.GetMonths(); i++)
            {
                enterExitsLunch.Add(i, new List <DateTime?>()
                {
                    null, null
                });
            }

            foreach (var timer in timers.EnterTimers)
            {
                enterExitsLunch[timer.Date.Day][0] = _timeBuilder.UpdateTime(_timeGetter.Now, timer.Time);
            }

            foreach (var timer in timers.ExitTimers)
            {
                enterExitsLunch[timer.Date.Day][1] = _timeBuilder.UpdateTime(_timeGetter.Now, timer.Time);
            }

            var chartSerie = new ChartSerie <double?>();

            for (var i = 1; i < _timeBuilder.GetMonths(); i++)
            {
                var enterExitLunch         = enterExitsLunch[i];
                var enterExitLunchExtremes = CalculateExtremes(enterExitLunch);

                if (enterExitLunchExtremes.Item1.HasValue && enterExitLunchExtremes.Item2.HasValue)
                {
                    var enterExitLunchDiff = (enterExitLunchExtremes.Item2.Value - enterExitLunchExtremes.Item1.Value);
                    chartSerie.data.Add(enterExitLunchDiff.Hours + (enterExitLunchDiff.Minutes / 100d));
                }

                else
                {
                    chartSerie.data.Add(null);
                }
            }
            return(chartSerie);
        }
Пример #12
0
        private ChartSerie <List <long?> > GetWeeklyTimesSerie(EnterExitRanges timers)
        {
            var dict = _timeBuilder.GetDayOfWeeks()
                       .ToDictionary(dayOfWeek => dayOfWeek, dayOfWeek => new List <DateTime?> {
                null, null
            });

            foreach (var timer in timers.EnterTimers)
            {
                dict[timer.Date.DayOfWeek][0] = _timeBuilder.UpdateTime(_timeGetter.Now, timer.Time);
            }

            foreach (var timer in timers.ExitTimers)
            {
                dict[timer.Date.DayOfWeek][1] = _timeBuilder.UpdateTime(_timeGetter.Now, timer.Time);
            }

            var chartSerie = new ChartSerie <List <long?> >();

            foreach (var dayOfWeek in _timeBuilder.GetDayOfWeeks())
            {
                var inst = dict[dayOfWeek];

                var extremes = CalculateExtremes(inst);

                if (extremes.Item1.HasValue && extremes.Item2.HasValue)
                {
                    chartSerie.data.Add(new List <long?>()
                    {
                        _timeBuilder.ToJavascriptTicks(extremes.Item1.Value, _timeZoneInfo),
                        _timeBuilder.ToJavascriptTicks(extremes.Item2.Value, _timeZoneInfo)
                    });
                }
                else
                {
                    chartSerie.data.Add(new List <long?> {
                        null, null
                    });
                }
            }
            return(chartSerie);
        }
Пример #13
0
        private ChartSerie <double?> GetMonthlyTotalsSerie(Dictionary <DateTime, TimeSpan> totals)
        {
            var chartSerie = new ChartSerie <double?>();

            var groupedByDayOfWeek = totals.GroupBy(x => x.Key.Day).ToDictionary(x => x.Key, x => x.Select(y => y.Value).FirstOrDefault());

            for (var i = 1; i < _timeBuilder.GetMonths(); i++)
            {
                if (groupedByDayOfWeek.ContainsKey(i))
                {
                    var totalsByDay = groupedByDayOfWeek[i];
                    chartSerie.data.Add(totalsByDay.Hours + (totalsByDay.Minutes / 100d));
                }
                else
                {
                    chartSerie.data.Add(null);
                }
            }
            return(chartSerie);
        }
        public void DataloggerCompleted(CustomYSensor Source)
        {
            if (!prop.Graph_showRecordedData)
            {
                return;
            }

            foreach (var p in typeof(GraphFormProperties).GetProperties())
            {
                string name = p.Name;
                if (name.StartsWith("Graph_series"))
                {
                    ChartSerie s = (ChartSerie)p.GetValue(prop, null);
                    if (s.DataSource_source == Source)
                    {
                        int index = int.Parse(name.Substring(12));
                        SourceChanged(index, Source);
                    }
                }
            }
        }
Пример #15
0
        private ChartSerie <double?> GetWeeklyLunchTotalsSerie(EnterExitRanges timers)
        {
            var enterExitsLunch = _timeBuilder.GetDayOfWeeks().ToDictionary(dayOfweek => dayOfweek, dayOfweek => new List <DateTime?>()
            {
                null, null
            });

            foreach (var timer in timers.EnterTimers)
            {
                enterExitsLunch[timer.Date.DayOfWeek][0] = _timeBuilder.UpdateTime(_timeGetter.Now, timer.Time);
            }

            foreach (var timer in timers.ExitTimers)
            {
                enterExitsLunch[timer.Date.DayOfWeek][1] = _timeBuilder.UpdateTime(_timeGetter.Now, timer.Time);
            }

            var chartSerie = new ChartSerie <double?>();

            foreach (var dayOfWeek in _timeBuilder.GetDayOfWeeks())
            {
                var enterExitLunch         = enterExitsLunch[dayOfWeek];
                var enterExitLunchExtremes = CalculateExtremes(enterExitLunch);

                if (enterExitLunchExtremes.Item1.HasValue && enterExitLunchExtremes.Item2.HasValue)
                {
                    var enterExitLunchDiff = (enterExitLunchExtremes.Item2.Value - enterExitLunchExtremes.Item1.Value);
                    chartSerie.data.Add(enterExitLunchDiff.Hours + (enterExitLunchDiff.Minutes / 100d));
                }
                else
                {
                    chartSerie.data.Add(null);
                }
            }
            return(chartSerie);
        }
        public GraphForm(StartForm parent, XmlNode initData)
        {
            InitializeComponent();
            seriesProperties = new List <ChartSerie>();
            _cartesianChart  = new YGraph(rendererCanvas, LogManager.Log);
            _cartesianChart.getCaptureParameters = constants.getCaptureParametersCallback;
            _cartesianChart.DisableRedraw();

            noDataSourcepanel      = _cartesianChart.addMessagePanel();
            noDataSourcepanel.text = "No data source configured\n"
                                     + " 1 - Make sure you have a Yoctopuce sensor connected.\n"
                                     + " 2 - Do a right-click on this window.\n"
                                     + " 3 - Choose \"Configure this graph\" to bring up the properties editor.\n"
                                     + " 4 - Choose a data source\n";

            offLineSourcesPanel               = _cartesianChart.addMessagePanel();
            offLineSourcesPanel.bgColor       = System.Drawing.Color.FromArgb(192, 255, 192, 192);
            offLineSourcesPanel.borderColor   = System.Drawing.Color.DarkRed;
            offLineSourcesPanel.font.color    = System.Drawing.Color.DarkRed;
            offLineSourcesPanel.panelHrzAlign = MessagePanel.HorizontalAlignPos.RIGHT;
            offLineSourcesPanel.panelVrtAlign = MessagePanel.VerticalAlignPos.TOP;



            captureRunningPanel               = _cartesianChart.addMessagePanel();
            captureRunningPanel.bgColor       = System.Drawing.Color.FromArgb(240, 200, 255, 193);;
            captureRunningPanel.borderColor   = System.Drawing.Color.DarkGreen;
            captureRunningPanel.font.color    = System.Drawing.Color.DarkGreen;
            captureRunningPanel.panelHrzAlign = MessagePanel.HorizontalAlignPos.LEFT;
            captureRunningPanel.panelVrtAlign = MessagePanel.VerticalAlignPos.TOP;


            _cartesianChart.setPatchAnnotationCallback(AnnotationCallback);


            foreach (var p in typeof(YaxisDescription).GetProperties())
            {
                if (p.Name.StartsWith("zones"))
                {
                    ZoneCountPerYaxis++;
                }
            }

            foreach (var p in typeof(XaxisDescription).GetProperties())
            {
                if (p.Name.StartsWith("markers"))
                {
                    MarkerCountPerXaxis++;
                }
            }



            foreach (var p in typeof(GraphFormProperties).GetProperties())
            {
                string name = p.Name;
                if (name.StartsWith("Graph_series"))
                {
                    SeriesCount++;
                }
            }

            if (YAxisCount == 0)
            {
                AnnotationPanelCount = 0;
                foreach (var p in typeof(GraphFormProperties).GetProperties())
                {
                    string name = p.Name;
                    if (name.StartsWith("Graph_yAxes"))
                    {
                        YAxisCount++;
                    }
                    if (name.StartsWith("Graph_annotationPanel"))
                    {
                        AnnotationPanelCount++;
                    }
                }
            }


            for (int i = 0; i < YAxisCount; i++)
            {
                YAxis axis = _cartesianChart.addYAxis();
                for (int j = 0; j < ZoneCountPerYaxis; j++)
                {
                    axis.AddZone();
                }
            }

            markers = new List <Marker>();
            for (int i = 0; i < MarkerCountPerXaxis; i++)
            {
                Marker m = _cartesianChart.xAxis.AddMarker();
                m.xposition = TimeConverter.ToUnixTime(DateTime.UtcNow) + i * 60;
                markers.Add(m);
            }



            for (int i = 0; i < AnnotationPanelCount; i++)
            {
                _cartesianChart.addAnnotationPanel();
            }

            prop = new GraphFormProperties(initData, this);

            for (int i = 0; i < SeriesCount; i++)
            {
                seriesProperties.Add((ChartSerie)prop.GetType().GetProperty("Graph_series" + i.ToString()).GetValue(prop, null));
                _cartesianChart.addSerie();
            }
            _cartesianChart.yAxes[0].visible = true;

            offlineMessages = new String[SeriesCount];
            showOffline     = new bool[SeriesCount];

            manager      = new formManager(this, parent, initData, "graph", prop);
            mainForm     = parent;
            initDataNode = initData;
            prop.ApplyAllProperties(this);
            if (!manager.initForm())
            {
                Rectangle s = Screen.FromControl(this).Bounds;
                this.Location = new Point((s.Width - this.Width) >> 1, (s.Height - this.Height) >> 1);
            }

            YDataRenderer.minMaxCheckDisabled = true;
            try { prop.ApplyAllProperties(_cartesianChart); }
            catch (TargetInvocationException e) { LogManager.Log("Graph initialization raised an exception (" + e.InnerException.Message + ")"); }
            YDataRenderer.minMaxCheckDisabled = false;

            manager.configureContextMenu(this, contextMenuStrip1, showConfiguration, switchConfiguration, capture);
            _cartesianChart.proportionnalValueChangeCallback = manager.proportionalValuechanged;

            for (int i = 0; i < SeriesCount; i++)
            {
                ChartSerie s = (ChartSerie)prop.GetType().GetProperty("Graph_series" + i.ToString()).GetValue(prop, null);
                s.Init(this, i);
                if (s.DataSource_source != null)
                {
                    SourceChanged(i, s.DataSource_source);
                }
            }

            for (int i = 0; i < YAxisCount; i++)
            {
                _cartesianChart.yAxes[i].AxisChanged   = AxisParamtersChangedAutomatically;
                _cartesianChart.yAxes[i].AllowAutoShow = true;
            }
            _cartesianChart.resetRefrenceSize();
            _cartesianChart.AllowPrintScreenCapture          = true;
            _cartesianChart.proportionnalValueChangeCallback = manager.proportionalValuechanged;
            _cartesianChart.setMarkerCaptureCallbacks(MarkedCaptureStarted, MarkedCaptureStopped);
            _cartesianChart.AllowRedraw();
            deleteMarkeOption = new ToolStripMenuItem("Disable all markers", Resources.disable_marker, disableAllMarkers);
            contextMenuStrip1.Items.Insert(2, deleteMarkeOption);
            markersMenu = new ToolStripMenuItem("Place markers", Resources.add_marker);
            contextMenuStrip1.Items.Insert(2, markersMenu);
            Pen          pIcon        = new Pen(Color.DarkRed);
            SolidBrush   bIcon        = new SolidBrush(Color.LightYellow);
            StringFormat stringFormat = new StringFormat();

            stringFormat.Alignment     = StringAlignment.Center;
            stringFormat.LineAlignment = StringAlignment.Center;
            Font font1 = new Font("Arial", 9, FontStyle.Regular, GraphicsUnit.Pixel);

            for (int i = 0; i < markers.Count; i++)
            {
                int index = i;

                Bitmap   bm = new Bitmap(16, 16);
                Graphics gr = Graphics.FromImage(bm);
                gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                gr.FillEllipse(bIcon, new Rectangle(1, 1, 14, 14));
                gr.DrawEllipse(pIcon, new Rectangle(1, 1, 14, 14));
                gr.DrawString((i + 1).ToString(), font1, Brushes.Black, new Rectangle(1, 1, 16, 16), stringFormat);
                markersMenu.DropDownItems.Add(new ToolStripMenuItem("Place marker #" + (i + 1).ToString(), bm, (object sender, EventArgs e) => { startMarkerCapture(index); }));
                gr.Dispose();
            }
            pIcon.Dispose();
            bIcon.Dispose();
            markersMenu.DropDownOpening += updateMakerList;
            contextMenuStrip1.Items.Insert(2, new ToolStripSeparator());
            contextMenuStrip1.Items.Insert(2, new ToolStripMenuItem("Clear dataloggers", Resources.cleardatalogger, clearDataLogger));
            contextMenuStrip1.Items.Insert(2, new ToolStripMenuItem("Reset data view", Resources.resetdataview, resetDataView));
            contextMenuStrip1.Items.Insert(2, new ToolStripSeparator());
            contextMenuStrip1.Opening += ContextMenuStrip1_Opening;


            _cartesianChart.OnDblClick += rendererCanvas_DoubleClick;
            if (constants.OSX_Running)
            {
                _cartesianChart.OnRightClick += rendererCanvas_RightClick;
            }
        }
        public void SensorNewDataBlock(CustomYSensor source, int sourceFromIndex, int sourcetoIndex, int targetIndex, bool fromDataLogger)
        {
            if ((fromDataLogger) && (!prop.Graph_showRecordedData))
            {
                return;
            }

            if (prop == null)
            {
                return;
            }

            List <pointXY[]> l;

            for (int i = 0; i < SeriesCount; i++)
            {
                ChartSerie s = (ChartSerie)prop.GetType().GetProperty("Graph_series" + i.ToString()).GetValue(prop, null);
                if (s.DataSource_source == source)
                {
                    int       count     = sourcetoIndex - sourceFromIndex + 1;
                    pointXY[] datablock = new pointXY[count];

                    if (count > 1)
                    {
                        switch (s.DataSource_datatype)
                        {
                        case 1:

                            l = decomposeToSegments(s.DataSource_source.minData, sourceFromIndex, count);
                            for (int j = l.Count - 1; j >= 0; j--)
                            {
                                _cartesianChart.series[i].InsertPoints(l[j]);
                            }



                            break;

                        case 2:

                            l = decomposeToSegments(s.DataSource_source.maxData, sourceFromIndex, count);
                            for (int j = l.Count - 1; j >= 0; j--)
                            {
                                _cartesianChart.series[i].InsertPoints(l[j]);
                            }



                            break;

                        default:
                            l = decomposeToSegments(s.DataSource_source.curData, sourceFromIndex, count);
                            for (int j = l.Count - 1; j >= 0; j--)
                            {
                                _cartesianChart.series[i].InsertPoints(l[j]);
                            }


                            break;
                        }
                    }
                }
            }
        }
Пример #18
0
        public ChartSerie GetChartDataForCountryGap(String ptf, String country)
        {
            String bench   = "";
            String ptfBase = ptf.Replace("Ecart_", "");

            #region Choix du Bench
            switch (ptfBase)
            {
            case ("6100002"):
                bench = "MXFR";
                break;

            case ("6100030"):
                bench = "MXEM";
                break;

            case ("AVEURO"):
                bench = "MXEM";
                break;

            case ("6100004"):
                bench = "MXEM";
                break;

            case ("610000263"):
                bench = "MXEM";
                break;

            case ("AVEUROPE"):
                bench = "MXEM";
                break;

            case ("6100001"):
                bench = "MXEM";
                break;

            case ("6100033"):
                bench = "MXEM";
                break;

            case ("6100062"):
                bench = "MXEUM";
                break;

            case ("6100026"):
                bench = "MXEU";
                break;

            case ("6100024"):
                bench = "MXUSLC";
                break;
            }
            #endregion

            #region Sql Request
            String sql = "";
            sql += " SELECT ";
            sql += " fac.COUNTRY,  ";
            sql += " fac.Date as Date, ";
            sql += " convert(decimal(10, 2),SUM(fac.MXFR)) as MXFR, ";
            sql += " convert(decimal(10, 2),SUM(fac.MXEM)) as MXEM, ";
            sql += " convert(decimal(10, 2),SUM(fac.MXEUM)) as MXEUM, ";
            sql += " convert(decimal(10, 2),SUM(fac.MXEU)) as MXEU, ";
            sql += " convert(decimal(10, 2),SUM(fac.MXUSLC)) as MXUSLC ";
            sql += " INTO #BENCH ";
            sql += " FROM DATA_FACTSET as fac  ";
            sql += " WHERE COUNTRY = '" + country + "' ";
            sql += " GROUP BY fac.Date, fac.COUNTRY ";
            sql += " ORDER BY fac.COUNTRY ";
            sql += "  ";
            sql += " SELECT  ";
            sql += " fac.DATE, ";
            sql += " convert(decimal(10, 2),SUM(fac.[" + ptfBase + "] * 100) - b." + bench + ") as ptf ";
            sql += " FROM DATA_FACTSET as fac ";
            sql += " inner join #BENCH as b on b.date = fac.date ";
            sql += " WHERE fac.COUNTRY = '" + country + "'  ";
            sql += " GROUP BY fac.DATE, b." + bench + " ORDER BY fac.DATE ";
            sql += " DROP TABLE #BENCH ";
            #endregion

            List <KeyValuePair <String, double> > tmp = _connection.sqlToListKeyValuePairDouble(sql);

            ChartSerie res = new ChartSerie();
            res.Label = GetFullCountry(country);

            tmp = GetfinDeMois(tmp);
            tmp = GetLastDates(tmp, 12);

            res.Data = new RadObservableCollection <ChartPoint>();
            foreach (var item in tmp)
            {
                if (item.Key != "")
                {
                    res.Data.Add(new ChartPoint(item.Key.Substring(0, 10), item.Value, GetFullCountry(country)));
                }
            }

            return(res);
        }
Пример #19
0
		public static ChartSerie CreateChartSerie(ExcelChart chart, bool isPivot, Range seriesAddress, Range xSeriesAddress)
		{
			ChartSerie result = null ;
			switch (chart.ChartType)
			{
				case ExcelChartType.XYScatter:
				case ExcelChartType.XYScatterLines:
				case ExcelChartType.XYScatterLinesNoMarkers:
				case ExcelChartType.XYScatterSmooth:
				case ExcelChartType.XYScatterSmoothNoMarkers:
					result = new ScatterChartSerie(chart, isPivot);
					break;
				case ExcelChartType.Pie:
				case ExcelChartType.Pie3D:
				case ExcelChartType.PieExploded:
				case ExcelChartType.PieExploded3D:
				case ExcelChartType.PieOfPie:
				case ExcelChartType.Doughnut:
				case ExcelChartType.DoughnutExploded:
				case ExcelChartType.BarOfPie:
					result = new PieChartSerie(chart, isPivot);
					break;
				case ExcelChartType.Line:
				case ExcelChartType.LineMarkers:
				case ExcelChartType.LineMarkersStacked:
				case ExcelChartType.LineMarkersStacked100:
				case ExcelChartType.LineStacked:
				case ExcelChartType.LineStacked100:
					result = new LineChartSerie(chart, isPivot);
					if (chart.ChartType == ExcelChartType.LineMarkers ||
						chart.ChartType == ExcelChartType.LineMarkersStacked ||
						chart.ChartType == ExcelChartType.LineMarkersStacked100)
					{
						((LineChartSerie)result).Marker = ExcelMarkerStyle.Square;
					}
					((LineChartSerie)result).Smooth = ((ExcelLineChart)chart).Smooth;
					break;

				default:
					result = new ChartSerie(chart, isPivot);
					break;
			}
			result.Series = seriesAddress;
			result.XSeries = xSeriesAddress;

			return result;
		}
        public int getSensorDataType(int index)
        {
            ChartSerie s = (ChartSerie)prop.GetType().GetProperty("Graph_series" + index.ToString()).GetValue(prop, null);

            return(s.DataSource_datatype);
        }
Пример #21
0
        public ChartSerie GetChartDataForSectorGap(String ptf, String sector)
        {
            String bench   = "";
            String ptfBase = ptf.Replace("Ecart_", "");

            #region Choix du Bench
            switch (ptfBase)
            {
            case ("6100002"):
                bench = "MXFR";
                break;

            case ("6100030"):
                bench = "MXEM";
                break;

            case ("AVEURO"):
                bench = "MXEM";
                break;

            case ("6100004"):
                bench = "MXEM";
                break;

            case ("610000263"):
                bench = "MXEM";
                break;

            case ("AVEUROPE"):
                bench = "MXEM";
                break;

            case ("6100001"):
                bench = "MXEM";
                break;

            case ("6100033"):
                bench = "MXEM";
                break;

            case ("6100062"):
                bench = "MXEUM";
                break;

            case ("6100026"):
                bench = "MXEU";
                break;

            case ("6100024"):
                bench = "MXUSLC";
                break;
            }
            #endregion

            #region Sql Request
            String sql = "";
            sql += " SELECT distinct ";
            sql += " fac.DATE, ";
            sql += " ss.label as 'SECTOR GICS', ";
            sql += " convert(decimal(10, 2),SUM(fac.MXFR)) as MXFR, ";
            sql += " convert(decimal(10, 2),SUM(fac.[6100002]) * 100)  as [6100002],  ";
            sql += " convert(decimal(10, 2),SUM(fac.MXEM)) as MXEM, ";
            sql += " convert(decimal(10, 2),SUM(fac.[6100030]) * 100)  as [6100030],  ";
            sql += " convert(decimal(10, 2),SUM(fac.AVEURO) * 100)  as AVEURO,  ";
            sql += " convert(decimal(10, 2),SUM(fac.[6100004]) * 100)  as [6100004],  ";
            sql += " convert(decimal(10, 2),SUM(fac.[6100063]) * 100)  as [6100063],  ";
            sql += " convert(decimal(10, 2),SUM(fac.AVEUROPE) * 100)  as AVEUROPE,  ";
            sql += " convert(decimal(10, 2),SUM(fac.[6100001]) * 100)  as [6100001],  ";
            sql += " convert(decimal(10, 2),SUM(fac.[6100033]) * 100)  as [6100033], ";
            sql += " convert(decimal(10, 2),SUM(fac.MXEUM)) as MXEUM, ";
            sql += " convert(decimal(10, 2),SUM(fac.[6100062]) * 100)  as [6100062], ";
            sql += " convert(decimal(10, 2),SUM(fac.MXEU)) as MXEU, ";
            sql += " convert(decimal(10, 2),SUM(fac.[6100026]) * 100)  as [6100026], ";
            sql += " convert(decimal(10, 2),SUM(fac.MXUSLC)) as MXUSLC, ";
            sql += " convert(decimal(10, 2),SUM(fac.[6100024]) * 100)  as [6100024] ";
            sql += " INTO #values ";
            sql += " FROM ref_security.SECTOR as ss ";
            sql += " inner join DATA_FACTSET as fac on fac.GICS_SECTOR = ss.code ";
            sql += " where  ";
            sql += " level = 0 ";
            sql += " and ss.class_name =  'GICS' and fac.GICS_SUBINDUSTRY is null  ";
            sql += " and ss.label = '" + sector + "' ";
            sql += " GROUP BY ss.label, fac.DATE ";
            sql += " ORDER BY ss.label, fac.DATE ";
            sql += "  ";
            sql += " SELECT date, ";
            sql += " convert(decimal(10, 2),[" + ptfBase + "] - " + bench + ") as pft ";
            sql += " FROM #values ";
            sql += "  ";
            sql += " DROP TABLE #values ";

            #endregion

            List <KeyValuePair <String, double> > tmp = _connection.sqlToListKeyValuePairDouble(sql);

            ChartSerie res = new ChartSerie();
            res.Label = sector;

            tmp = GetfinDeMois(tmp);
            tmp = GetLastDates(tmp, 12);

            res.Data = new RadObservableCollection <ChartPoint>();
            foreach (var item in tmp)
            {
                if (item.Key != "")
                {
                    res.Data.Add(new ChartPoint(item.Key.Substring(0, 10), item.Value, sector));
                }
            }

            return(res);
        }
Пример #22
0
        public RadObservableCollection <ChartSerie> GetChartIndustriesDataSource(String ptf, String sector)
        {
            if (ptf == null)
            {
                return(null);
            }

            String idsector = _connection.GetIdSectorFromName(sector).ToString().Trim();
            String ptff     = "[" + ptf.Replace("Ecart_", "") + "]";

            List <DateIndustryValue> tmp;

            if (ptf.Contains("Ecart_"))
            {
                String bench = "";
                if (ptff == "[6100002]")
                {
                    bench = "MXFR";
                }
                else if (ptff == "[6100030]" || ptff == "[AVEURO]" || ptff == "[6100004]" ||
                         ptff == "[6100063]" || ptff == "[AVEUROPE]" || ptff == "[6100001]" || ptff == "[6100033]")
                {
                    bench = "MXEM";
                }
                else if (ptff == "[6100062]")
                {
                    bench = "MXEUM";
                }
                else if (ptff == "[6100026]")
                {
                    bench = "MXEU";
                }
                else if (ptff == "[6100024]" || ptff == "[6100066]")
                {
                    bench = "MXUSLC";
                }

                tmp = _connection.ProckStockToDateIndustryValue("ACT_RepartitionIndustries",
                                                                idsector, ptff, bench);
            }
            else
            {
                tmp = _connection.ProckStockToDateIndustryValue("ACT_RepartitionIndustries",
                                                                idsector, ptff, "null");
            }

            if (tmp == null)
            {
                return(null);
            }

            List <List <KeyValuePair <String, double> > > tmp2 = new List <List <KeyValuePair <String, double> > >();

            List <KeyValuePair <String, double> > currentList = new List <KeyValuePair <String, double> >();
            List <String> industriesName = new List <string>();

            String currentIndustry = "";

            foreach (var v in tmp)
            {
                if (currentIndustry == "")
                {
                    currentIndustry = v.Industry;
                }

                if (currentIndustry != v.Industry)
                {
                    industriesName.Add(currentIndustry);
                    currentIndustry = v.Industry;
                    tmp2.Add(currentList);
                    currentList = new List <KeyValuePair <String, double> >();
                    currentList.Add(new KeyValuePair <String, double>(v.Date.Substring(0, 10), v.Value));
                    currentIndustry = v.Industry;
                }
                else
                {
                    currentList.Add(new KeyValuePair <String, double>(v.Date.Substring(0, 10), v.Value));
                }
            }
            tmp2.Add(currentList);
            industriesName.Add(currentIndustry);

            for (int i = 0; i < tmp2.Count; i++)
            {
                tmp2[i] = GetfinDeMois(tmp2[i]);
                tmp2[i] = GetLastDates(tmp2[i], 12);
            }

            RadObservableCollection <ChartSerie> res = new RadObservableCollection <ChartSerie>();

            for (int i = 0; i < tmp2.Count; i++)
            {
                ChartSerie serie = new ChartSerie();
                serie.Label = industriesName[i];
                serie.Data  = new RadObservableCollection <ChartPoint>();

                foreach (var v in tmp2[i])
                {
                    serie.Data.Add(new ChartPoint(v.Key, v.Value, industriesName[i]));
                }

                res.Add(serie);
            }

            return(res);

            /*
             * String industries = "";
             * industries += " SELECT ";
             * industries += "  distinct  fac.DATE as Date, ";
             * industries += "  s.label, ";
             * industries += "  convert(decimal(10, 2),SUM(fac.[" + ptf + "] *  100)) as '" + ptf + "'  ";
             * industries += "  FROM ref_security.SECTOR s   ";
             * industries += "  INNER JOIN ref_security.SECTOR_TRANSCO st on  ";
             * industries += "  st.id_sector1 = s.id   ";
             * industries += "  INNER JOIN ref_security.SECTOR fils on   ";
             * industries += "  fils.id = st.id_sector2   ";
             * industries += "  LEFT OUTER JOIN ref_security.SECTOR ss ON   ";
             * industries += "  fils.id_parent = ss.id   ";
             * industries += "  INNER JOIN DATA_FACTSET fac on   ";
             * industries += "  fac.FGA_SECTOR = s.code   ";
             * industries += "  WHERE fac.GICS_SECTOR is null  ";
             * industries += "  AND ss.class_name = 'GICS'   ";
             * industries += "  AND ss.label = '" + sector + "' ";
             * industries += "  GROUP BY fac.DATE, s.label ORDER BY s.label, DATE";
             *
             * List<DateIndustryValue> tmp = _connection.sqlToDateIndustryValue(industries);
             * List<List<KeyValuePair<String, double>>> tmp2 = new List<List<KeyValuePair<String, double>>>();
             *
             * List<KeyValuePair<String, double>> currentList = new List<KeyValuePair<String, double>>();
             * List<String> industriesName = new List<string>();
             *
             * String currentIndustry = "";
             * foreach (var v in tmp)
             * {
             *  if (currentIndustry == "")
             *      currentIndustry = v.Industry;
             *
             *  if (currentIndustry != v.Industry)
             *  {
             *      industriesName.Add(currentIndustry);
             *      currentIndustry = v.Industry;
             *      tmp2.Add(currentList);
             *      currentList = new List<KeyValuePair<String, double>>();
             *      currentList.Add(new KeyValuePair<String, double>(v.Date.Substring(0, 10), v.Value));
             *      currentIndustry = v.Industry;
             *  }
             *  else
             *      currentList.Add(new KeyValuePair<String, double>(v.Date.Substring(0, 10), v.Value));
             * }
             * tmp2.Add(currentList);
             * industriesName.Add(currentIndustry);
             *
             * for (int i = 0; i < tmp2.Count; i++)
             * {
             *  tmp2[i] = GetfinDeMois(tmp2[i]);
             *  tmp2[i] = GetLastDates(tmp2[i], 12);
             * }
             *
             * RadObservableCollection<CharSerie> res = new RadObservableCollection<CharSerie>();
             *
             * for (int i = 0; i < tmp2.Count; i++)
             * {
             *  CharSerie serie = new CharSerie();
             *  serie.Label = industriesName[i];
             *  serie.Data = new RadObservableCollection<ChartPoint>();
             *
             *  foreach (var v in tmp2[i])
             *      serie.Data.Add(new ChartPoint(v.Key, v.Value, industriesName[i]));
             *
             *  res.Add(serie);
             * }
             *
             * return res;
             */
        }