/// <summary>
        /// Given the json blob name, this helper will return a line chart for the data in it.
        /// </summary>
        /// <param name="blobNames"></param>
        /// <param name="title">The title for the chart. If unspecified, the blobName will be used.</param>
        /// <param name="dataPointCount">The number of datapoints to show in the graph.</param>
        /// <param name="chartDimensions">The width/height of the chart</param>
        /// <returns></returns>
        public static DotNet.Highcharts.Highcharts GetLineChartFromBlobName(string[] blobNames, string title = null, int dataPointCount = 6, int chartDimensions = 300)
        {
            if (string.IsNullOrEmpty(title))
            {
                title = blobNames[0];
            }
            List <DotNet.Highcharts.Options.Series> seriesSet = new List <DotNet.Highcharts.Options.Series>();
            List <string> xValues = new List <string>();

            foreach (string blobName in blobNames)
            {
                List <Object> yValues = new List <Object>();
                BlobStorageService.GetJsonDataFromBlob(blobName + ".json", out xValues, out yValues);
                //Retrive only the last N data points (To do : need to update this to retrieve the data for last N hours intead of N data points).
                if (xValues.Count > dataPointCount)
                {
                    xValues.RemoveRange(0, xValues.Count - dataPointCount);
                    yValues.RemoveRange(0, yValues.Count - dataPointCount);
                }

                seriesSet.Add(new DotNet.Highcharts.Options.Series
                {
                    Data = new Data(yValues.ToArray()),
                    Name = GetSanitizedTitleFromBlobName(blobName)
                });
            }

            DotNet.Highcharts.Highcharts chart = ChartingUtilities.GetLineChart(seriesSet, xValues, title, chartDimensions);
            return(chart);
        }
Example #2
0
        public PartialViewResult GetCompanyStatusChart()
        {
            SimpleChartModel chartModel = new SimpleChartModel();

            chartModel.ChartType   = DotNet.Highcharts.Enums.ChartTypes.Pie;
            chartModel.ContainerId = "companyStatusChart";
            chartModel.Title       = "客户状态";

            YSeries series = new YSeries();

            series.YName = "数量";

            chartModel.ValueSuffix = "个";
            //读取公司的表,group by 销售名
            OtaCrmModel db = new OtaCrmModel();
            var         ss = from i in db.OtaCompany
                             where i.BusinessStatus != null
                             group i by i.BusinessStatus
                             into g
                             select new { count = g.Count(), businessStatus = g.Key };
            List <object[]> pieDataList = new List <object[]>();

            foreach (var item in ss)
            {
                object[] pieData = new object[] { item.businessStatus, item.count };
                pieDataList.Add(pieData);
            }
            chartModel.pieDataList = pieDataList;

            DotNet.Highcharts.Highcharts chart = GetPieChart(chartModel);
            return(PartialView("_PartialChartView", chart));
        }
Example #3
0
        public ActionResult IndexPost()
        {
            var random    = new Random();
            var viewModel = new ComparisonViewModel(null);

            TryUpdateModel(viewModel);

            Series[] series;

            if (!viewModel.AllIndexes)
            {
                series = new[]
                {
                    this.GetSeries(viewModel.Query, viewModel.FirstIndex, random, viewModel.NumberOfQueries, viewModel.Data),
                    this.GetSeries(viewModel.Query, viewModel.SecondIndex, random, viewModel.NumberOfQueries, viewModel.Data),
                };
            }
            else
            {
                series = Enum.GetValues(typeof(IndexEnum)).OfType <IndexEnum>()
                         .Select(t => this.GetSeries(viewModel.Query, t, random, viewModel.NumberOfQueries, viewModel.Data)).ToArray();
            }

            DotNet.Highcharts.Highcharts chart = this.GetChart(series, viewModel.Data);

            viewModel.Chart = chart;

            var report = (Session["report"] as List <ReportViewModel>) ?? new List <ReportViewModel>();

            report.Add(new ReportViewModel(viewModel, series));
            Session["report"] = report;

            return(View(viewModel));
        }
        public static DotNet.Highcharts.Highcharts GetBarChart(List<string> xValues, List<Object> yValues, string YAxisTitle, string chartTitle)
        {
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts(chartTitle)
            .InitChart(new DotNet.Highcharts.Options.Chart { DefaultSeriesType = ChartTypes.Column })
            .SetPlotOptions(new PlotOptions
            {
                Column = new PlotOptionsColumn
                {
                    Stacking = Stackings.Normal,
                }
            });

            chart.SetXAxis(new XAxis
            {
                Categories = xValues.ToArray(),

            });
            chart.SetSeries(new DotNet.Highcharts.Options.Series
            {
                Data = new Data(yValues.ToArray()),
                Name = YAxisTitle
            });

            chart.SetTitle(new DotNet.Highcharts.Options.Title { Text = chartTitle });
            return chart;
        }
Example #5
0
        public PartialViewResult GetCompanyCountChart()
        {
            SimpleChartModel chartModel = new SimpleChartModel();

            chartModel.Height      = 500;
            chartModel.ContainerId = "companyCountChart";
            chartModel.Title       = "客户数量";
            chartModel.SeriesList  = new List <YSeries>();

            YSeries series = new YSeries();

            series.YSeriesList = new List <object>();
            series.YName       = "数量";

            chartModel.YTitle      = DateTime.Today.ToString("yyyy-MM-dd");
            chartModel.ValueSuffix = "个";
            //读取公司的表,group by 销售名
            OtaCrmModel db = new OtaCrmModel();
            var         ss = from i in db.OtaCompany
                             group i by i.SalesUserName
                             into g
                             select new { count = g.Count(), userName = g.Key };

            foreach (var item in ss)
            {
                chartModel.XList.Add(item.userName);
                series.YSeriesList.Add(item.count);
            }
            chartModel.SeriesList.Add(series);

            DotNet.Highcharts.Highcharts chart = GetChart(chartModel);
            return(PartialView("_PartialChartView", chart));
        }
Example #6
0
        public ActionResult FundsChart()
        {
            var xDates = fundList.Select(i => i.fundDate.ToShortDateString()).ToArray();


            var doublevals = fundList.Select(i => i.value).ToArray();

            object[] serie = doublevals.Cast <object>().ToArray();

            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("Fundusz")
                                                 .SetXAxis(new XAxis
            {
                Categories   = xDates,
                TickInterval = 50,
                Labels       = new XAxisLabels
                {
                    Align    = HorizontalAligns.Right,
                    Rotation = -90
                }
            }).SetTitle(new Title
            {
                Text = "Fundusz"
            })
                                                 .SetSeries(new Series
            {
                Name = "Wartość",
                Data = new Data(serie)
            });

            return(View(chart));
        }
