public JsonResult ServerLineChartsData()
        {
            string[] _months = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };

            List <ChartSerieViewModel> series = new List <ChartSerieViewModel>();

            for (int i = 0; i < 5; i++)
            {
                decimal   d      = 2 + i;
                decimal[] _datas = { d, 6.90m, 9.50m, 14.50m, 18.20m, 4.56m, d, 26.50m, 23.30m, 18.30m, 13.90m, d };

                ChartSerieViewModel lineChartSerieViewModel = new ChartSerieViewModel();
                lineChartSerieViewModel.SeriesName  = "Tokyo : " + i;
                lineChartSerieViewModel.SeriesDatas = _datas;

                series.Add(lineChartSerieViewModel);
            }

            var model = new LineChartViewModel();

            model.TitleText          = "Monthly Average Temperature";
            model.SubTitleText       = "Source: WorldClimate.com";
            model.XAxisCategories    = _months;
            model.YAxisTitleText     = "Temperature (°C)";
            model.TooltipValueSuffix = "°C";
            model.Series             = series.ToArray();

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
        public JsonResult ServerBarChartsData()
        {
            string[] _categories = { "Apples", "Oranges", "Pears", "Grapes", "Bananas" };

            List <ChartSerieViewModel> series = new List <ChartSerieViewModel>();

            for (int i = 0; i < 3; i++)
            {
                decimal   d      = 2 + i;
                decimal[] _datas = { d, 3, 4, 7, d };

                ChartSerieViewModel lineChartSerieViewModel = new ChartSerieViewModel();
                lineChartSerieViewModel.SeriesName  = "John : " + i;
                lineChartSerieViewModel.SeriesDatas = _datas;

                series.Add(lineChartSerieViewModel);
            }

            var model = new BarChartViewModel();

            model.TitleText       = "Stacked column chart";
            model.XAxisCategories = _categories;
            model.YAxisTitleText  = "Total fruit consumption";
            model.Series          = series.ToArray();

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
        private ChartSerieViewModel[] CreateEntityFrameworkSensorValuesSeries(long shipId, List <ESensor> sensors, DateTime rangeBegin, DateTime rangeEnd)
        {
            using (var context = new PrototypeContext())
            {
                ChartSerieViewModel[] series = new ChartSerieViewModel[sensors.Count];
                for (int i = 0; i < series.Length; i++)
                {
                    var sensor       = sensors[i];
                    var sensorValues = context.SensorValuesRows.Where(x => x.ShipId == shipId &&
                                                                      x.ImportTimestamp >= rangeBegin &&
                                                                      x.ImportTimestamp <= rangeEnd)
                                       .ToList();

                    var sensorValuesAsChartDataPoints = sensorValues.Select(sv => new ChartDataPointViewModel()
                    {
                        x = sv.RowTimestamp,
                        y = sv.GetValue(sensor)
                    });

                    var serieForThisSensor = new ChartSerieViewModel()
                    {
                        name = sensor.ToString(), data = sensorValuesAsChartDataPoints.ToArray()
                    };
                    series[i] = serieForThisSensor;
                }

                return(series);
            }
        }
        private ChartSerieViewModel[] CreateSeriesObjects(List <List <RedisKpiValue> > kpiValuesPerKpi)
        {
            var chartSerieViewModels = new ChartSerieViewModel[kpiValuesPerKpi.Count];

            for (int i = 0; i < kpiValuesPerKpi.Count; i++)  //(var kpiValues in kpiValuesPerKpi)
            {
                RedisKpiValue[] kpiValues = kpiValuesPerKpi[i].ToArray();

                chartSerieViewModels[i] = new ChartSerieViewModel()
                {
                    name = "",
                    data = kpiValues.Select(v => new ChartDataPointViewModel()
                    {
                        x = v.Date.ToUnixMilliTs(), y = v.Value
                    })
                           .ToArray()
                };
            }
            return(chartSerieViewModels);
        }
        private ChartSerieViewModel[] CreateRedisSensorValuesSeries(long shipId, List <ESensor> sensors, DateTime rangeBegin, DateTime rangeEnd)
        {
            List <RedisSensorValuesRow> sensorValuesWithinRange =
                _sensorValuesRowRetriever.GetRange(shipId, rangeBegin.ToUnixMilliTs(), rangeEnd.ToUnixMilliTs());

            ChartSerieViewModel[] series = new ChartSerieViewModel[sensors.Count];
            for (int i = 0; i < series.Length; i++)
            {
                var sensor = sensors[i];
                var sensorValuesAsChartDataPoints = sensorValuesWithinRange.Select(sv => new ChartDataPointViewModel()
                {
                    x = sv.RowTimestamp,
                    y = sv.SensorValues[sensor]
                }).ToArray();

                series[i] = new ChartSerieViewModel()
                {
                    name = sensor.ToString(),
                    data = sensorValuesAsChartDataPoints
                };
            }
            return(series);
        }