Пример #1
0
        public string AllGoalsByMonthNet()
        {
            var now = DateTime.Now;
            var currentMonth = new DateTime(now.Year, now.Month, 1);
            var startDate = currentMonth.AddYears(-1);

            var highchart = new Highcharts("AllGoalsMonth");
            var chart = new Chart()
                {
                    Type = ChartTypes.Column
                };
            highchart.InitChart(chart);
            highchart.SetTitle(new Title() {Text = "Goals by Month"});
            var yaxis = new YAxis {Max = 2};
            highchart.SetYAxis(yaxis);
            var series = new Series {Name = "Steps"};
            var xaxis = new XAxis();
            var categories = new List<string>();
            var data = new List<object>();
            for (var i = startDate; i <= currentMonth; i = i.AddMonths(1))
            {
                categories.Add(i.Month.ToString() + "-" + i.Year.ToString());
                data.Add(pedometerCalcService.MonthPct(i.Month, i.Year));
            }
            xaxis.Categories = categories.ToArray();
            series.Data = new Data(data.ToArray());
            highchart.SetXAxis(xaxis);
            highchart.SetSeries(series);

            return highchart.ToHtmlString();
        }
Пример #2
0
        public ActionResult CoinsCompare(String coins)
        {
            Series[] series = new Series[coins.Split(',').Length];
            XAxis[] xAxises = new XAxis[coins.Split(',').Length];

            for (int i = 0; i < coins.Split(',').Length; i++ )
            {
                string coinId = coins.Split(',')[i];

                var coin = CoinManager.GetCoin(Guid.Parse(coinId));
                var coinDealHistories = CoinManager.GetCoinDealHistories(coin);

                String[] dealDates = new String[coinDealHistories.Count];
                String[] dealPrices = new String[coinDealHistories.Count];
                for (int j = 0; j < dealDates.Length; j++)
                {
                    dealDates[j] = coinDealHistories[j].DealDate.ToString("yyyy-MM-dd");
                    dealPrices[j] = coinDealHistories[j].DealPrice.ToString();
                }

                series[i] = new Series
                {
                    Name = coin.Name + "," + coin.AppraisalInstitute + "," + coin.AppraisalScore,
                    Data = new Data(dealPrices),
                    XAxis = i
                };
                xAxises[i] = new XAxis { Title = new XAxisTitle { Text = "拍卖日期" }, Categories = dealDates };
            }

            DotNet.Highcharts.Highcharts coinHistoryDealChart =
                new DotNet.Highcharts.Highcharts("CoinHistoryDealChart")
                .SetTitle(new Title { Text = "拍卖价格波动表" })
                .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "拍卖价格" } })
                .SetXAxis(xAxises)
                .SetSeries(series);

            CoinViewModel coinView = new CoinViewModel();
            coinView.coinHistoryDealChart = coinHistoryDealChart;

            return View(coinView);
        }
 public Highcharts SetXAxis(XAxis[] xAxisArray)
 {
     _XAxisArray = xAxisArray;
     return this;
 }
 /// <summary>
 /// The X axis or category axis. Normally this is the horizontal axis, though if the chart is inverted this is the vertical axis. 
 /// In case of multiple axes, the xAxis node is an array of configuration objects.
 /// </summary>
 /// <param name="xAxis"></param>
 /// <returns></returns>
 public Highcharts SetXAxis(XAxis xAxis)
 {
     _XAxis = xAxis;
     return this;
 }
        private DotNet.Highcharts.Highcharts GetChart(Series[] series, DataEnum data)
        {
            Chart chart = null;
            XAxis xAxis = null;
            PlotOptions options = null;
            switch (data)
            {
                case DataEnum.random_points:
                    xAxis = new XAxis { Categories = new[] { "50", "100", "500", "1k", "5k", "10k", "50k", "100k", "500k", "1M", "2M", "3M", "4M", "5M" } };
                    options = new PlotOptions();
                    chart = new Chart();
                    break;
                case DataEnum.countries:
                    xAxis = new XAxis { Categories = series.Select(t => t.Name).ToArray() };
                    options = new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } };
                    chart = new Chart { DefaultSeriesType = ChartTypes.Column };

                    // ReSharper disable once PossibleNullReferenceException
                    var results = new object[series.Length];
                    for (int i = 0; i < series.Length; i++)
                        results[i] = series.FirstOrDefault(x => x.Name.Equals(series[i].Name)).Data.ArrayData[0];
                    series = new[]{ new Series{ Name = data.ToString(), Data = new Data(results)} };

                    break;
            }

            return new DotNet.Highcharts.Highcharts("chart")
                .InitChart(chart)
                .SetTitle(new Title{ Text = "Comparison result" })
                .SetXAxis(xAxis)
                .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Time (ms)" }, })
                .SetSeries(series)
                .SetPlotOptions(options);
        }