Example #7
0
 public void Add(string key, string title, DotNet.Highcharts.Highcharts chart)
 {
     queue.Add(new QueueItem()
     {
         Key = key, Title = title, Data = chart, Type = QueueItem.types.chart
     });
 }
        public static DotNet.Highcharts.Highcharts GetBarChart(List <string> xValues, List <Object> yValues, string YAxisTitle, string chartTitle)
        {
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts(chartTitle)
                                                 .InitChart(new DotNet.Highcharts.Options.Chart {
                DefaultSeriesType = ChartTypes.Column
            })
                                                 .SetPlotOptions(new PlotOptions
            {
                Column = new PlotOptionsColumn
                {
                    Stacking = Stackings.Normal,
                }
            });

            chart.SetXAxis(new XAxis
            {
                Categories = xValues.ToArray(),
            });
            chart.SetSeries(new DotNet.Highcharts.Options.Series
            {
                Data = new Data(yValues.ToArray()),
                Name = YAxisTitle
            });

            chart.SetTitle(new DotNet.Highcharts.Options.Title {
                Text = chartTitle
            });
            return(chart);
        }
Example #9
0
        /// <summary>
        /// Returns a bar chart for a given set of values.
        /// </summary>
        /// <param name="seriesSet"></param>
        /// <param name="xValues"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static DotNet.Highcharts.Highcharts GetBarChart(List <DotNet.Highcharts.Options.Series> seriesSet, List <string> xValues, string title)
        {
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts(title);
            chart.InitChart(new Chart
            {
                Height            = 320,
                Width             = 320,
                DefaultSeriesType = ChartTypes.Column
            });

            chart.SetXAxis(new XAxis
            {
                Categories = xValues.ToArray()
            });

            chart.SetLegend(new Legend {
                Enabled = false
            });
            chart.SetSeries(seriesSet.ToArray());

            chart.SetTitle(new DotNet.Highcharts.Options.Title {
                Text = title.Replace("_", " ")
            });

            return(chart);
        }
        public PartialViewResult GetChart()
        {
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart");

            //初始化
            DotNet.Highcharts.Options.Chart chartOption = new DotNet.Highcharts.Options.Chart();
            chartOption.DefaultSeriesType = DotNet.Highcharts.Enums.ChartTypes.Line;
            chartOption.Width             = 400;
            chartOption.Height            = 400;
            chart.InitChart(chartOption);

            //设置标题
            DotNet.Highcharts.Options.Title title = new DotNet.Highcharts.Options.Title();
            title.Align = DotNet.Highcharts.Enums.HorizontalAligns.Center;
            title.Text  = "图表";
            chart.SetTitle(title);

            //提示
            DotNet.Highcharts.Options.Tooltip tooltip = new DotNet.Highcharts.Options.Tooltip();
            tooltip.ValueSuffix = "摄氏度";
            chart.SetTooltip(tooltip);

            DotNet.Highcharts.Options.PlotOptions plotOptions = new DotNet.Highcharts.Options.PlotOptions();
            plotOptions.Bar                    = new DotNet.Highcharts.Options.PlotOptionsBar();
            plotOptions.Bar.DataLabels         = new DotNet.Highcharts.Options.PlotOptionsBarDataLabels();
            plotOptions.Bar.DataLabels.Enabled = true;
            chart.SetPlotOptions(plotOptions);

            //横坐标
            DotNet.Highcharts.Options.XAxis xs = new DotNet.Highcharts.Options.XAxis {
                Categories = new[] { "jan", "feb" }
            };
            List <string> cList = new List <string>();

            cList.Add("jan");
            cList.Add("feb");
            xs.Categories = cList.ToArray();
            xs.Title      = new DotNet.Highcharts.Options.XAxisTitle();
            xs.Title.Text = "月份";
            chart.SetXAxis(xs);

            //纵坐标
            DotNet.Highcharts.Options.YAxis ys = new DotNet.Highcharts.Options.YAxis();
            ys.Title      = new DotNet.Highcharts.Options.YAxisTitle();
            ys.Title.Text = "温度";
            chart.SetYAxis(ys);

            //设置表现值
            DotNet.Highcharts.Options.Series ss = new DotNet.Highcharts.Options.Series();
            List <object> oList = new List <object>();

            oList.Add(29);
            oList.Add(33);
            ss.Data = new DotNet.Highcharts.Helpers.Data(oList.ToArray());
            ss.Name = "温度";
            chart.SetSeries(ss);

            return(PartialView("_PartialChartView", chart));
        }
Example #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SalesOrderDataAccess db  = new SalesOrderDataAccess();
            var           orders     = db.GetAllOrders();
            var           customers  = orders.Select(order => order.CustomerName).ToArray();
            var           netAmount  = orders.Select(order => order.TotalSum).ToList();
            var           netTax     = orders.Select(order => order.Tax).ToList();
            List <object> amount     = new List <object>();
            List <object> tax        = new List <object>();
            List <object> categories = new List <object>();


            netAmount.ForEach(delegate(decimal net)
            {
                amount.Add((object)net);
            });

            netTax.ForEach(delegate(decimal net)
            {
                tax.Add((object)net);
            });


            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
                                                 .InitChart(new Chart
            {
                Height            = 300,
                Width             = 600,
                DefaultSeriesType = ChartTypes.Line,
                ClassName         = "chart"
            })
                                                 .SetTitle(new Title
            {
                Text = "Sales Orders By Company",
                X    = -20
            })
                                                 .SetXAxis(new XAxis
            {
                Categories = customers
            })
                                                 .SetYAxis(new YAxis
            {
                Title = new YAxisTitle {
                    Text = "In Dollars"
                },
            })
                                                 .SetSeries(new Series[]
            {
                new Series {
                    Name = "Amount", Data = new Data(amount.ToArray())
                },
                new Series {
                    Name = "Tax", Data = new Data(tax.ToArray())
                },
            });

            ltrChart.Text = chart.ToHtmlString();
        }
Example #12
0
        public void SetGraph()
        {
            List <cstPackingTime> lsShipInfo = Obj.call.GetPackingTimeQuantity();

            String[] Sarray = new string[lsShipInfo.Count];
            object[] Times  = new object[lsShipInfo.Count];
            for (int i = 0; i <= lsShipInfo.Count - 1; i++)
            {
                Sarray[i] = lsShipInfo[i].ShippingNumber.ToString();
                String   s      = lsShipInfo[i].TimeSpend.ToString();
                String[] t      = s.Split(new char[] { ':', 'H', 'S', 'M' });
                String   timess = t[2].Trim() + "." + t[4].Trim();
                Decimal  D      = Convert.ToDecimal(timess);
                Times[i] = Math.Round(D, 2);
            }

            #region Graph

            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
                                                 .InitChart(new Chart
            {
                Type = ChartTypes.Line
            })
                                                 .SetTitle(new Title
            {
                Text = "Shipment packing Time"
            })
                                                 .SetXAxis(new XAxis
            {
                Categories = Sarray,
                Title      = new XAxisTitle {
                    Text = "Shipment Numbers"
                },
                Min = 10
            })
                                                 .SetLegend(new Legend
            {
                VerticalAlign = VerticalAligns.Bottom
            })

                                                 .SetYAxis(new YAxis
            {
                Title = new YAxisTitle {
                    Text = "Time in (Min.Sec)"
                }
            })
                                                 .SetSeries(new Series
            {
                Data = new Data(Times),
                Name = "Time Taken"
            });

            #endregion

            ltrChart.Text = chart.ToHtmlString();
        }
Example #13
0
        public DotNet.Highcharts.Highcharts GetChart(SimpleChartModel chartModel)
        {
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts(chartModel.ContainerId);

            //初始化
            DotNet.Highcharts.Options.Chart chartOption = new DotNet.Highcharts.Options.Chart();
            chartOption.DefaultSeriesType = chartModel.ChartType;
            chartOption.Width             = chartModel.Width;
            chartOption.Height            = chartModel.Height;
            chart.InitChart(chartOption);

            //设置标题
            DotNet.Highcharts.Options.Title title = new DotNet.Highcharts.Options.Title();
            title.Align = DotNet.Highcharts.Enums.HorizontalAligns.Center;
            title.Text  = chartModel.Title;
            chart.SetTitle(title);

            //提示
            DotNet.Highcharts.Options.Tooltip tooltip = new DotNet.Highcharts.Options.Tooltip();
            tooltip.ValueSuffix = chartModel.ValueSuffix;
            chart.SetTooltip(tooltip);

            DotNet.Highcharts.Options.PlotOptions plotOptions = new DotNet.Highcharts.Options.PlotOptions();
            plotOptions.Bar                    = new DotNet.Highcharts.Options.PlotOptionsBar();
            plotOptions.Bar.DataLabels         = new DotNet.Highcharts.Options.PlotOptionsBarDataLabels();
            plotOptions.Bar.DataLabels.Enabled = true;
            chart.SetPlotOptions(plotOptions);

            //横坐标
            DotNet.Highcharts.Options.XAxis xs = new DotNet.Highcharts.Options.XAxis();
            xs.Categories = chartModel.XList.ToArray();
            xs.Title      = new DotNet.Highcharts.Options.XAxisTitle();
            xs.Title.Text = chartModel.XTitle;
            chart.SetXAxis(xs);

            //纵坐标
            DotNet.Highcharts.Options.YAxis ys = new DotNet.Highcharts.Options.YAxis();
            ys.Title      = new DotNet.Highcharts.Options.YAxisTitle();
            ys.Title.Text = chartModel.YTitle;
            chart.SetYAxis(ys);

            //设置表现值
            List <DotNet.Highcharts.Options.Series> ssList = new List <DotNet.Highcharts.Options.Series>();

            foreach (YSeries yserires in chartModel.SeriesList)
            {
                DotNet.Highcharts.Options.Series ss = new DotNet.Highcharts.Options.Series();
                ss.Data = new DotNet.Highcharts.Helpers.Data(yserires.YSeriesList.ToArray());
                ss.Name = yserires.YName;
                ssList.Add(ss);
            }
            chart.SetSeries(ssList.ToArray());

            return(chart);
        }
 public static DotNet.Highcharts.Highcharts GetPieChart(Series seriesSet, string title)
 {
     DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts(title);
     chart.InitChart(new Chart
     {
         Height = 250,
         Width = 250,
         DefaultSeriesType = ChartTypes.Pie
     });          
     chart.SetSeries(seriesSet);
     chart.SetTitle(new DotNet.Highcharts.Options.Title { Text = title });
     return chart;
 }
Example #15
0
        public void GetChart(List <FundValue> datesList, List <decimal> fund, List <decimal> deposit)
        {
            ChartDataBuilder cdb = new ChartDataBuilder();

            cdb.ProcessData(datesList.Select(x => x.fundDate).ToList(), fund, deposit);
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("Porownanie");
            Series s1 = new Series
            {
                Data = cdb.FundData,
                Name = "Fundusz"
            };
            Series s2 = new Series
            {
                Data = cdb.DepositData,
                Name = "Lokata"
            };

            Series[] serie = new Series[2];
            serie[0] = s1;
            serie[1] = s2;
            var startandstop = GetValidDate(datesList);
            int interval;

            if (startandstop.Count / 80 > 1)
            {
                interval = startandstop.Count / 80;
            }
            else
            {
                interval = 1;
            }

            var xlabels = cdb.ChartData.Select(x => x.Date.ToShortDateString()).ToArray();

            chart.SetXAxis(new XAxis
            {
                Categories   = xlabels,
                TickInterval = interval,
                Labels       = new XAxisLabels
                {
                    Align    = HorizontalAligns.Right,
                    Rotation = -90
                }
            }).SetSeries(serie);
            chart.SetTitle(new Title
            {
                Text = "Porównanie lokaty i funduszu"
            });

            Chart = chart;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            SalesOrderDataAccess db = new SalesOrderDataAccess();
            var orders = db.GetAllOrders();
            var customers = orders.Select(order => order.CustomerName).ToArray();
            var netAmount = orders.Select(order => order.TotalSum).ToList();
            var netTax = orders.Select(order => order.Tax).ToList();
            List<object> amount = new List<object>();
            List<object> tax = new List<object>();
            List<object> categories = new List<object>();

            netAmount.ForEach(delegate(decimal net)
            {
                amount.Add((object)net);
            });

            netTax.ForEach(delegate(decimal net)
            {
                tax.Add((object)net);
            });

            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
            .InitChart(new Chart
            {
                Height = 300,
                Width = 600,
                DefaultSeriesType = ChartTypes.Line,
                ClassName = "chart"
            })
            .SetTitle(new Title
                          {
                              Text = "Sales Orders By Company",
                              X = -20
                          })
            .SetXAxis(new XAxis
            {
                Categories = customers
            })
            .SetYAxis(new YAxis
            {
                Title = new YAxisTitle { Text = "In Dollars" },
            })
            .SetSeries(new Series[]
            {
                new Series { Name = "Amount", Data = new Data(amount.ToArray()) },
                new Series { Name = "Tax", Data = new Data(tax.ToArray()) },
            });

            ltrChart.Text = chart.ToHtmlString();
        }
Example #17
0
        // GET: MonthReportsViewModels
        public ActionResult Index3()
        {
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
                                                 .SetXAxis(new XAxis
            {
                Categories = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
            })
                                                 .SetSeries(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 })
            });

            return(View(chart));
        }
Example #18
0
        public ActionResult Index()
        {
            var random = new Random();

            var series = new[]
            {
                this.GetSeries(QueryEnum.FindNearestNeighbours, IndexEnum.gist, random, 4, DataEnum.countries),
                this.GetSeries(QueryEnum.FindNearestNeighbours, IndexEnum.rtree, random, 4, DataEnum.countries),
            };

            DotNet.Highcharts.Highcharts chart = this.GetChart(series, DataEnum.countries);

            return(View(new ComparisonViewModel(chart)));
        }
 public static DotNet.Highcharts.Highcharts GetPieChart(Series seriesSet, string title)
 {
     DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts(title);
     chart.InitChart(new Chart
     {
         Height            = 250,
         Width             = 250,
         DefaultSeriesType = ChartTypes.Pie
     });
     chart.SetSeries(seriesSet);
     chart.SetTitle(new DotNet.Highcharts.Options.Title {
         Text = title
     });
     return(chart);
 }