Пример #6
0
 public ActionResult _SingleLine()
 {
     Series series = new Series
     {
         Data = new Data(new object[] { 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4 })
     };
     XAxis xaxis = new XAxis
     {
         Categories = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
     };
     Highcharts chart = new Highcharts("chart_single_line");
     chart.SetXAxis(xaxis);
     chart.SetSeries(series);
     return PartialView(new SmartCity.Models.Global.HighchartModel { highChart=chart });
 }
Пример #7
0
        private void GetAreaChart()
        {
            DashboardViewModel dashboard = new DashboardViewModel();
            dashboard.ViewModelEvent += dashboard_ViewModelEvent;

            // Get statistics
            List<Dictionary<string, object>> values = dashboard.GetAreaChart();

            if (values != null)
            {
                Highcharts areaChart = new Highcharts("areaChart");
                areaChart.InitChart(new Chart()
                {
                    DefaultSeriesType = ChartTypes.Area,
                    BackgroundColor = new DotNet.Highcharts.Helpers.BackColorOrGradient(Color.Transparent),
                    Height = 300
                });
                areaChart.SetPlotOptions(new PlotOptions()
                {
                    Series = new PlotOptionsSeries()
                    {
                        ConnectNulls = true,
                        ConnectEnds = true
                    }
                });
                areaChart.SetLegend(new DotNet.Highcharts.Options.Legend()
                {
                    Align = DotNet.Highcharts.Enums.HorizontalAligns.Center,
                    Layout = DotNet.Highcharts.Enums.Layouts.Horizontal,
                    VerticalAlign = DotNet.Highcharts.Enums.VerticalAligns.Bottom,
                    BorderWidth = 0
                });
                areaChart.SetCredits(new DotNet.Highcharts.Options.Credits() { Enabled = false });
                areaChart.SetTitle(new DotNet.Highcharts.Options.Title() { Text = "" });

                YAxis yAxis = new YAxis();
                yAxis.Title = new DotNet.Highcharts.Options.YAxisTitle() { Text = "" };
                yAxis.Min = 0;

                XAxis xAxis = new XAxis();
                xAxis.Categories = values[0].Keys.ToArray();

                List<Series> seriesCollection = new List<Series>();

                Series seriesUsers = new Series();
                seriesUsers.Data = new DotNet.Highcharts.Helpers.Data(values[0].Values.ToArray());
                seriesUsers.Name = "Users";
                seriesCollection.Add(seriesUsers);

                Series seriesMailbox = new Series();
                seriesMailbox.Data = new DotNet.Highcharts.Helpers.Data(values[1].Values.ToArray());
                seriesMailbox.Name = "Mailbox";
                seriesCollection.Add(seriesMailbox);

                if (StaticSettings.CitrixEnabled)
                {
                    Series seriesCitrix = new Series();
                    seriesCitrix.Data = new DotNet.Highcharts.Helpers.Data(values[2].Values.ToArray());
                    seriesCitrix.Name = "Citrix";
                    seriesCollection.Add(seriesCitrix);
                }

                areaChart.SetXAxis(xAxis);
                areaChart.SetYAxis(yAxis);
                areaChart.SetSeries(seriesCollection.ToArray());

                litAreaChart.Text = areaChart.ToHtmlString();
            }
            else
                litAreaChart.Text = "Error populating chart.";
        }