Example #20
0
        public PartialViewResult Vote(int pollID, int option)
        {
            // default userId to 1 for now
            Vote vote = new Vote()
            {
                PollID    = pollID,
                ChoiceID  = option,
                DateVoted = DateTime.Now,
                UserID    = 2
            };

            repository.AddVote(vote);

            // get the count of all votes for the poll
            Dictionary <string, int> voteDict = new Dictionary <string, int>();
            Poll poll = repository.Poll(pollID);

            foreach (var opt in poll.Options)
            {
                int count = repository.GetVotes(pollID, opt.OptionID);
                voteDict.Add(opt.Text.Replace("'", "\\\'"), count);
            }

            string[] keys   = voteDict.OrderByDescending(x => x.Value).Select(x => x.Key).ToArray();
            int[]    values = voteDict.OrderByDescending(x => x.Value).Select(x => x.Value).ToArray();
            // now we have the votes for each option
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
                                                 .SetTitle(new DotNet.Highcharts.Options.Title {
                Text = poll.PollQuestion
            })
                                                 .SetXAxis(new DotNet.Highcharts.Options.XAxis
            {
                Categories = keys
            })
                                                 .SetSeries(new DotNet.Highcharts.Options.Series
            {
                Type = DotNet.Highcharts.Enums.ChartTypes.Bar,
                Name = "Votes",
                Data = new DotNet.Highcharts.Helpers.Data(Array.ConvertAll(values, x => (object)x))
            });
            //chart.SetTooltip(new DotNet.Highcharts.Options.Tooltip
            //{
            //    UseHTML = true,
            //    HeaderFormat = "<span>Those who voted</span><table>",
            //    PointFormat = "<tr><td style"
            //});
            return(PartialView("_PollResults", chart));
        }
        public void SetGraph()
        {
            List <cstStationToatlPacked> _lsTotalPacekedPerStation = Obj.Rcall.GetStationTotalPaked();

            gvStationInfo.DataSource = _lsTotalPacekedPerStation.ToList();
            gvStationInfo.DataBind();

            Series[] sr = new Series[_lsTotalPacekedPerStation.Count];

            // chart Veriables
            String[] StationNames = new string[_lsTotalPacekedPerStation.Count];

            for (int i = 0; i < _lsTotalPacekedPerStation.Count; i++)
            {
                sr[i] = new Series {
                    Name = _lsTotalPacekedPerStation[i].StationName, Data = new Data(new object[] { _lsTotalPacekedPerStation[i].TotalPacked, _lsTotalPacekedPerStation[i].PartiallyPacked })
                };
            }

            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("Chart")
                                                 .InitChart(new DotNet.Highcharts.Options.Chart
            {
                Type            = ChartTypes.Bar,
                BackgroundColor = new BackColorOrGradient(System.Drawing.Color.White),
                Height          = 400,
            })
                                                 .SetXAxis(new DotNet.Highcharts.Options.XAxis
            {
                Categories = (new string[] { "Packed", "Partially Packed" }),
                Title      = new XAxisTitle {
                    Text = "Packi", Style = "fontSize: '15px', fontFamily: 'Verdana', color: 'Black'"
                }
            })
                                                 .SetTitle(new Title
            {
                Text  = "Station Information ",
                Style = "fontSize: '30px',fontFamily: 'Verdana', fontBold: 'true', color: 'Black' "
            })
                                                 .SetYAxis(new YAxis
            {
                Title = new YAxisTitle {
                    Text = "Staion Names", Style = "fontSize: '15px', fontFamily: 'Verdana', color: 'Black'"
                },
            })
                                                 .SetSeries(sr);

            ltrChart.Text = chart.ToHtmlString();
        }
Example #22
0
        static void Main(string[] args)
        {
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
                                                 .SetXAxis(new XAxis
            {
                Categories = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
            })
                                                 .SetSeries(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 })
            });

            string text = chart.ToHtmlString();

            System.IO.File.AppendAllText(@"C:\Users\Ben\Desktop\chart.html", text);
        }
Example #23
0
        protected void Render_Chart(string name)
        {
            string[] created_time = created_time1.Select(a => a).ToArray();
            object[] _like        = Array.ConvertAll(likes, x => (object)x);
            object[] _comments    = Array.ConvertAll(Comments, x => (object)x);
            object[] _links       = Array.ConvertAll(link, x => (object)x);
            Array.Reverse(created_time);
            Array.Reverse(_like);
            Array.Reverse(_comments);
            Array.Reverse(link);
            string sear = searchBox.Text;

            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart").InitChart(new Chart {
                ZoomType = ZoomTypes.X, SpacingRight = 20, DefaultSeriesType = ChartTypes.Line
            })

                                                 .SetTitle(new Title
            {
                Text = "Instagram " + " for: " + UserName,
                X    = -20
            })
                                                 .SetSubtitle(new Subtitle
            {
                Text = "Click and drag in the plot area to zoom in ",
                X    = -20
            }).SetXAxis(new XAxis
            {
                Categories = new[] { ConvertToString(created_time) },
                Labels     = new XAxisLabels
                {
                    Step = null
                }
            })
                                                 .SetSeries(new[] {
                new Series {
                    Type = ChartTypes.Spline, Data = new Data(_like), Name = "likes:",
                },
                new Series {
                    Type = ChartTypes.Column, Data = new Data(_comments), Name = "comments:",
                },
            }
                                                            );

            ltChart1.Text     = chart.ToHtmlString();
            ExportCSV.Visible = true;
            Result.Visible    = true;
        }
Example #24
0
        public ActionResult AverageTimeTakenInMsTrendToday()
        {
            List <DotNet.Highcharts.Options.Series> seriesSet = new List <DotNet.Highcharts.Options.Series>();
            List <string> value = new List <string>();
            Dictionary <string, string> dict = BlobStorageService.GetDictFromBlob("IISRequestDetails" + String.Format("{0:MMdd}", DateTime.Now.AddDays(-1)) + ".json");

            if (dict != null)
            {
                List <IISRequestDetails>            requestDetails = new List <IISRequestDetails>();
                Dictionary <string, List <object> > request        = new Dictionary <string, List <object> >();
                foreach (KeyValuePair <string, string> keyValuePair in dict)
                {
                    value.Add(keyValuePair.Key.Substring(0, 2));
                    requestDetails = new JavaScriptSerializer().Deserialize <List <IISRequestDetails> >(keyValuePair.Value);

                    foreach (IISRequestDetails scenarios in requestDetails)
                    {
                        if (scenarios.ScenarioName.Equals("Over all requests"))
                        {
                            continue;
                        }
                        if (request.ContainsKey(scenarios.ScenarioName))
                        {
                            request[scenarios.ScenarioName].Add(scenarios.AvgTimeTakenInMilliSeconds);
                        }
                        else
                        {
                            List <object> Yvalue = new List <object>();
                            Yvalue.Add(scenarios.AvgTimeTakenInMilliSeconds);
                            request.Add(scenarios.ScenarioName, Yvalue);
                        }
                    }
                }

                foreach (KeyValuePair <string, List <object> > each in request)
                {
                    seriesSet.Add(new DotNet.Highcharts.Options.Series
                    {
                        Data = new Data(each.Value.ToArray()),
                        Name = each.Key.Replace(" ", "_")
                    });
                }
            }
            DotNet.Highcharts.Highcharts chart = ChartingUtilities.GetLineChart(seriesSet, value, "TodayAvgTimeInMsTrend", 500);
            return(PartialView("~/Views/Shared/PartialChart.cshtml", chart));
        }
Example #25
0
        public DotNet.Highcharts.Highcharts GetPieChart(SimpleChartModel chartModel)
        {
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts(chartModel.ContainerId);

            //初始化
            DotNet.Highcharts.Options.Chart chartOption = new DotNet.Highcharts.Options.Chart();
            chartOption.DefaultSeriesType = chartModel.ChartType;
            chartOption.Width             = chartModel.Width;
            chartOption.Height            = chartModel.Height;
            chart.InitChart(chartOption);

            //设置标题
            DotNet.Highcharts.Options.Title title = new DotNet.Highcharts.Options.Title();
            title.Align = DotNet.Highcharts.Enums.HorizontalAligns.Center;
            title.Text  = chartModel.Title;
            chart.SetTitle(title);

            //提示
            DotNet.Highcharts.Options.Tooltip tooltip = new DotNet.Highcharts.Options.Tooltip();
            tooltip.ValueSuffix = chartModel.ValueSuffix;
            tooltip.PointFormat = "{point.name}: <b>{point.y}</b>";
            chart.SetTooltip(tooltip);

            //饼图
            DotNet.Highcharts.Options.PlotOptions plotOptions = new DotNet.Highcharts.Options.PlotOptions();
            plotOptions.Pie = new DotNet.Highcharts.Options.PlotOptionsPie();
            plotOptions.Pie.AllowPointSelect   = true;
            plotOptions.Pie.Cursor             = DotNet.Highcharts.Enums.Cursors.Pointer;
            plotOptions.Pie.ShowInLegend       = true;
            plotOptions.Pie.DataLabels         = new DotNet.Highcharts.Options.PlotOptionsPieDataLabels();
            plotOptions.Pie.DataLabels.Enabled = true;
            plotOptions.Pie.DataLabels.Format  = "<b>{point.name}</b>: {point.y}个";
            chart.SetPlotOptions(plotOptions);

            //设置表现值
            List <DotNet.Highcharts.Options.Series> ssList = new List <DotNet.Highcharts.Options.Series>();

            DotNet.Highcharts.Options.Series ss = new DotNet.Highcharts.Options.Series();
            ss.Type = DotNet.Highcharts.Enums.ChartTypes.Pie;
            ss.Name = chartModel.Title;
            ss.Data = new DotNet.Highcharts.Helpers.Data(chartModel.pieDataList.ToArray());
            ssList.Add(ss);
            chart.SetSeries(ssList.ToArray());

            return(chart);
        }
        public static DotNet.Highcharts.Highcharts GetLineChart(List<DotNet.Highcharts.Options.Series> seriesSet, List<string> xValues, string title,int dimensions=300)
        {
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts(title);
            chart.InitChart(new Chart
            {
                Height = dimensions,
                Width = dimensions
            });

            chart.SetXAxis(new XAxis
            {
                Categories = xValues.ToArray()

            });
            chart.SetSeries(seriesSet.ToArray());
            chart.SetTitle(new DotNet.Highcharts.Options.Title { Text = title });
            return chart;
        }
Example #27
0
        public ActionResult FundsChart(string val)
        {
            string[]         dates      = val.Split('-');
            DateTime         startDate  = DateTime.ParseExact(dates[0], "MM/dd/yyyy ", CultureInfo.InvariantCulture);
            DateTime         stopDate   = DateTime.ParseExact(dates[1], " MM/dd/yyyy", CultureInfo.InvariantCulture);
            var              cutList    = from FundVal in fundList where FundVal.fundDate >= startDate && FundVal.fundDate <= stopDate select FundVal;
            List <FundValue> trimList   = cutList.ToList();
            var              xDates     = trimList.Select(i => i.fundDate.ToShortDateString()).ToArray();
            var              doublevals = trimList.Select(i => i.value).ToArray();

            object[] serie = doublevals.Cast <object>().ToArray();
            int      interval;

            if (trimList.Count / 80 > 1)
            {
                interval = trimList.Count / 80;
            }
            else
            {
                interval = 1;
            }

            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("Fundusz")
                                                 .SetXAxis(new XAxis
            {
                Categories   = xDates,
                TickInterval = interval,
                Labels       = new XAxisLabels
                {
                    Align    = HorizontalAligns.Right,
                    Rotation = -90
                }
            }).SetTitle(new Title
            {
                Text = "Fundusz"
            })
                                                 .SetSeries(new Series
            {
                Name = "Wartość",
                Data = new Data(serie)
            });

            return(View(chart));
        }
        public static DotNet.Highcharts.Highcharts GetAreaChart(List<DotNet.Highcharts.Options.Series> seriesSet, List<string> xValues, string title)
        {
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts(title);
            chart.InitChart(new Chart
            {
                Height = 300,
                Width = 300,
                DefaultSeriesType = ChartTypes.Area
            });

            chart.SetXAxis(new XAxis
            {
                Categories = xValues.ToArray()

            });
            chart.SetSeries(seriesSet.ToArray());
            chart.SetTitle(new DotNet.Highcharts.Options.Title { Text = title });
            return chart;
        }
        public static DotNet.Highcharts.Highcharts GetLineChart(List <DotNet.Highcharts.Options.Series> seriesSet, List <string> xValues, string title, int dimensions = 300)
        {
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts(title);
            chart.InitChart(new Chart
            {
                Height = dimensions,
                Width  = dimensions
            });

            chart.SetXAxis(new XAxis
            {
                Categories = xValues.ToArray()
            });
            chart.SetSeries(seriesSet.ToArray());
            chart.SetTitle(new DotNet.Highcharts.Options.Title {
                Text = title
            });
            return(chart);
        }
Example #30
0
        public ActionResult Index2()
        {
            var itemSales = db.salesLineItem.GroupBy(s => s.item).Select(s => new { item = s.Key.name, sum = s.Sum(b => b.quantity) });

            string[] namesOfItems = new string[10];
            int      i            = 0;

            foreach (var itm in itemSales)
            {
                namesOfItems[i] = itm.item;
                i++;
                if (i == 10)
                {
                    break;
                }
            }

            object[] sumOfItems = new object[10];
            i = 0;
            foreach (var itm in itemSales)
            {
                sumOfItems[i] = itm.sum;
                i++;
                if (i == 10)
                {
                    break;
                }
            }


            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart");
            chart.SetXAxis(new XAxis
            {
                Categories = namesOfItems
            });

            chart.SetSeries(new Series
            {
                Data = new Data(sumOfItems)
            });

            return(View(chart));
        }
        public static DotNet.Highcharts.Highcharts GetAreaChart(List <DotNet.Highcharts.Options.Series> seriesSet, List <string> xValues, string title)
        {
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts(title);
            chart.InitChart(new Chart
            {
                Height            = 300,
                Width             = 300,
                DefaultSeriesType = ChartTypes.Area
            });

            chart.SetXAxis(new XAxis
            {
                Categories = xValues.ToArray()
            });
            chart.SetSeries(seriesSet.ToArray());
            chart.SetTitle(new DotNet.Highcharts.Options.Title {
                Text = title
            });
            return(chart);
        }
        /// <summary>
        /// Creates the Html for a Chart using Restore data
        /// </summary>
        /// <returns></returns>
        public string RestoreByNuGetVersionChart()
        {
            string[]      blobNames = { "Restore7Day.json", "Restore-Dependency7Day.json" };
            List <string> xValues   = new List <string>();
            List <object> yValues   = new List <Object>();

            ReportHelpers.GetValuesFromBlobs(blobNames, StorageAccount, ContainerName, out xValues, out yValues);

            List <DotNet.Highcharts.Options.Series> seriesSet = new List <DotNet.Highcharts.Options.Series>();

            seriesSet.Add(new DotNet.Highcharts.Options.Series
            {
                Data = new Data(yValues.ToArray())
            });

            DotNet.Highcharts.Highcharts installChart = ReportHelpers.GetBarChart(seriesSet, xValues, "Restores_Per_NuGet_Version");
            string installChartHtml = installChart.ToHtmlString();

            return(installChartHtml);
        }
Example #33
0
        private void loadSummaryPieChart()
        {
            queryString = "select count(*) as count, CASE greatest(Neutral,Happy,Sad,Angry,Surprised,Scared,Disgusted)" +
                          " WHEN Neutral THEN 'Neutral'" +
                          " WHEN Happy THEN 'Happy'" +
                          " WHEN Sad THEN 'Sad'" +
                          " WHEN Angry THEN 'Angry'" +
                          " WHEN Surprised THEN 'Surprised'" +
                          " WHEN Scared THEN 'Scared'" +
                          " WHEN Disgusted THEN 'Disgusted'" +
                          " else 'Unknown'" +
                          " END AS maxColumn from alef.emotions where Student_id=" + studentId +
                          " and Timestamp BETWEEN " + start + " AND " + end + " group by maxColumn;";

            DataTable data              = loadDatafromDB(queryString);
            var       percentages       = new List <object[]>();
            double    totalNumOfRecords = 0;

            foreach (DataRow dr in data.Rows)
            {
                totalNumOfRecords += Convert.ToDouble(dr["count"]);
            }

            foreach (DataRow dr in data.Rows)
            {
                double percentage = Math.Round((((Convert.ToDouble(dr["count"])) / totalNumOfRecords) * 100.0), 2);
                percentages.Add(new object[] { dr["maxColumn"].ToString(), percentage.ToString() });
            }

            Title title = new DotNet.Highcharts.Options.Title();

            title.Text = "";

            DotNet.Highcharts.Highcharts chart2 = new DotNet.Highcharts.Highcharts("chart2").SetTitle(title);
            chart2.SetSeries(new Series
            {
                Type = DotNet.Highcharts.Enums.ChartTypes.Pie,
                Data = new Data(percentages.ToArray())
            });
            ltrChart2.Text = chart2.ToHtmlString();
        }
Example #34
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);
        }
Example #35
0
        public PartialViewResult GetMeetCountChart()
        {
            SimpleChartModel chartModel = new SimpleChartModel();

            chartModel.ContainerId = "meetChart";
            chartModel.Title       = "沟通频率";

            chartModel.SeriesList = new List <YSeries>();

            YSeries series = new YSeries();

            series.YSeriesList = new List <object>();
            series.YName       = "次数";

            chartModel.ValueSuffix = "次";
            //读取meeting表,按照时间为上一周
            DateTime startWeek = DateTime.Now.AddDays(1 - Convert.ToInt32(DateTime.Now.DayOfWeek.ToString("d")));

            startWeek = startWeek.AddDays(-7);
            DateTime endWeek = startWeek.AddDays(6);

            chartModel.YTitle = startWeek.ToString("yyyyMMdd") + "-" + endWeek.ToString("yyyyMMdd");

            OtaCrmModel db = new OtaCrmModel();
            var         ss = from i in db.CompanyMeeting
                             where i.MeetDate >= startWeek && i.MeetDate <= endWeek
                             group i by i.CreateUserName
                             into g
                             select new { count = g.Count(), userName = g.Key };
            AccountController ac = new AccountController();

            foreach (var item in ss)
            {
                chartModel.XList.Add(ac.GetRealName(item.userName));
                series.YSeriesList.Add(item.count);
            }
            chartModel.SeriesList.Add(series);

            DotNet.Highcharts.Highcharts chart = GetChart(chartModel);
            return(PartialView("_PartialChartView", chart));
        }
        public ActionResult ThisWeek()
        {
            //Returns the chart for Average response for the last week
            string[] checkNames = new string[] { "feed.raw.packages.list", "package.restore.download", "package.restore.lookup", "feed.top.30.by.downloads" };
            List <DotNet.Highcharts.Options.Series> seriesSet = new List <DotNet.Highcharts.Options.Series>();
            List <string> xValues = new List <string>();
            List <object> yValues = new List <object>();

            foreach (string check in checkNames)
            {
                //Get the response values from pre-created blobs for each check.
                BlobStorageService.GetJsonDataFromBlob(check + "WeeklyReport.json", out xValues, out yValues);
                seriesSet.Add(new DotNet.Highcharts.Options.Series
                {
                    Data = new Data(yValues.ToArray()),
                    Name = check
                });
            }
            DotNet.Highcharts.Highcharts chart = ChartingUtilities.GetLineChart(seriesSet, xValues, "AvgResponseTime", 600);
            return(PartialView("~/Views/Shared/PartialChart.cshtml", chart));
        }
        // GET: WebService
        public ActionResult Index()
        {

            var visualSitecoreService = new SitecoreWS.VisualSitecoreServiceSoapClient();
            string database = "master";
            SitecoreWS.Credentials credentials = new SitecoreWS.Credentials();
            credentials.UserName = @"sitecore\admin";
            credentials.Password = "******";

            string homeItem = "{641783AA-0EF2-4117-9503-C5CEA36E32F3}";
            string homeItem2 = "{180A9978-A7F5-4AF3-AEA3-7E4062177DAA}";
            //string parentItem = "{C5384188-D4B4-4C09-A053-094271353190}";


            var children = visualSitecoreService.GetChildren(homeItem2, database, credentials);
             
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(children.ToString());

            string xpath = "sitecore/item/@id";
            var nodes = xmlDoc.SelectNodes(xpath);

            foreach (XmlNode childrenNode in nodes)
            {
                //childrenNode.Value
                var item = visualSitecoreService.GetItemFields(childrenNode.Value, "en", "1", true, database, credentials);
                    //var getItem = sitecoreService.GetItemFields(getChildren.ChildNodes[i].Attributes[0].Value, "en", "1", true, database, myCred);

            }

            using (XmlReader reader = XmlReader.Create((new StringReader(children.ToString()))))
            {
                XDocument loaded = XDocument.Load(reader);

                var q = from c in loaded.Descendants("id")
                        select (string)c.Value;

                
                foreach (string name in q)
                    Console.WriteLine("Item name = {0}", name);
            }

            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
    .SetXAxis(new XAxis
    {
        Categories = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
    })
    .SetSeries(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 })
    });

            return View(chart);


            //string parentId = "{37F01BDF-AAF4-4C0C-87A0-CD26220F783D}";
            //string templateId = "{1D7ADB59-3AB0-4131-93AB-AADE26297D65}";


            //while (true)
            //{
            //    Console.WriteLine("Sitecore Terminal Web Service Integration");
            //    Console.WriteLine("=========================================");
            //    var children = visualSitecoreService.GetChildren(parentId, database, credentials);
            //    using (System.Xml.XmlReader reader =
            //    XmlReader.Create((new System.IO.StringReader(children.ToString()))))
            //    {
            //        XDocument loaded = XDocument.Load(reader);
            //        var q = from c in loaded.Descendants("item")
            //                select (string)c.Value;
            //        Console.WriteLine("Number of added items in Sitecore = " + q.Count().ToString() + "" + Environment.NewLine);
            //        foreach (string name in q)
            //            Console.WriteLine("Item name = {0}", name);
            //        Console.WriteLine(Environment.NewLine);
            //    }
            //    Console.WriteLine("=========================================" +
            //    Environment.NewLine);
            //    Console.WriteLine("Enter a name for the new Item:" +
            //    Environment.NewLine);
            //    string itemName = Console.ReadLine();
            //    var result = visualSitecoreService.AddFromTemplate(parentId, templateId, itemName, database, credentials);
            //    Console.WriteLine("Item '" + itemName + "' is added.");
            //    Console.WriteLine("Press key to continue");
            //    Console.ReadKey();
            //    Console.Clear();

            //    return View();
            //}
            //}
        }
Example #38
0
        //
        // GET: /OldCoins/Details/5
        public ActionResult Details(Guid id)
        {
            if (Request.Cookies["FYCoins"] != null)
            {
                if (Request.Cookies["FYCoins"]["RateUSD"] != null)
                {
                    ViewBag.RateUSD = Request.Cookies["FYCoins"]["RateUSD"] == null ?
                        "" : Request.Cookies["FYCoins"]["RateUSD"];
                    ViewBag.DealDate = Request.Cookies["FYCoins"]["DealDate"] == null ?
                        "" : Request.Cookies["FYCoins"]["DealDate"];
                    ViewBag.DealCompany = Request.Cookies["FYCoins"]["DealCompany"] == null ?
                        "" : Request.Cookies["FYCoins"]["DealCompany"];
                }
                else
                {
                    ViewBag.RateUSD = "6.2";
                    ViewBag.DealDate = "";
                    ViewBag.DealCompany = "";
                }
            }
            else
            {
                ViewBag.RateUSD = "6.2";
                ViewBag.DealDate = "";
                ViewBag.DealCompany = "";
            }

            var coin = CoinManager.GetCoin(id);
            var coinDealHistories = CoinManager.GetCoinDealHistories(coin);
            //var coinWithLastDealHistory = CoinManager.GetLastCoinDealHistory(coin);

            CoinViewModel coinViewModel = new CoinViewModel(CoinManager.GetCoinWithLastCoinDealHistory(id));
            coinViewModel.coinDealHistories = coinDealHistories;
            coinViewModel.coinDealHistory = new CoinDealHistory();

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

            DotNet.Highcharts.Highcharts coinHistoryDealChart =
                new DotNet.Highcharts.Highcharts("CoinHistoryDealChart")
                .SetTitle(new Title { Text = "拍卖价格波动表" })
                .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "拍卖价格" } })
                .SetXAxis(new XAxis { Title = new XAxisTitle { Text = "拍卖日期" }, Categories = dealDates })
                .SetSeries(new Series
                {
                    Name = "拍卖价格",
                    Data = new Data(dealPrices)
                });

            coinViewModel.coinHistoryDealChart = coinHistoryDealChart;

            return View(coinViewModel);
            //return View();
        }
Example #39
0
        protected void Page_Load(object sender, EventArgs e)
        {
            /* get data
             */
            DataTable dt = PostOrmDB.GetTop10MentionKeyword();

            var query = dt.AsEnumerable()
                .GroupBy(row => new
                {
                    Text = row.Field<string>("keyword_value"),
                    Keyword = row.Field<int>("KeywordId"),
                    Senti = row.Field<int>("SentiLabel")
                })
                .Select(grp => new
                {
                    Text = grp.Key.Text,
                    Keyword = grp.Key.Keyword,
                    Senti = grp.Key.Senti,
                    Count = grp.Count()
                });

            List<string> ltext = new List<string>();
            List<string> lkeyword = new List<string>();
            List<int> lpos = new List<int>();
            List<int> lnor = new List<int>();
            List<int> lneg = new List<int>();

            /*
             * get value of pos/nor/neg
             */
            /*
            foreach (var senti in query)
            {
                    if (!lkeyword.Contains(senti.Keyword.ToString()))
                    {
                        lkeyword.Add(senti.Keyword.ToString());

                        if (senti.Senti == 0 || senti.Senti == 1)
                        {
                            lneg.Add(senti.Count);
                        }
                        else{
                            lneg.Add(0);
                        }
                        if (senti.Senti == 2)
                        {
                            lnor.Add(senti.Count);
                        }
                        else{
                            lnor.Add(0);
                        }

                        if (senti.Senti == 3 || senti.Senti == 4)
                        {
                            lpos.Add(senti.Count);
                        }
                        else
                        {
                            lpos.Add(0);
                        }

                    }
                    else
                    {
                        if (senti.Senti == 0 || senti.Senti == 1)
                        {
                            lneg[lneg.Count-1]=senti.Count;
                        }

                        if (senti.Senti == 2)
                        {
                            lnor[lnor.Count - 1] = senti.Count;
                        }

                        if (senti.Senti == 3 || senti.Senti == 4)
                        {
                            lpos[lpos.Count - 1] = senti.Count;
                        }

                    }

            }
             * */

            foreach (var senti in query)
            {
                if (!ltext.Contains(senti.Text))
                {
                    ltext.Add(senti.Text);

                    if (senti.Senti == 0 || senti.Senti == 1)
                    {
                        lneg.Add(senti.Count);
                    }
                    else
                    {
                        lneg.Add(0);
                    }
                    if (senti.Senti == 2)
                    {
                        lnor.Add(senti.Count);
                    }
                    else
                    {
                        lnor.Add(0);
                    }

                    if (senti.Senti == 3 || senti.Senti == 4)
                    {
                        lpos.Add(senti.Count);
                    }
                    else
                    {
                        lpos.Add(0);
                    }

                }
                else
                {
                    if (senti.Senti == 0 || senti.Senti == 1)
                    {
                        lneg[lneg.Count - 1] = senti.Count;
                    }

                    if (senti.Senti == 2)
                    {
                        lnor[lnor.Count - 1] = senti.Count;
                    }

                    if (senti.Senti == 3 || senti.Senti == 4)
                    {
                        lpos[lpos.Count - 1] = senti.Count;
                    }

                }

            }

            List<string> lstr = new List<string>();
            /*
            foreach (var item in lkeyword)
            {
                lstr.Add(item.ToString());
            }
            */
            foreach (var item in ltext)
            {
                lstr.Add(item);
            }

            //string[] o_keyword = lstr.ToArray();
            string[] o_text = lstr.ToArray();
            object[] o_neg = lneg.Cast<object>().ToArray();
            object[] o_nor = lnor.Cast<object>().ToArray();
            object[] o_pos = lpos.Cast<object>().ToArray();

            /* Display chart
             *
             */
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
            .InitChart(new Chart { DefaultSeriesType = DotNet.Highcharts.Enums.ChartTypes.Bar })
            .SetTitle(new Title { Text = "Distribution of Top 10 Keywords In A Week" })
            //.SetXAxis(new XAxis { Categories = o_keyword })
            .SetXAxis(new XAxis { Categories = o_text })
            .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })
            .SetSeries(new[]
                       {
                           new Series { Name = "Negative", Data = new Data(o_neg) },
                           new Series { Name = "Normal", Data = new Data(o_nor) },
                           new Series { Name = "Positive", Data = new Data(o_pos) }
                       });

            huyChart.Text = chart.ToHtmlString();
        }
        // GET: Relatorio
        public ActionResult Index()
        {

            /// Total de Contatos
            int i = 0;
            for (i = 0; i < db.Contatos.Count(); )
            {
                i++;

            }

            
            ViewBag.Resultado = i;


            /// Total de Contatos Femininos
            int j = 0;
            foreach (var item in db.Contatos)
            {
                if (item.Feminino == true)
                {
                    j++;
                }
            }

            ViewBag.Feminino = j;

            /// Total de Contatos Masculinos
            int k = 0;
            foreach (var item in db.Contatos)
            {
                if (item.Masculino == true)
                {
                    k++;
                }
            }

            ViewBag.Masculino = k;


            /// Graficos de Contatos
            
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
            .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
            .SetTitle(new Title { Text = "Gráfico de Contatos" })
            .SetXAxis(new XAxis
                        {
                            Categories = new[] { "Masculino", "Feminino", "Total"}
                        })
            .SetYAxis(new YAxis
            {
                Min = 0,
                Title = new YAxisTitle { Text = "Quatidade de Contatos" }
            })
            .SetSeries(new Series
                        {
                            Data = new Data(new object[] { k, j, i })
                        });

            ViewBag.grafico = chart;

            return View();
        }
        /// <summary>
        /// Returns a bar chart for a given set of values.
        /// </summary>
        /// <param name="seriesSet"></param>
        /// <param name="xValues"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static DotNet.Highcharts.Highcharts GetBarChart(List<DotNet.Highcharts.Options.Series> seriesSet, List<string> xValues, string title)
        {
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts(title);
            chart.InitChart(new Chart
            {
                Height = 320,
                Width = 320,
                DefaultSeriesType = ChartTypes.Column
            });

            chart.SetXAxis(new XAxis
            {
                Categories = xValues.ToArray()

            });

            chart.SetLegend(new Legend { Enabled = false });
            chart.SetSeries(seriesSet.ToArray());

            chart.SetTitle(new DotNet.Highcharts.Options.Title { Text = title.Replace("_", " ")});
            
            return chart;
        }
        public ActionResult Speed(int id = 0)
        {
            if (Session["user"] == null)
                return RedirectToAction("Login", "Account");
            var results = servicio.ObtenerPosiciones(id).Select(
                    a => new
                    {
                        a.fechaPosicion,
                        a.velocidad,
                    });
            if (id <= 0 || results.Count() == 0)
                return new HttpStatusCodeResult(404, "No se ha encontrado la ruta de la Entidad de ID " + id + ". (¿Quizás fue eliminada?)");

            var xData = results.Select(i => i.fechaPosicion.ToString("HH:mm:ss")).ToArray();
            var yData = results.Select(i => new object[] { i.velocidad }).ToArray();

            double average = Math.Round(servicio.ObtenerPosiciones(id).Average(r => r.velocidad), 2);

            object[] yDataAverage = new object[yData.Length];
            Array.Copy(yData,0,yDataAverage,0,yData.Length);

            for (int i = 0; i < yDataAverage.Length; i++)
            {
                yDataAverage[i] = average;
            }

            TempData["idEntidad"] = id;

            var chart = new DotNet.Highcharts.Highcharts("chart")
                        .InitChart(new Chart { DefaultSeriesType = ChartTypes.Line })
                        .SetTitle(new Title { Text = "Velocidad de Entidad" })
                        .SetXAxis(new XAxis { Categories = xData })
                        .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Velocidad (Km/h)" } })
                        .SetTooltip(new Tooltip
                        {
                            Enabled = true,
                            Formatter = @"function() { 
                                var text = '';
                                if(this.series.name == 'Velocidad') {
                                    text = '<b>'+ 'Velocidad: ' + '</b>' + this.y + ' Km/h<br/>' +
                                '<b>'+ 'Hora: ' +'</b> '+ this.x;
                                } else {
                                    text = '<b>'+ 'Velocidad: ' + '</b>' + this.y + ' Km/h<br/>';
                                }
                                return text;
                            }"
                        })
                        .SetSeries(new[]
                        {
                         new Series {Name = "Velocidad", Data = new Data(yData)},
                         new Series {Name = "Velocidad promedio", Data = new Data(yDataAverage)},
                        });


            return View(chart);
        }
        protected void Calculate(object sender, EventArgs e)
        {
            double L,C,A;
            var mydata = new ArrayList();
                ;

            /*
            if (Inductance.Text.Length > 0 && Capacitance.Text.Length > 0)
            {

                A = Convert.ToDouble(Inductance.Text) + Convert.ToDouble(Capacitance.Text);
                Answer.Text = A.ToString("0.000");
            }
            else
            {
                Answer.Text = "Invalid Input";
            }
            //Debug.Write("Calculate Pressed\n");
             *
             * */
            //s = Inductance.Text;
            //C = Double.TryParse(s, L);
            if (Double.TryParse(Inductance.Text, out L))
            {
            }
            if( (Double.TryParse(Capacitance.Text,out  C))&&(Double.TryParse(Inductance.Text, out L)))
            {
               //A = L + C;
                A =  1.0 / (6.2831853 * Math.Sqrt(L * C/1000));
                Answer.Text = A.ToString("0.000") + " MHz";
                for( int i = 0; i < 10; i++ ) {
                    //mydata.Add(1.0 * i);
                    mydata.Add( 1.0 / (6.2831853 * Math.Sqrt(L * C/1000 * 0.2 * (i+1))));
                }

            } else
            {
                Answer.Text = "Invalid Input";
            }
            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
                .InitChart(new Chart
                    {
                        DefaultSeriesType = ChartTypes.Line,
                        Height = 300,
                        MarginRight = 130,
                        //MarginBottom = 25,
                        ClassName = "chart"
                    })
                .SetTitle(new Title
                {
                    Text = "Resonant Frequency",
                    X = -20
                })

                .SetXAxis(new XAxis
                {
                    Categories = new[] { "20%","40%","60%","80%","100%","120%","140%","160%","180%","200%" },
                    //Categories = mydata;
                    Title = new XAxisTitle {Text =  "% Capacitance"},
                    Min = 0,
                    Max = 9,
                    //TickLength = 20,
                    //TickWidth = 20,
                    //MinTickInterval = 20
                    TickInterval = 1
                }
                )
                .SetYAxis(new YAxis
                    {
                        Title = new YAxisTitle { Text = "Frequency MHz" },
                        PlotLines = new []
                        {
                            new YAxisPlotLines
                            {

                                    Value = 0,
                                    Width = 1,
                                    //Color = ColorTranslator.FromHtml("808080")

                            }
                        }
                    }
                        )
                .SetSeries(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 })
                    //Data = new Data(new object mydata);

                    Data = new Data(new object[] { mydata[0], mydata[1], mydata[2], mydata[3], mydata[4],
                    mydata[5],mydata[6], mydata[7], mydata[8], mydata[9]})
                });
            ltrChart.Text = chart.ToHtmlString();
        }