public static Highcharts ConstructChart(Dictionary<int, double> dataToDisplay, string chartTitle,string chartDescription) { var title = new Title() { Text = chartTitle }; var subtitle = new Subtitle() { Text = chartDescription }; var XData = dataToDisplay.Keys.ToList().ConvertAll(x => Convert.ToString(x)).ToArray(); var YData = dataToDisplay.Values; var xaxisTitle = new XAxisTitle { Text = "X" }; var yaxisTitle = new YAxisTitle { Text = "Y" }; Highcharts chart = new Highcharts("Chart") .SetTitle(title) .SetSubtitle(subtitle) .SetXAxis(new XAxis { Categories = XData, Title = xaxisTitle, LineWidth = 0 }) .SetYAxis(new YAxis { Title = yaxisTitle, LineWidth = 0 }) .SetSeries(new Series { Data = new Data(YData.OfType<object>().ToArray()), }); return chart; }
public string ReporteCantidadDePatosEnAustraliaPorMes() { Highcharts chart = new DotNet.Highcharts.Highcharts("Cantidad de patos en Australia") .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 }), Name = "Tarjetas" }); chart.SetYAxis(new YAxis() { Title = new YAxisTitle() { Text = "En miles" } }); chart.SetTitle(new Title() { Text = "Ventas del año pasado" }); string cadena = chart.ToHtmlString(); cadena = cadena.Substring(193); cadena = cadena.Substring(0, cadena.Length - 17); cadena = cadena.Replace("Cantidad de patos en Australia_container", "Chart"); return(cadena); }
public Highcharts CreateAnswersPerDayChart(string chartName) { var data = _dataSource.GetAnswersPerDay(_userTimeZone, _fakeTodayDate); var chart = new Highcharts(chartName) .InitChart(new Chart {DefaultSeriesType = ChartTypes.Spline}) .SetOptions(new GlobalOptions {Global = new Global {UseUTC = false}}) .SetTitle(new Title {Text = "Answers per day"}) .SetXAxis(new XAxis { Type = AxisTypes.Datetime, DateTimeLabelFormats = new DateTimeLabel {Month = "%e. %B", Year = "%b", Day = "%A, %e. %B"} }) .SetYAxis(new YAxis { Title = new YAxisTitle {Text = "Number of answers"}, Min = 0 }) .SetTooltip(new Tooltip { Formatter = "function() { return '<b>'+ this.series.name +'</b><br/>'+ Highcharts.dateFormat('%A, %e. %B', this.x) +': '+ this.y +''; }" }) .SetSeries(new[] { CreateDateCountSeries(data, "Begrijpend Lezen"), CreateDateCountSeries(data, "Rekenen"), CreateDateCountSeries(data, "Spelling") }); return chart; }
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(); }
public Highcharts GenerateLostChart(IEnumerable <DashBoardInfoPerTeam> dashboard) { DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("Lost") .SetXAxis(new XAxis { Categories = dashboard.Select(t => t.Name).ToList().ToArray(), Title = new XAxisTitle() { Text = "Team" } }) .SetSeries(new Series { Data = new Data(dashboard.Select(t => { Object o; o = t.Lost; return(o); }).ToList().ToArray()), Name = "Number of losses" }) .SetYAxis(new YAxis { Title = new YAxisTitle() { Text = "Losses" } }) .SetTitle(new Title() { Text = "Number of losses per team" }); return(chart); }
public string CurrentMonthGoalProgressNet() { var now = DateTime.Now; var daysInMonth = DateTime.DaysInMonth(now.Year, now.Month); var expectedPct = ((decimal)now.Day / daysInMonth); var remainingDays = daysInMonth - now.Day; var stepsPR = pedometerCalcService.StepsPR(); var remainingSteps = (int) (stepsPR-pedometerCalcService.MonthStepsActual())/remainingDays; var highchart = new Highcharts("CurrentMonthGoal"); var chart = new Chart() {Type = ChartTypes.Bar}; var categories = new List<string> {"Steps"}; var yaxis = new YAxis {Max = 1}; var seriesArray = new List<Series>(); var series = new Series {Name = "Expected",Color = Color.Red}; var data = new List<object> {pedometerCalcService.MonthPctExpected(now)}; var plotoptions = new PlotOptionsBar { Grouping = false, Shadow = false, DataLabels = new PlotOptionsBarDataLabels() { Enabled = false, Format = string.Format("Expected: {0}", (int) (stepsPR*expectedPct)), Color = Color.White } }; series.Data = new Data(data.ToArray()); series.PlotOptionsBar = plotoptions; seriesArray.Add(series); series = new Series {Name = "Actual", Color = Color.Green}; data = new List<object> { pedometerCalcService.MonthPct(now.Month, now.Year) }; plotoptions = new PlotOptionsBar { Grouping = false, Shadow = false, DataLabels = new PlotOptionsBarDataLabels() { Enabled = true, Format = string.Format("Remaining: {0}/day", remainingSteps), Color = Color.White, Shadow = false } }; series.Data = new Data(data.ToArray()); series.PlotOptionsBar = plotoptions; seriesArray.Add(series); highchart.InitChart(chart); highchart.SetTitle(new Title() {Text = "Month Progress"}); highchart.SetXAxis(new XAxis() {Categories = categories.ToArray()}); highchart.SetYAxis(yaxis); highchart.SetSeries(seriesArray.ToArray()); highchart.SetTooltip(new Tooltip() {Enabled = false}); return highchart.ToHtmlString(); }
public ActionResult Index(FormularioInsercaoArquivoViewModel formularioViewModel) { if (!formularioViewModel.Arquivo.FileName.EndsWith(".xml")) { //test ViewData["Mensagem"] = "O Arquivo deve ser no famato XML."; return(View(formularioViewModel)); } var caminhoENomeRepositorioArquivoTestes = "C:\\Users\\Altamir\\Desktop\\temp_zap_analise\\" + formularioViewModel.Arquivo.FileName; formularioViewModel.Arquivo.SaveAs(caminhoENomeRepositorioArquivoTestes); var dadosXml = ConversorXmlObjectoComplexo.Converter(caminhoENomeRepositorioArquivoTestes); #region geraDadoSGraficoPizza object[] dadosGraficoPizza = new object[dadosXml.Alertas.Count]; for (int i = 0; i < dadosGraficoPizza.Length - 1; i++) { dadosGraficoPizza[i] = new object[] { dadosXml.Alertas[i].NomeAlerta, dadosXml.Alertas[i].QtdOcorrencias }; } #endregion #region graficoPizza var grafico = new DotNet.Highcharts.Highcharts("grafico_pizza") .InitChart(new Chart { PlotShadow = false }) .SetTitle(new Title { Text = dadosXml.NomeSite }) .SetTooltip(new Tooltip { Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }" }) .SetPlotOptions(new PlotOptions { Pie = new PlotOptionsPie { AllowPointSelect = true, Cursor = DotNet.Highcharts.Enums.Cursors.Pointer, DataLabels = new PlotOptionsPieDataLabels { Color = System.Drawing.ColorTranslator.FromHtml("#000000"), ConnectorColor = System.Drawing.ColorTranslator.FromHtml("#000000"), Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }" } } }) .SetSeries(new Series { Type = DotNet.Highcharts.Enums.ChartTypes.Pie, Name = "Browser share", Data = new DotNet.Highcharts.Helpers.Data(dadosGraficoPizza) }); #endregion formularioViewModel.GraficoPizza = grafico; formularioViewModel.ApresetarResultados = true; return(View(formularioViewModel)); }
public ComparisonViewModel(Highcharts chart) { NumberOfQueries = 4; Chart = chart; FirstIndex = IndexEnum.gist; SecondIndex = IndexEnum.rtree; AllIndexes = false; Data = DataEnum.countries; Query = QueryEnum.FindNearestNeighbours; }
public ActionResult GetContributor() { Random rand = new Random(); //create a collection of data var transactionCounts = new List<TransactionCount> { new TransactionCount(){ MonthName="January", Count=rand.Next(101)}, new TransactionCount(){ MonthName="February", Count=rand.Next(101)}, new TransactionCount(){ MonthName="March", Count=rand.Next(101)}, new TransactionCount(){ MonthName="April", Count=rand.Next(101)} }; //modify data type to make it of array type var xDataMonths = transactionCounts.Select(i => i.MonthName).ToArray(); var yDataCounts = transactionCounts.Select(i => new object[] { i.Count }).ToArray(); //instanciate an object of the Highcharts type var chart = new Highcharts("chart") //define the type of chart .InitChart(new Chart { DefaultSeriesType = ChartTypes.Line }) //overall Title of the chart .SetTitle(new Title { Text = "Incoming Transacions per hour" }) //small label below the main Title .SetSubtitle(new Subtitle { Text = "Accounting" }) //load the X values .SetXAxis(new XAxis { Categories = xDataMonths }) //set the Y title .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Number of Transactions" } }) .SetTooltip(new Tooltip { Enabled = true, Formatter = @"function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': '+ this.y; }" }) .SetPlotOptions(new PlotOptions { Line = new PlotOptionsLine { DataLabels = new PlotOptionsLineDataLabels { Enabled = true }, EnableMouseTracking = false } }) //load the Y values .SetSeries(new[] { new Series {Name = "Hour", Data = new Data(yDataCounts)}, //you can add more y data to create a second line // new Series { Name = "Other Name", Data = new Data(OtherData) } }); return PartialView("Contributor", chart); }
// // GET: /Reports/ public ActionResult Index() { HospitalBirthData model = new HospitalBirthData(); model.Charts = new List <DotNet.Highcharts.Highcharts>(); DotNet.Highcharts.Highcharts g1 = new DotNet.Highcharts.Highcharts("chart"); DotNet.Highcharts.Highcharts g2 = new DotNet.Highcharts.Highcharts("chart"); model.Charts.Add(g1); model.Charts.Add(g2); return(View(model)); }
public string ReporteTarjetasPorEmpleado() { BLL.BLLHistoricoSolicitudTarjeta bll = new BLL.BLLHistoricoSolicitudTarjeta(); var hist = bll.ObtenerHistoricoSolicitudTarjetasPorEmpleado(); Highcharts chart = new DotNet.Highcharts.Highcharts("Cantidad de patos en Australia"); chart.InitChart(new DotNet.Highcharts.Options.Chart { DefaultSeriesType = DotNet.Highcharts.Enums.ChartTypes.Column }); chart.SetTitle(new Title() { Text = "Cantidad de ventas por empleado" }); object[] datos = new object[hist.Length]; for (int i = 0; i < hist.Length; i++) { datos[i] = hist[i].Item2; } chart.SetSeries(new Series() { Data = new Data(datos), Name = "Tarjetas" }); string[] cat = new string[hist.Length]; for (int i = 0; i < hist.Length; i++) { cat[i] = hist[i].Item1; } chart.SetXAxis(new XAxis() { Categories = cat, }); chart.SetYAxis(new YAxis() { Title = new YAxisTitle() { Text = "Tarjetas" } }); string cadena = chart.ToHtmlString(); cadena = cadena.Substring(193); cadena = cadena.Substring(0, cadena.Length - 17); cadena = cadena.Replace("Cantidad de patos en Australia_container", "Chart"); return(cadena); }
// // GET: /HighChartsSampleModel/ public ActionResult Index() { var highchartSample = new List<HighChartsSampleModel> { new HighChartsSampleModel() {Parameters = "Event", GoodScore = 23.45D, AverageScore = 15.32D,BadScore = 9.4D,ActualScore=78.33D}, new HighChartsSampleModel() {Parameters = "Weather",GoodScore=45.67D,AverageScore = 33.24D,BadScore = 12.23D,ActualScore = 56.22D}, new HighChartsSampleModel() {Parameters = "User Review",GoodScore=67.23D,AverageScore = 31.23D,BadScore = 10.11D,ActualScore = 29.44D}, new HighChartsSampleModel() {Parameters = "Tweets",GoodScore = 89.67D,AverageScore = 12.33D,BadScore = 3.43D,ActualScore = 88.11D}, new HighChartsSampleModel() {Parameters = "Persona",GoodScore=38.34D,AverageScore = 25.34D,BadScore = 16.43D,ActualScore = 35.08D}, new HighChartsSampleModel() {Parameters = "Crime",GoodScore=38.34D,AverageScore = 25.34D,BadScore = 16.43D,ActualScore = 24.87D} }; var xDataParameters = highchartSample.Select(i => i.Parameters).ToArray(); var actualScore = highchartSample.Select(i => i.ActualScore); var chart = new Highcharts("chart"); chart.InitChart(new Chart { DefaultSeriesType = ChartTypes.Bar }); chart.SetTitle(new Title { Text = "Risk Score Profiling" }); chart.SetSubtitle(new Subtitle { Text = "Risk predicting using social media" }); chart.SetXAxis(new XAxis { Categories = xDataParameters }); chart.SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Scores" }, Max = 100 }); chart.SetLegend(new Legend { Enabled = false, }); chart.SetTooltip(new Tooltip { Enabled = true, Formatter = @"function(){return '<b>' + this.series.name +'</b><br/>' + this.x+':' + this.y;}" }); chart.SetPlotOptions(new PlotOptions { //Series = new PlotOptionsSeries() { Stacking = Stackings.Normal }, Bar = new PlotOptionsBar { DataLabels = new PlotOptionsBarDataLabels { Enabled = true,Color = Color.Maroon,Shadow = true}, //PointWidth = 10, //GroupPadding = 1, //PointPadding = 0, Shadow = true, BorderWidth = 1, BorderColor = Color.FloralWhite, } }); Data data = new Data( actualScore.Select(y => new Point { Color = GetBarColor(y), Y = y}).ToArray() ); chart.SetSeries(new Series { Name = "Actual Score", Data = data }); return View(chart); }
public ActionResult Bar() { var list = new DataForBarChart().ListDatas; Series[] array = new Series[list.Count]; for (int i = 0; i < list.Count; i++) array[i] = new Series { Name = list[i].Name, Data = new Data(list[i].List) }; Highcharts chart = new Highcharts("chart") .InitChart(new Chart { Type = ChartTypes.Bar }) .SetTitle(new Title { Text = "Yearly Sales of Goods" }) .SetXAxis(new XAxis { Categories = _elementsService.ProductsItems.Select(item => item.Name).ToArray(), Title = new XAxisTitle { Text = string.Empty } }) .SetYAxis(new YAxis { Min = 0, Title = new YAxisTitle { Text = "BYR", Align = AxisTitleAligns.High } }) .SetTooltip(new Tooltip { Formatter = @"function() { return ''+ this.series.name +': '+ this.y +' BYR'; }" }) .SetPlotOptions(new PlotOptions { Bar = new PlotOptionsBar { DataLabels = new PlotOptionsBarDataLabels { Enabled = true } } }) .SetLegend(new Legend { Layout = Layouts.Vertical, Align = HorizontalAligns.Right, VerticalAlign = VerticalAligns.Top, X = -100, Y = 100, Floating = true, BorderWidth = 1, BackgroundColor = new BackColorOrGradient(ColorTranslator.FromHtml("#FFFFFF")), Shadow = true }) .SetCredits(new Credits { Enabled = false }) .SetSeries(array); return View(chart); }
public ActionResult ChartOrders() { Highcharts orders = new Highcharts("OrderID"); orders.SetTitle(new Title() { Text = Resources.Resource.OrdersRoma }); orders.SetYAxis(new YAxis { Title = new YAxisTitle() { Text = Resources.Resource.CountRoma }, }); //var ord = orderManager.GetQueryableOrders(); var drivers = userManager.GetQueryableDrivers(); //var res = ord.Join(drivers, x => x.DriverId, y => y.Id, (x, y) => new { Name = y.UserName, Orders = 1 }).GroupBy(x=>x.Name).ToList(); List<Series> series = new List<Series>(); List<object> serieData = new List<object>(); /*foreach (var i in res) { Series serie = new Series(); serie.Name = i.Key; serie.Type = ChartTypes.Column; serieData.Clear(); serieData.Add(i.Count()); serie.Data = new Data(serieData.ToArray()); series.Add(serie); }*/ orders.SetSeries(series.ToArray()); orders.SetLegend(new Legend() { Align = HorizontalAligns.Right, Layout = Layouts.Vertical, VerticalAlign = VerticalAligns.Top }); orders.SetPlotOptions(new PlotOptions() { Area = new PlotOptionsArea() { Stacking = Stackings.Normal } }); orders.SetCredits(new Credits() { Enabled = false }); ViewBag.Order = orders; return View(); }
private Highcharts BuildAreaSplineChart(XAndYAxisArrayContainer chartData, string chartTitle, string yAxisTitle) { Highcharts chart = new Highcharts(GenerateChartName(chartTitle)) .InitChart(new Chart { DefaultSeriesType = ChartTypes.Areaspline }) .SetTitle(new Title { Text = string.Empty }) .SetLegend(new Legend { Enabled = false }) .SetXAxis(new XAxis { Categories = chartData.XAxis }) .SetYAxis(new YAxis { Title = new YAxisTitle { Text = yAxisTitle } }) .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.x +': '+ this.y + ' WIs Remaining'; }" }) .SetCredits(new Credits { Enabled = false }) .SetPlotOptions(new PlotOptions { Areaspline = new PlotOptionsAreaspline { FillOpacity = 0.5 } }) .SetSeries(new[] { new Series { Data = new Data(chartData.YAxis) } }); return chart; }
public static void AppendHighchart(this StringBuilder sb, Highcharts chart) { foreach (KeyValuePair<string, string> jsVariable in chart.JsVariables) sb.AppendLine("var {0} = {1};".FormatWith(jsVariable.Key, jsVariable.Value), 1); sb.AppendLine(chart.Name + " = new Highcharts.Chart({", 1); sb.Append(chart.GetOptions(), 2); sb.AppendLine("});", 1); foreach (KeyValuePair<string, string> jsFunction in chart.JsFunctions) { sb.AppendLine(); sb.AppendLine(jsFunction.Key, 1); sb.AppendLine(jsFunction.Value, 2); sb.AppendLine("}", 1); } }
protected void Render_Chart() { int nbValues = 10; DateTime dateFrom = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); int maxDaysInMonth = DateTime.DaysInMonth(dateFrom.Year, dateFrom.Month); DateTime dateTo = new DateTime(DateTime.Now.Year, DateTime.Now.Month, maxDaysInMonth); var randomDatesValues = ChartsRandomDataGenerator.GenerateRandomDates(dateFrom, dateTo, nbValues); var randomNumberValues = ChartsRandomDataGenerator.GenerateRandomNumbers(1000, nbValues); object[] chartValues = randomNumberValues.Cast <object>().ToArray(); string[] dateValues = randomDatesValues.ToArray(); // Declare the HighCharts object DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart").InitChart(new Chart { DefaultSeriesType = ChartTypes.Column }) .SetTitle(new Title { Text = "Example of Chart", X = -50 }) .SetSubtitle(new Subtitle { Text = "All data are random", X = -70 }) .SetXAxis(new XAxis { Categories = dateValues //random dates }) .SetSeries(new[] { new Series { //Name = "# Dates", Data = new Data(chartValues) //random numbers }, }); chrtMyChart.Text = chart.ToHtmlString(); }
public DotNet.Highcharts.Highcharts set_graph(graphViewModel model) { DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart") .SetTitle(new Title { Text = "Production Graph" }) .SetSubtitle(new Subtitle { Text = "Date : " + DateTime.Today, X = -20 }) .SetXAxis(new XAxis { Categories = new[] { "6am", "7am", "8am", "9am", "10am", "11am", "12pm", "1pm", "2pm", "3pm", "4pm", "5pm", "6pm" } }) .SetSeries(new[] { new Series { Name = "Laptop", Data = new Data(new object[] { model.laptop_six_am, model.laptop_six_am, model.laptop_seven_am, model.laptop_eight_am, model.laptop_nine_am, model.laptop_ten_am, model.laptop_eleven_am, model.laptop_twelve_pm, model.laptop_one_pm, model.laptop_two_pm, model.laptop_three_pm, model.laptop_four_pm, model.laptop_five_pm }) } , new Series { Name = "Desktop", Data = new Data(new object[] { model.desktop_six_am, model.desktop_six_am, model.desktop_seven_am, model.desktop_eight_am, model.desktop_nine_am, model.desktop_ten_am, model.desktop_eleven_am, model.desktop_twelve_pm, model.desktop_one_pm, model.desktop_two_pm, model.desktop_three_pm, model.desktop_four_pm, model.desktop_five_pm }) } } ); chart.InitChart(new Chart { Width = 800, Height = 250 }); return(chart); }
private Highcharts getMalesChart() { Highcharts chart = new DotNet.Highcharts.Highcharts("chart") .SetTitle(new Title { Text = "Female students reaction to the educational experience" }) .SetXAxis(new XAxis { Categories = new[] { "Sad", "Happy", "Angry" } }) .SetSeries(new Series { Data = new Data(new object[] { db.Feedbacks.Where(f => f.Mood.Description == "Sad" && f.Course.Id == this.courseId && f.Student.Gender.Name == "Male").Count(), db.Feedbacks.Where(f => f.Mood.Description == "Happy" && f.Course.Id == this.courseId && f.Student.Gender.Name == "Male").Count(), db.Feedbacks.Where(f => f.Mood.Description == "Angry" && f.Course.Id == this.courseId && f.Student.Gender.Name == "Male").Count() }) }); return(chart); }
private Highcharts DataLabels(string label, string[] categories, PairModel station1, PairModel station2, PairModel station3, PairModel station4) { Highcharts chart = new Highcharts("chart") .InitChart(new Chart { DefaultSeriesType = ChartTypes.Line }) .SetTitle(new Title { Text = label }) .SetSubtitle(new Subtitle { Text = "Source: Dummy Data" }) .SetXAxis(new XAxis { Categories = categories }) .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Temperature (°C)" } }) .SetTooltip(new Tooltip { Enabled = true, Formatter = @"function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': '+ this.y +'°C'; }" }) .SetPlotOptions(new PlotOptions { Line = new PlotOptionsLine { DataLabels = new PlotOptionsLineDataLabels { Enabled = true }, EnableMouseTracking = false } }) .SetSeries(new[] { new Series { Name = station1.Key.ToString(), Data = (Data)station1.Value }, new Series { Name = station2.Key.ToString(), Data = (Data)station2.Value }, new Series { Name = station3.Key.ToString(), Data = (Data)station3.Value }, new Series { Name = station4.Key.ToString(), Data = (Data)station3.Value } }); return chart; }
public ActionResult Index() { var cicloAct = db.SP_MW_Ciclos_Act().First(); ViewBag.Ciclo = cicloAct.NU_Ano.ToString() + cicloAct.NU_Ciclo.ToString(); ViewBag.FEIni = cicloAct.FE_CicloIni.Day + "/" + cicloAct.FE_CicloIni.Month + "/" + cicloAct.FE_CicloIni.Year; ViewBag.FEFin = cicloAct.FE_CicloFin.Day + "/" + cicloAct.FE_CicloFin.Month + "/" + cicloAct.FE_CicloFin.Year; DateTime inicio = DateTime.Now; DateTime fin = new DateTime(cicloAct.FE_CicloFin.Year, cicloAct.FE_CicloFin.Month, cicloAct.FE_CicloFin.Day); TimeSpan restantes = (fin - inicio); if (restantes.Days < 0) { ViewBag.Restantes = 0; } else { ViewBag.Restantes = restantes.Days + 1; } ChartsModel model = new ChartsModel(); model.Charts = new List <Highcharts>(); string[] regiones = db.SP_MW_Dashboard_CoberturaPorReg().ToList() .OrderBy(e => e.TX_Region) .Select(c => c.TX_Region).ToArray(); object[] valPuntos = db.SP_MW_Dashboard_CoberturaPorReg() .OrderBy(e => e.TX_Region) .Select(c => c.PCJFVRR.ToString()).ToArray(); object[] valCoberturaMedica = db.SP_MW_Dashboard_CoberturaPorReg() .OrderBy(e => e.TX_Region) .Select(c => new object[] { c.PCJFVRR }).ToArray(); object[] valCoberturaHospital = db.SP_MW_Dashboard_CoberturaPorReg() .OrderBy(e => e.TX_Region) .Select(c => new object[] { c.VisitadosHospital }).ToArray(); object[] valCoberturaFarmacia = db.SP_MW_Dashboard_CoberturaPorReg() .OrderBy(e => e.TX_Region) .Select(c => new object[] { c.VisitadosFarmacia }).ToArray(); List <Point> misPuntos = new List <Point>(); int i = 0; foreach (object v in valPuntos) { Point punto = new Point { Y = Convert.ToDouble(v), Color = Color.FromName("colors[" + i + "]") }; misPuntos.Add(punto); i++; } Highcharts chart1 = new DotNet.Highcharts.Highcharts("chart1") .SetCredits(new Credits { Enabled = false }) .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column, Height = 250 }) .SetTitle(new Title { Text = "Coberturas" }) .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "(%) Porcentajes" } }) .SetXAxis(new XAxis { Title = new XAxisTitle { Text = "Regiones" }, Categories = regiones }) .SetSeries(new[] { new Series { Name = "Cobertura Médica (Mix)", Data = new Data(valCoberturaMedica) }, new Series { Name = "Cobertura Farmacias", Data = new Data(valCoberturaFarmacia) }, new Series { Name = "Cobertura Hospitales", Data = new Data(valCoberturaHospital) }, }); var valAltasBajas = db.SP_MW_Dashboard_AltasBajas().First(); Highcharts chart3 = new Highcharts("chart3") .SetCredits(new Credits { Enabled = false }) .InitChart(new Chart { Height = 200 }) .SetTitle(new Title { Text = "Altas y Bajas" }) .SetTooltip(new Tooltip { Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }" }) .SetTooltip(new Tooltip { Formatter = "TooltipFormatter" }) .SetXAxis(new XAxis { Categories = new[] { "Altas", "Bajas" } }) .AddJavascripFunction("TooltipFormatter", @"var s; if (this.point.name) { // the pie chart s = ''+ this.point.name +': '+ this.y +'%'; } else { s = ''+ 'Médicos: '+ this.y; } return s;") .SetLabels(new Labels { Items = new[] { new LabelsItems { Html = "% Altas y Bajas", Style = "left: '165px', top: '8px', color: 'black'" } } }) .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Cantidad de Médicos" } }) .SetPlotOptions(new PlotOptions { Pie = new PlotOptionsPie { Center = new[] { new PercentageOrPixel(170), new PercentageOrPixel(40) }, Size = new PercentageOrPixel(60), ShowInLegend = false, DataLabels = new PlotOptionsPieDataLabels { Enabled = false } }, Column = new PlotOptionsColumn { ShowInLegend = false, DataLabels = new PlotOptionsColumnDataLabels { Enabled = true } } }) .SetSeries(new[] { new Series { Type = ChartTypes.Column, Data = new Data(new[] { new Point { //Name = "Altas", DataLabels = false, Y = valAltasBajas.NU_Altas, Color = Color.FromName("Highcharts.getOptions().colors[0]") }, new Point { //Name = "Bajas", DataLabels = false, Y = valAltasBajas.NU_Bajas, Color = Color.FromName("Highcharts.getOptions().colors[1]") } }) }, new Series { Type = ChartTypes.Pie, Name = "Total", Data = new Data(new[] { new Point { Name = "Altas", Y = Convert.ToDouble(valAltasBajas.NU_PRCAltas), Color = Color.FromName("Highcharts.getOptions().colors[0]") }, new Point { Name = "Bajas", Y = Convert.ToDouble(valAltasBajas.NU_PRCBajas), Color = Color.FromName("Highcharts.getOptions().colors[1]") } } ) } }); var valAVGFichas = db.SP_MW_Dashboard_PromedioFichas().First(); //IMPORTANTE Para que el Angular Gauge funcione debe estar en el _Layout el script "highcharts-more.js" Highcharts chart4 = new Highcharts("chart4") .SetCredits(new Credits { Enabled = false }) .InitChart(new Chart { Type = ChartTypes.Gauge, PlotBackgroundColor = null, PlotBackgroundImage = null, PlotBorderWidth = 0, PlotShadow = false, Height = 250 }) .SetTitle(new Title { Text = "% de Fichas Llenas" }) .SetPane(new Pane { StartAngle = -150, EndAngle = 120, Background = new[] { new BackgroundObject { BackgroundColor = new BackColorOrGradient(new Gradient { LinearGradient = new[] { 0, 0, 0, 1 }, Stops = new object[, ] { { 0, "#FFF" }, { 1, "#333" } } }), BorderWidth = new PercentageOrPixel(0), OuterRadius = new PercentageOrPixel(109, true) }, new BackgroundObject { BackgroundColor = new BackColorOrGradient(new Gradient { LinearGradient = new[] { 0, 0, 0, 1 }, Stops = new object[, ] { { 0, "#333" }, { 1, "#FFF" } } }), BorderWidth = new PercentageOrPixel(1), OuterRadius = new PercentageOrPixel(107, true) }, new BackgroundObject(), new BackgroundObject { BackgroundColor = new BackColorOrGradient(ColorTranslator.FromHtml("#DDD")), BorderWidth = new PercentageOrPixel(0), OuterRadius = new PercentageOrPixel(105, true), InnerRadius = new PercentageOrPixel(103, true) } } }) .SetYAxis(new YAxis { Min = 0, Max = 100, //MinorTickInterval = "auto", MinorTickWidth = 1, MinorTickLength = 10, MinorTickPosition = TickPositions.Inside, MinorTickColor = ColorTranslator.FromHtml("#666"), TickPixelInterval = 30, TickWidth = 2, TickPosition = TickPositions.Inside, TickLength = 10, TickColor = ColorTranslator.FromHtml("#666"), Labels = new YAxisLabels { Step = 2, //Rotation = "auto" }, Title = new YAxisTitle { Text = "% Fichas" }, PlotBands = new[] { new YAxisPlotBands { From = 0, To = 50, Color = ColorTranslator.FromHtml("#DF5353") }, new YAxisPlotBands { From = 50, To = 90, Color = ColorTranslator.FromHtml("#DDDF0D") }, new YAxisPlotBands { From = 90, To = 100, Color = ColorTranslator.FromHtml("#55BF3B") } } }) .SetSeries(new Series { Name = "Valor", Data = new Data(new object[] { valAVGFichas.Value }) }); model.Charts.Add(chart1); //model.Charts.Add(chart2); model.Charts.Add(chart3); model.Charts.Add(chart4); return(View(model)); }
public ActionResult MonthlyFeeCollection() { Highcharts chart = new Highcharts("MonthlyFeeCollection") .InitChart(new Chart { Width = 390, Height = 305, DefaultSeriesType = ChartTypes.Column }) .SetTitle(new Title { Text = "" }) //.SetSubtitle(new Subtitle { Text = "Source: WorldClimate.com" }) .SetXAxis(new XAxis { Categories = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" } }) .SetYAxis(new YAxis { Min = 0, Title = new YAxisTitle { Text = "" } }) .SetLegend(new Legend { Layout = Layouts.Vertical, Align = HorizontalAligns.Left, VerticalAlign = VerticalAligns.Top, X = 100, Y = 70, Floating = true, BackgroundColor = new BackColorOrGradient(ColorTranslator.FromHtml("#FFFFFF")), Shadow = true }) .SetTooltip(new Tooltip { Formatter = @"function() { return ''+ this.x +': '+ this.y +' Rupees'; }" }) .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { PointPadding = 0.2, BorderWidth = 0 } }) .SetCredits(new Credits { Enabled = false }) .SetExporting(new Exporting { Enabled = false }) .SetSeries(new[] { new Series { Name = "Fee Amount", Data = new Data(new object[] { 49, 71, 106, 129, 144, 56, 67, 55, 45, 67, 95, 54 }) } }); return View(chart); }
// GET: Report public ActionResult Index() { // Get number of each ticket status using (tskmProject.Models.tskmContainer db = new Models.tskmContainer()) { #region Sample: Current Status Ticket Ratio var ticketStatusStat = (from status in db.Status select new { Name = status.statusName, Count = status.Ticket.LongCount() }).ToList(); var ticketStatusRatioChart = new Highcharts("TicketStatusRatio") .SetTitle(new Title { Text = "สรุปสถานะใบงาน" }) .SetSeries(new Series { Type = ChartTypes.Pie, Name = "TicketStatus", Data = new Data(ticketStatusStat.Select(x => new object[] { x.Name, x.Count }).ToArray()) }); ViewBag.TicketStatusRatioChart = ticketStatusRatioChart; #endregion //Ticket Opened/Closed in each month #region Sample: Ticket Opened/Closed in each month var ticketOpenStat = (from ticket in db.Tickets.ToList() group ticket by new { Month = ticket.CreatedDate.Month, Year = ticket.CreatedDate.Year } into g select new DotNet.Highcharts.Options.Point { Name = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(g.Key.Month) + "/" + g.Key.Year, Y = g.Count() }).ToArray(); var ticketCloseStat = (from ticket in db.Tickets.ToList() where ticket.Status.statusName == "Closed" group ticket by new { Month = ticket.UpdatedDate.Month, Year = ticket.UpdatedDate.Year } into g select new DotNet.Highcharts.Options.Point { Name = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(g.Key.Month) + "/" + g.Key.Year, Y = g.Count() }).ToArray(); var ticketOpenCloseStatChart = new Highcharts("TicketOpenCloseStat") .SetTitle(new Title { Text = "การเปิด-ปิดใบงาน" }) .SetXAxis(new DotNet.Highcharts.Options.XAxis { Categories = ticketCloseStat.Union(ticketOpenStat).Select(x => x.Name).GroupBy(x => x).Select(x => x.Key).ToArray() }) .SetSeries(new Series[] { new Series { Type = ChartTypes.Column, Name = "Opened", Data = new Data(ticketOpenStat) }, new Series { Type = ChartTypes.Column, Name = "Closed", Data = new Data(ticketCloseStat) }}); ViewBag.TicketOpenCloseStatChart = ticketOpenCloseStatChart; #endregion //Create/Post KM in each month (Line Chart) #region Sample: Line Chart for KM var knowledgeCreateStat = (from create in db.Knowledgebases.ToList() group create by new { Month = create.knowledgeDate.Month, Year = create.knowledgeDate.Year } into c select new DotNet.Highcharts.Options.Point { Name = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(c.Key.Month) + "/" + c.Key.Year, Y = c.Count() }).ToArray(); var knowledgeCommentStat = (from comment in db.KnowledgeComments.ToList() //where comment.commentDate == DateTime.Now group comment by new { Month = comment.commentDate.Month, Year = comment.commentDate.Year } into c select new DotNet.Highcharts.Options.Point { Name = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(c.Key.Month) + "/" + c.Key.Year, Y = c.Count() }).ToArray(); var knowledgeBaseCommentStatChart = new Highcharts("KnowledgeCreateCommentStat") .SetTitle(new Title { Text = "แนวโน้มการสร้างและถาม-ตอบความรู้" }) .SetXAxis(new DotNet.Highcharts.Options.XAxis { Categories = knowledgeCommentStat.Union(knowledgeCreateStat).Select(x => x.Name).GroupBy(x => x).Select(x => x.Key).ToArray() }) .SetYAxis(new YAxis { Min = 0 }) .SetSeries(new Series[] { new Series { Type = ChartTypes.Line, Name = "Create", Data = new Data(knowledgeCreateStat) }, new Series { Type = ChartTypes.Line, Name = "Comment", Data = new Data(knowledgeCommentStat) }}); ViewBag.KnowledgeCreateCommentStatChart = knowledgeBaseCommentStatChart; #endregion } return View(); }
protected void Page_Load(object sender, EventArgs e) { var list = //new List<Tuple<string, string>>(); // list.Add(new Tuple<string, string>("START_PERIOD", "January 2017")); // list.Add(new Tuple<string, string>("END_PERIOD", "January 2017")); // list.Add(new Tuple<string, string>("BRAND", "Coca Cola")); // list.Add(new Tuple<string, string>("PRESENTATION_TYPE", "table")); // list.Add(new Tuple<string, string>("CITY_NAME", "NICOSIA")); // list.Add(new Tuple<string, string>("SELECT CLAUSE", "show")); // list.Add(new Tuple<string, string>("Function", "sales")); (List <Tuple <string, string> >)HttpContext.Current.Session["Pairs"]; if (list == null) { Response.Redirect("Default.aspx"); } var serializer = new XmlSerializer(typeof(XMLObject.language)); var loadStream = new FileStream(HttpRuntime.AppDomainAppPath + "\\file2.xml", FileMode.Open, FileAccess.Read); var loadedObject = (XMLObject.language)serializer.Deserialize(loadStream); var FROM = new List <string>(); var GROUP_BY = new List <string>(); var SELECT = new List <string>(); var WHERE = new List <string>(); FROM.Add("[NQL].[dbo].[PROCESSED_DATA]"); string ptype = ""; string period = ""; foreach (var item in list) { if (item.Item1.Equals("START_PERIOD")) { period = "PERIOD_ID BETWEEN " + "[NQL].[dbo].[GET_PERIOD_ID]('" + item.Item2 + "')" + " AND "; } // Console.WriteLine(loadedObject.dimensions.product.); if (item.Item1.Equals("END_PERIOD")) { period += "[NQL].[dbo].[GET_PERIOD_ID]('" + item.Item2 + "')"; } if (item.Item1.Equals("PRESENTATION_TYPE")) { ptype = item.Item2; } } WHERE.Add(period); string putLast = ""; foreach (var item in list) { if (!item.Item1.Equals("START_PERIOD") && !item.Item1.Equals("END_PERIOD") && !item.Item1.Equals("PRESENTATION_TYPE") && !item.Item1.Equals("SELECT CLAUSE")) { if (item.Item1.Equals("FUNCTION")) { putLast = item.Item2; SELECT.Add("PERIOD_NAME"); // SELECT.Add(item.Item2); GROUP_BY.Add("PERIOD_NAME"); } else if (!SELECT.Contains(item.Item1)) { SELECT.Add(item.Item1); GROUP_BY.Add(item.Item1); string tmp = ""; tmp = item.Item1 + "='" + item.Item2 + "'"; WHERE.Add(tmp); } } } if (putLast.ToLower().Trim().Equals("sales value")) { SELECT.Add("SUM(SALES_VALUE) AS SALES_VALUE"); } if (putLast.ToLower().Trim().Equals("sales volume")) { SELECT.Add("SUM(SALES_VOLUME) AS SALES_VOLUME"); } if (putLast.ToLower().Trim().Equals("sales") || putLast.ToLower().Trim().Equals("sales items")) { SELECT.Add("SUM(SALES_QUANTITY) AS SALES_QUANTITY"); } SELECT = SELECT.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList(); WHERE = WHERE.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList(); GROUP_BY = GROUP_BY.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList(); string query = "SELECT "; string select = ""; var last = SELECT.Last(); foreach (var VARIABLE in SELECT) { // query += VARIABLE; if (VARIABLE.Equals(last)) { select += VARIABLE + " "; } else { select += VARIABLE + ", "; } } loadedObject.result.SELECT = select; query += select; query += "\nFROM "; string from = ""; last = FROM.Last(); foreach (var VARIABLE in FROM) { // query += VARIABLE; if (VARIABLE.Equals(last)) { from += VARIABLE + " "; } else { from += VARIABLE + ", "; } } query += from; loadedObject.result.FROM = from; if (WHERE.Count > 0) { query += "\nWHERE "; last = WHERE.Last(); string where = ""; foreach (var VARIABLE in WHERE) { // query += VARIABLE; if (VARIABLE.Equals(last)) { where += VARIABLE + " "; } else { where += VARIABLE + " AND "; } } query += where; loadedObject.result.WHERE = where; } query += "\nGROUP BY "; last = GROUP_BY.Last(); string groupby = ""; foreach (var VARIABLE in GROUP_BY) { // query += VARIABLE; if (VARIABLE.Equals(last)) { groupby += VARIABLE + " "; } else { groupby += VARIABLE + ", "; } } query += groupby; loadedObject.result.GROUP_BY = groupby; using (var writer = new StreamWriter(HttpRuntime.AppDomainAppPath + "\\result.xml")) { serializer.Serialize(writer, loadedObject); writer.Flush(); } loadStream.Close(); multitxt.Text = query; DataTable dt = GetData(query); gridView.DataSource = dt; gridView.DataBind(); gridView.UseAccessibleHeader = true; // gridView.HeaderRow.TableSection = TableRowSection.TableHeader; DataColumnCollection columns = dt.Columns; string myStr = ""; if (columns.Contains("SALES_VALUE")) { myStr = "SALES_VALUE"; } if (columns.Contains("SALES_VOLUME")) { myStr = "SALES_VOLUME"; } if (columns.Contains("SALES_QUANTITY")) { myStr = "SALES_QUANTITY"; } // SerializedDataOfChart(query); DataView dv = new DataView(dt); DataTable dtT = dv.ToTable(true, "PERIOD_NAME", myStr); List <string> ctgries = new List <string>(); var values = new List <double>(); foreach (DataRow row in dtT.Rows) { ctgries.Add(Convert.ToString(row["PERIOD_NAME"])); values.Add(Convert.ToDouble(row[myStr])); } string[] ca = ctgries.ToArray(); object[] cc = values.Select(d => (object)d).ToArray(); if (ptype.ToLower().Trim().Equals("table")) { gridView.Visible = true; } else if (ptype.ToLower().Trim().Equals("line chart")) { ltrChart.Visible = true; DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart").SetXAxis(new XAxis { Categories = ca }).SetSeries(new Series { Data = new Data(cc), Name = myStr }).SetTitle(new Title { Text = "Line Chart" }); ltrChart.Text = chart.ToHtmlString(); } else if (ptype.ToLower().Trim().Equals("bar chart")) { ltrChart.Visible = true; DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart") .InitChart(new Chart { DefaultSeriesType = ChartTypes.Bar }) .SetTitle(new Title { Text = "Bar Chart" }) .SetXAxis(new XAxis { Categories = ca }) .SetYAxis(new YAxis { Min = 0, Title = new YAxisTitle { Text = myStr, Align = AxisTitleAligns.High } }) .SetPlotOptions(new PlotOptions { Bar = new PlotOptionsBar { DataLabels = new PlotOptionsBarDataLabels { Enabled = true } } }) // .SetLegend(new Legend // { // Layout = Layouts.Vertical, // Align = HorizontalAligns.Right, // VerticalAlign = VerticalAligns.Top, // X = -100, // Y = 100, // Floating = true, // BorderWidth = 1, // BackgroundColor = new BackColorOrGradient(ColorTranslator.FromHtml("#FFFFFF")), // Shadow = true // }) .SetSeries(new Series { Data = new Data(cc), Name = myStr }); ltrChart.Text = chart.ToHtmlString(); } // foreach (DataRow row in dtT.Rows) // { // ctgries.Add(Convert.ToString(row["PERIOD_NAME"])); // values.Add(Convert.ToDouble(row[myStr])); // // // string[] ca = ctgries.ToArray(); // object[] cc = values.Select(d => (object)d).ToArray(); // DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("barchart").SetXAxis(new XAxis // { // Categories = ca // }).SetSeries(new Series // { // Name = myStr, // Data = new Data(cc) // }); // barChart.Text = chart.ToHtmlString(); // } }
public ActionResult GetSearchResult(int month, int year, int companyId, int productgrpId) { var properties = _repository.GetAllProperty().Where(m => m.Company_Id == companyId).Select(c => c.Row_Id).ToList(); var orderIds = _repository.GetAllOrders().Where(o => properties.Contains((int)o.Property_Id)).Select(x => x.Row_Id).ToList(); DateTime currentMonth = new DateTime(year, month, DateTime.Now.Day); var thisMonthStart = currentMonth.AddDays(1 - currentMonth.Day); var thisMonthEnd = thisMonthStart.AddMonths(1).AddSeconds(-1); var orderItems = _repository.GetAllOrderItems().Where(o => orderIds.Contains((int)o.Order_Id)).ToList(); DashboardViewModel dashboardViewModel = new DashboardViewModel(); dashboardViewModel.OrderQuantity = new object[thisMonthEnd.Day]; dashboardViewModel.Days = new string[thisMonthEnd.Day]; dashboardViewModel.DaysInMonth = thisMonthEnd.Day; for (int i = 0; i < thisMonthEnd.Day; i++) { dashboardViewModel.OrderQuantity[i] = (orderItems.Where(x => x.Created.Equals(thisMonthStart)).Count()); dashboardViewModel.Days[i] = (i + 1).ToString(); thisMonthStart.AddDays(1); } Highcharts chart = new Highcharts("chart") .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column }) .SetTitle(new Title { Text = "Monthly Order" }) .SetSubtitle(new Subtitle { Text = "" }) .SetXAxis(new XAxis { Categories = dashboardViewModel.Days }) .SetYAxis(new YAxis { Min = 0, Title = new YAxisTitle { Text = "Orders quantity" } }) .SetLegend(new Legend { Layout = Layouts.Vertical, Align = HorizontalAligns.Left, VerticalAlign = VerticalAligns.Top, X = 100, Y = 70, Floating = true, BackgroundColor = new BackColorOrGradient(ColorTranslator.FromHtml("#FFFFFF")), Shadow = true }) .SetTooltip(new Tooltip { Formatter = @"function() { return ''+ this.x +': '+ this.y ; }" }) .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { PointPadding = 0.2, BorderWidth = 0 } }) .SetSeries(new[] { //new Series { Name = "Order", Data = new Data(dashboardViewModel.OrderQuantity) }, new Series { Name = "Order", Data = new Data(new object[] { 48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,21.7 }) }, //new Series { Name = "New York", Data = new Data(new object[] { 83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3 }) }, //new Series { Name = "Berlin", Data = new Data(new object[] { 42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1 }) } }); return PartialView("GetSearchResult", chart); //return Json(dashboardViewModel, JsonRequestBehavior.AllowGet); }
public Charts chart(String id) { using (db) { var reptileType = db.Reptiles.FirstOrDefault(r => r.ReptileId == id); var weights = (from w in db.Weights where w.ReptileId == id select w.Weights); var feedings = (from f in db.Feedings where f.ReptileId == id select f.NumItemsFed); var lengths = (from l in db.Lengths where l.ReptileId == id select l.Lengths); Object[] AvgForSpecies = new Object[12]; DateTime newDate = DateTime.UtcNow; DateTime born = reptileType.Born.Value; TimeSpan ts = newDate - born; int age = ts.Days; if (age > 365) { AvgForSpecies = new Object[12]; } else { if (reptileType.ScientificName.Equals("Python regius")) { AvgForSpecies = new Object[] { 61.73, 82.20, 146.47, 230.33, 288.20, 346.40, 377.87, 406.20, 445.20, 476.73, 506.27, 546, }; } else if (reptileType.ScientificName.Equals("Eublepharis macularius")) { AvgForSpecies = new Object[] { 2, 4, 5.5, 7.23, 9, 12.43, 15.98, 17, 18.96, 24, 30, 37, }; } } List<int> WeightAmount = new List<int>(); List<int> FeedingsAmount = new List<int>(); List<Double> LengthsAmount = new List<Double>(); foreach (var w in weights) { WeightAmount.Add(w); } foreach (var f in feedings) { FeedingsAmount.Add(f); } foreach (var l in lengths) { LengthsAmount.Add(l); } WeightAmount.ToArray(); object[] newWeightsObj; newWeightsObj = WeightAmount.Cast<object>().ToArray(); FeedingsAmount.ToArray(); object[] newFeedingsObj; newFeedingsObj = FeedingsAmount.Cast<object>().ToArray(); LengthsAmount.ToArray(); object[] newLengthsObj; newLengthsObj = LengthsAmount.Cast<object>().ToArray(); Highcharts g2 = new Highcharts("chart2") .InitChart(new Chart { Type = ChartTypes.Column }) .SetTitle(new Title { Text = "Feedings" }) .SetCredits(new Credits { Enabled = false }) .SetXAxis(new XAxis { Categories = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" } }) .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "grams" } }) .SetTooltip(new Tooltip { Formatter = @"function() { return ''+ this.x +': '+ this.y +' grams'; }" }) .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { PointPadding = 0.2, BorderWidth = 0 } }) .SetSeries(new[] { new Series {Color = ColorTranslator.FromHtml("#87CEFA"),Name = "Feedings", Data = new Data(newFeedingsObj)}, new Series {Color = ColorTranslator.FromHtml("#FF66FF") ,Name = "Weight", Data = new Data(newWeightsObj)}, new Series {Color = ColorTranslator.FromHtml("#6C7A89") ,Name = "Average", Data = new Data(AvgForSpecies)} }); Highcharts g1 = new Highcharts("chart1") .InitChart(new Chart { Type = ChartTypes.Areaspline }) .SetTitle(new Title { Text = "Weights for each month " }) .SetCredits(new Credits { Enabled = false }) .SetXAxis(new XAxis { Categories = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }, Title = new XAxisTitle { Text = "Months" } }) .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Weight units" } }) .SetSeries(new[] { new Series { Name = "Weights", Data = new Data(newWeightsObj)}, new Series { Color = ColorTranslator.FromHtml("#6C7A89"),Name = "Average", Data = new Data(AvgForSpecies)}, }); Highcharts g3 = new Highcharts("chart3") .InitChart(new Chart { Type = ChartTypes.Areaspline }) .SetTitle(new Title { Text = "Length for each month " }) .SetCredits(new Credits { Enabled = false }) .SetXAxis(new XAxis { Title = new XAxisTitle { Text = "Months" }, Categories = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" } }) .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Length units in inches" } }) .SetSeries(new Series { Name = "Lengths", Data = new Data(newLengthsObj) }); Charts model = new Charts(); model.Chart1 = g1; model.Chart2 = g2; model.Chart3 = g3; return model; } }
private Highcharts GetChart() { object[] BerlinData = new object[] { -0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0 }; string[] Categories = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; object[] LondonData = new object[] { 3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8 }; object[] NewYorkData = new object[] { -0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5 }; object[] TokioData = new object[] { 7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6 }; Highcharts chart = new Highcharts("chart") .InitChart(new Chart { DefaultSeriesType = ChartTypes.Line, MarginRight = 130, MarginBottom = 25, ClassName = "chart" }) .SetTitle(new Title { Text = "Monthly Average Temperature", X = -20 }) .SetSubtitle(new Subtitle { Text = "Source: WorldClimate.com", X = -20 }) .SetXAxis(new XAxis { Categories = Categories }) .SetYAxis(new YAxis { Title = new XAxisTitle { Text = "Temperature (°C)" }, PlotLines = new[] { new XAxisPlotLines { Value = 0, Width = 1, Color = ColorTranslator.FromHtml("#808080") } } }) .SetTooltip(new Tooltip { Formatter = @"function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': '+ this.y +'°C'; }" }) .SetLegend(new Legend { Layout = Layouts.Vertical, Align = HorizontalAligns.Right, VerticalAlign = VerticalAligns.Top, X = -10, Y = 100, BorderWidth = 0 }) .SetSeries(new[] { new Series { Name = "Tokyo", Data = new DotNet.Highcharts.Helpers.Data(TokioData) }, new Series { Name = "New York", Data = new DotNet.Highcharts.Helpers.Data(NewYorkData) }, new Series { Name = "Berlin", Data = new DotNet.Highcharts.Helpers.Data(BerlinData) }, new Series { Name = "London", Data = new DotNet.Highcharts.Helpers.Data(LondonData) } } ); return chart; }
// GET: Graficos public ActionResult Index() { var produto = new Produto(); var intArray = _produtoBo.ObterProdutos().Select(x => x.Quantidade); var objectArray = intArray.Cast <object>().ToArray(); DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart") .InitChart(new Chart { DefaultSeriesType = ChartTypes.Bar }) .SetTitle(new Title { Text = "Quantidade de Produtos Comprados" }) .SetXAxis(new XAxis { Categories = _produtoBo.ObterProdutos().Select(x => x.Produto).ToArray() }) .SetYAxis(new YAxis { Min = 0, Title = new YAxisTitle { Text = "Total Produtos" } }) .SetSeries(new Series { Name = "Produto", Data = new Data(objectArray) }); ViewBag.grafico = chart; var intArrayCompra = _compraBo.ObterCompra().Select(x => x.QuantidadeItem); var objArrayCompra = intArrayCompra.Cast <object>().ToArray(); DotNet.Highcharts.Highcharts graficoCompra = new DotNet.Highcharts.Highcharts("graficoCompra") .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column }) .SetTitle(new Title { Text = "Quantidade de Compras" }) .SetXAxis(new XAxis { Categories = _compraBo.ObterCompra().Select(x => x.Compra).ToArray() }) .SetYAxis(new YAxis { Min = 0, Title = new YAxisTitle { Text = "Total de itens por Compras" } }) .SetSeries(new Series { Name = "Compras", Data = new Data(objArrayCompra) }); ViewBag.Compra = graficoCompra; return(View()); }
// // GET: /Home/ public ActionResult Index() { DbDataContext dt = new DbDataContext(); //Fetching data from db: var voltageValues = dt.Values.Where(v => v.FieldName == "Voltage").OrderBy(v => v.Datetime).ToList<Value>(); var currentValues = dt.Values.Where(v => v.FieldName == "Current").OrderBy(v => v.Datetime).ToList<Value>(); Highcharts Chart = new Highcharts("Chart"); // Initiizing chart // Making month and days persian, however it is not accurate at all! Chart.SetOptions(new GlobalOptions { Lang = new DotNet.Highcharts.Helpers.Lang { Loading = "در حال بارگذاری", Months = new string[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند" }, Weekdays = new string[] { "شنبه", "یک شنبه", "دوشنبه", "سه شنبه", "چهارشنبه", "پنج شنبه", "جمعه" }, ShortMonths = new string[] { "فرور", "اردی", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند" } } }); Chart.InitChart(new Chart { DefaultSeriesType = ChartTypes.Line, MarginRight = 130, MarginBottom = 55, ClassName = "chart", ZoomType = ZoomTypes.X }) .SetTitle(new Title { Text = "نمودار تغییرات داده ها " }) .SetSubtitle(new Subtitle { Text = "نمونه استفاده نمودار", X = -20 }) .SetXAxis(new XAxis { Type = AxisTypes.Datetime, Title = new XAxisTitle { Text = "بازه زمانی از ... تا..." }, MinorTickInterval = 3600 * 1000, TickLength = 1, MinRange = 3600 * 1000, MinTickInterval = 3600 * 1000, GridLineWidth = 1, Labels = new XAxisLabels { Align = HorizontalAligns.Right, Rotation = -30, }, DateTimeLabelFormats = new DateTimeLabel { Second = "%H:%M:%S", Minute = "%H:%M", Hour = "%H:%M", Day = "%e %b", Week = "%e %b", Month = "%b", Year = "%Y", }, ShowEmpty = false, }) .SetLegend(new Legend { Layout = Layouts.Vertical, Align = HorizontalAligns.Left, X = 20, VerticalAlign = VerticalAligns.Top, Y = 80, BackgroundColor = new BackColorOrGradient(System.Drawing.ColorTranslator.FromHtml("#FFFFFF")) }); YAxis[] yAxis = new YAxis[2]; yAxis[0] = (new YAxis { Title = new YAxisTitle { Text = string.Format("{0} ({1})", "Voltage", "V"), }, Labels = new YAxisLabels { //Align = HorizontalAligns.Right, Formatter = "function() { return this.value; }", }, Opposite = true, GridLineWidth = 0 }); yAxis[1] = (new YAxis { Title = new YAxisTitle { Text = string.Format("{0} ({1})", "Current", "A"), }, Labels = new YAxisLabels { //Align = HorizontalAligns.Left, Formatter = "function() { return this.value; }", }, Opposite = false, GridLineWidth = 1 }); Chart.SetYAxis(yAxis); Series[] seriesOfData = new Series[2]; object[,] x1 = new object[voltageValues.Count(), 2]; for (int i = 0; i < voltageValues.Count(); i++) { x1[i, 0] = PersianDateTime.ParseFromDateTime(voltageValues[i].Datetime).ToString("Date.parse('MM/dd/yyyy HH:mm:ss')"); x1[i, 1] = voltageValues[i].Value1; } DotNet.Highcharts.Helpers.Data data1 = new DotNet.Highcharts.Helpers.Data(x1); Series series1 = new Series { Name = "Voltage", Data = data1, Type = ChartTypes.Line, }; series1.YAxis = "0"; seriesOfData[0] = series1; object[,] x2 = new object[currentValues.Count(), 2]; for (int i = 0; i < voltageValues.Count(); i++) { x2[i, 0] = PersianDateTime.ParseFromDateTime(voltageValues[i].Datetime).ToString("Date.parse('MM/dd/yyyy HH:mm:ss')"); x2[i, 1] = currentValues[i].Value1; } DotNet.Highcharts.Helpers.Data data2 = new DotNet.Highcharts.Helpers.Data(x2); Series series2 = new Series { Name = "Current", Data = data2, Type = ChartTypes.Spline, }; series1.YAxis = "1"; seriesOfData[1] = series2; Chart.SetSeries(seriesOfData); ViewBag.Chart = Chart; return View(); }
public void BuildChart() { int kpiId = KpiId; string strategyId = ""; string startingPeriod = ""; string endingPeriod = ""; decimal target = 0; int firstDayOfWeek = Artexacta.App.Configuration.Configuration.GetFirstDayOfWeek(); List <KpiChartData> measurements = KpiMeasurementBLL.GetKPIMeasurementForChart(kpiId, CategoryId, CategoryItemId, firstDayOfWeek, ref strategyId, ref target, ref startingPeriod, ref endingPeriod); Dictionary <string, object> standardSerie = new Dictionary <string, object>(); Dictionary <string, object> targetStandardSerie = new Dictionary <string, object>(); Dictionary <string, object> sumSerie = new Dictionary <string, object>(); Dictionary <string, object> targetSumSerie = new Dictionary <string, object>(); KPI objKpi = KPIBLL.GetKPIById(kpiId); bool hasTarget = target != -1; bool isSum = strategyId == "SUM"; bool isTargetUsable = false; //bool isSerieUsable = false; decimal sumMeasurement = 0; decimal sumTarget = 0; foreach (var item in measurements) { //if (!string.IsNullOrEmpty(startingPeriod) && item.Period == startingPeriod) // isSerieUsable = true; //if (isSerieUsable) standardSerie.Add(item.Period, item.Measurement); //else // standardSerie.Add(item.Period, null); if (isSum) { sumMeasurement = sumMeasurement + item.Measurement; //if (isSerieUsable) sumSerie.Add(item.Period, sumMeasurement); //else // sumSerie.Add(item.Period, null); if (hasTarget) { if (!string.IsNullOrEmpty(startingPeriod) && item.Period == startingPeriod) { isTargetUsable = true; } if (!string.IsNullOrEmpty(endingPeriod) && item.Period == endingPeriod) { isTargetUsable = false; } if (isTargetUsable) { sumTarget = sumTarget + target; targetSumSerie.Add(item.Period, sumTarget); } else { targetSumSerie.Add(item.Period, null); } } } if (hasTarget) { if (!string.IsNullOrEmpty(startingPeriod) && item.Period == startingPeriod) { isTargetUsable = true; } if (!string.IsNullOrEmpty(endingPeriod) && item.Period == endingPeriod) { isTargetUsable = false; } if (isTargetUsable) { targetStandardSerie.Add(item.Period, target); } else { targetStandardSerie.Add(item.Period, null); } } } List <Series> series = new List <Series>(); series.Add(new Series { Name = Resources.KpiDetails.ValuesLabel, Data = new Data(standardSerie.Values.ToArray <object>()) }); if (hasTarget) { series.Add(new Series { Name = Resources.KpiDetails.KpiTargetLabel, Color = System.Drawing.Color.Red, Data = new Data(targetStandardSerie.Values.ToArray <object>()) }); } DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts(ClientID) .InitChart(new Chart() { Type = ChartTypes.Line }) .SetTitle(new Title() { Text = "" }) .SetXAxis(new XAxis { Categories = standardSerie.Keys.ToArray <string>() }) .SetSeries(series.ToArray()) .SetLegend(new Legend() { Layout = Layouts.Horizontal, Align = HorizontalAligns.Center, VerticalAlign = VerticalAligns.Bottom, BorderWidth = 0 }); if (objKpi.UnitID != "TIME") { //chart.SetTooltip(new Tooltip() //{ // ValueSuffix = " " + objKpi.uni.ToLower() + "s" //}); } else { chart.SetTooltip(new Tooltip() { Formatter = "function (){" + "return decimalToYYMMDDhhmm(this.y).toString('" + Resources.DataTime.YearsValueSingle + "','" + Resources.DataTime.YearsValue + "'," + "'" + Resources.DataTime.MonthsValueSingle + "'," + "'" + Resources.DataTime.MonthsValue + "'," + "'" + Resources.DataTime.DaysValueSingle + "'," + "'" + Resources.DataTime.DaysValue + "'," + "'" + Resources.DataTime.HoursValueSingle + "'," + "'" + Resources.DataTime.HoursValue + "'," + "'" + Resources.DataTime.MinutesValueSingle + "'," + "'" + Resources.DataTime.MinutesValue + "');" + "}" }); } ChartLiteral.Text = chart.ToHtmlString(); if (isSum) { series = new List <Series>(); series.Add(new Series { Name = Resources.KpiDetails.ValuesLabel, Data = new Data(sumSerie.Values.ToArray <object>()) }); if (hasTarget) { series.Add(new Series { Name = Resources.KpiDetails.KpiTargetLabel, Color = System.Drawing.Color.Red, Data = new Data(targetSumSerie.Values.ToArray <object>()) }); } chart = new DotNet.Highcharts.Highcharts(ClientID + "_sum") .InitChart(new Chart() { Type = ChartTypes.Line }) .SetTitle(new Title() { Text = "" }) .SetXAxis(new XAxis { Categories = standardSerie.Keys.ToArray <string>() }) .SetSeries(series.ToArray()) .SetLegend(new Legend() { Layout = Layouts.Horizontal, Align = HorizontalAligns.Center, VerticalAlign = VerticalAligns.Bottom, BorderWidth = 0 }); if (objKpi.UnitID != "TIME") { //chart.SetTooltip(new Tooltip() //{ // ValueSuffix = " " + objKpi.uni.ToLower() + "s" //}); } else { chart.SetTooltip(new Tooltip() { Formatter = "function (){" + "return decimalToYYMMDDhhmm(this.y).toString('" + Resources.DataTime.YearsValueSingle + "','" + Resources.DataTime.YearsValue + "'," + "'" + Resources.DataTime.MonthsValueSingle + "'," + "'" + Resources.DataTime.MonthsValue + "'," + "'" + Resources.DataTime.DaysValueSingle + "'," + "'" + Resources.DataTime.DaysValue + "'," + "'" + Resources.DataTime.HoursValueSingle + "'," + "'" + Resources.DataTime.HoursValue + "'," + "'" + Resources.DataTime.MinutesValueSingle + "'," + "'" + Resources.DataTime.MinutesValue + "');" + "}" }); } SumChartLiteral.Text = chart.ToHtmlString(); SumChartPanel.Visible = true; } }
protected void Button4_Click(object sender, EventArgs e) { var FASna = (List <string>)Session["Asname"]; var g = FASna.GroupBy(i => i); int countLength = 0; foreach (var grp in g) { countLength++; } object[] data = new object[countLength]; int index = 0; foreach (var grp in g) { data[index] = new object[] { grp.Key, grp.Count() }; index++; } DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart").InitChart(new Chart { DefaultSeriesType = ChartTypes.Pie, PlotShadow = false }) .SetTitle(new Title { Text = "% Path Covered by Autonomous Systems" }) .SetTooltip(new Tooltip { Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }" }) .SetPlotOptions(new PlotOptions { Pie = new PlotOptionsPie { AllowPointSelect = true, Cursor = Cursors.Pointer, DataLabels = new PlotOptionsPieDataLabels { Color = ColorTranslator.FromHtml("#000000"), ConnectorColor = ColorTranslator.FromHtml("#000000"), Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ Math.round(this.percentage) +' %'; }" }, } }) .SetSeries(new Series { Data = new Data(data) }); Literal1.Text = chart.ToHtmlString(); //////////////////// RTT //////////////////////// // Series[] series = new Series[Frttave.Count()]; // string[] array_DistrictNames = new string[Frttave.Count()]; // data = new object[Frttave.Count()]; // int index2 = 0; // foreach (var district in Frttave) // { // series[index2] = new Series { Name = index2.ToString(), Data = new Data(new object[] { district }) }; // array_DistrictNames[index2] = index2.ToString(); // index2++; // } // DotNet.Highcharts.Highcharts chart2 = new DotNet.Highcharts.Highcharts("chart").InitChart(new Chart { DefaultSeriesType = ChartTypes.Column, Margin = new int[] { 50, 50, 100, 80 } }) // .SetTitle(new Title { Text = "District Based Registered Institutes" }) // .SetPlotOptions(new PlotOptions // { // Bar = new PlotOptionsBar // { // DataLabels = new PlotOptionsSeriesDataLabels // { // Enabled = true // } // } // } // ) //.SetXAxis(new XAxis //{ // Categories = new[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30" } //}) // .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Registered Institutions", Align = AxisTitleAligns.High } }) // ; // chart2.SetSeries(series); // Literal2.Text = chart2.ToHtmlString(); }
// GET: Graficos public ActionResult Index() { var produto = new Produto(); var intArray = _produtoBo.ObterProdutos().Select(x => x.Quantidade); var objectArray = intArray.Cast<object>().ToArray(); DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart") .InitChart(new Chart { DefaultSeriesType = ChartTypes.Bar }) .SetTitle(new Title { Text = "Quantidade de Produtos Comprados" }) .SetXAxis(new XAxis { Categories = _produtoBo.ObterProdutos().Select(x => x.Produto).ToArray() }) .SetYAxis(new YAxis { Min = 0, Title = new YAxisTitle { Text = "Total Produtos" } }) .SetSeries(new Series { Name = "Produto", Data = new Data(objectArray) }); ViewBag.grafico = chart; var intArrayCompra = _compraBo.ObterCompra().Select(x => x.QuantidadeItem); var objArrayCompra = intArrayCompra.Cast<object>().ToArray(); DotNet.Highcharts.Highcharts graficoCompra = new DotNet.Highcharts.Highcharts("graficoCompra") .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column }) .SetTitle(new Title { Text = "Quantidade de Compras" }) .SetXAxis(new XAxis { Categories = _compraBo.ObterCompra().Select(x => x.Compra).ToArray() }) .SetYAxis(new YAxis { Min = 0, Title = new YAxisTitle { Text = "Total de itens por Compras" } }) .SetSeries(new Series { Name = "Compras", Data = new Data(objArrayCompra) }); ViewBag.Compra = graficoCompra; return View(); }
//public async Task<FileContentResult> GetChart() //{ // return File(await GetChartsProducts(), "image/png"); //} //private async Task<byte[]> GetChartsProducts() //{ // if(Data == null) Data = await ProductManager.GetSalesProducsAsync(); // var chart = new Chart(300, 400, ChartTheme.Green); // chart.AddTitle("Загальна вартість"); // chart.AddSeries("Counts", xValue: Data, xField: "Name", yValues: Data, yFields: "Count"); // //chart.AddSeries("TotalPrice", xValue: Data, xField: "Name", yValues: Data, yFields: "TotalPrice"); // return chart.GetBytes(); //} //private static readonly ApplicationDbContext _db = new ApplicationDbContext(); //protected override void Dispose(bool disposing) //{ // if (disposing) // { // _db.Dispose(); // } // base.Dispose(disposing); //} private Highcharts GetChartCount(List<ProductInOrderViewModel> data, string name) { if (!data.Any()) return null; var height = Math.Max(400, data.Count * 60); var chart = new Highcharts("cart_" + name) //define the type of chart .InitChart(new Chart { DefaultSeriesType = ChartTypes.Bar, Height = height, Width = null }) //overall Title of the chart .SetTitle(new Title { Text = "Кількість проданих товарів" }) //small label below the main Title //.SetSubtitle(new Subtitle { Text = "Accounting" }) //load the X values .SetXAxis(new XAxis { Categories = data.Select(o => o.Name.Length > 34 ? o.Name.Replace('\'', '`').Remove(34) + "..." : o.Name.Replace('\'', '`')).ToArray(), Labels = new XAxisLabels { Style = " fontSize: '16px'" }, Title = new XAxisTitle { Text = "" } }) //set the Y title .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Кількість товарів, шт.", Style = " fontSize: '18px'" }, Labels = new YAxisLabels { Style = " fontSize: '18px', fontWeight: 'bold'" }, AllowDecimals = false }) .SetTooltip(new Tooltip { Enabled = true, Formatter = @"function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': <b>'+ this.y + '</b> шт.'; }" }) .SetPlotOptions(new PlotOptions { Line = new PlotOptionsLine { DataLabels = new PlotOptionsLineDataLabels { Enabled = true }, EnableMouseTracking = false } }) .SetLegend(new Legend { Enabled = false }) //load the Y values .SetSeries(new[] { new Series {Name = "Кількість", Data = new Data(data.Select(o => new object[] { o.Count }).ToArray()),Color =Color.DodgerBlue }, //you can add more y data to create a second line // new Series { Name = "Other Name", Data = new Data(OtherData) } }); return chart; }
public ActionResult Charts() { DateTime lowerLimitDate = DateTime.Now.AddMonths(-6); var chartData = (from sale in db.Sales.Include(customer => db.Customers) where sale.SaleDate > lowerLimitDate group sale by sale.Customer.Name into groupedSales select groupedSales).ToList(); var categories = new List<string>(); for (int i = 1; i <= 12; i++) { categories.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i)); } Highcharts chart = new Highcharts("Test") .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column }) .SetTitle(new Title { Text = "Ventas promedio en los ultimos 6 meses x Cliente" }) .SetXAxis(new XAxis { Title = new XAxisTitle { Text = "Meses" }, Labels = new XAxisLabels { Format = "{value}", Enabled = true }, Categories = categories.ToArray() }) .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "$ (usd)" } }) .SetSeries( (from groupedSale in chartData select new Series { Name = groupedSale.Key, Data = new Data((from sale in groupedSale group sale by sale.SaleDate.Month into monthGroup select new object[] { monthGroup.Key - 1, monthGroup.Average(sale=>sale.TotalCost) }).ToArray()) }).ToArray() ); //.SetTooltip(new Tooltip{ Formatter = new }); //.SetPlotOptions(new PlotOptions { Series = new PlotOptionsSeries { Stacking = Stackings.Normal } }); return View(chart); }
private Highcharts GetChartPayment(List<ChartDataViewModel> data, string name) { if (!data.Any()) return null; var chart = new Highcharts("cart_" + name) .InitChart(new Chart { DefaultSeriesType = ChartTypes.Bar, Height = null, Width = null }) .SetTitle(new Title { Text = "Кількість проданих товарів по формi оплати" }) .SetXAxis(new XAxis { Categories = data.Select(o => o.Name.Replace('\'', '`')).ToArray(), Labels = new XAxisLabels { Style = " fontSize: '16px'" }, Title = new XAxisTitle { Text = "" } }) .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Кількість товарів, шт.", Style = " fontSize: '18px'" }, AllowDecimals = false, Labels = new YAxisLabels { Style = " fontSize: '18px', fontWeight: 'bold'" } }) .SetTooltip(new Tooltip { Enabled = true, Formatter = @"function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': <b>'+ this.y + '</b> шт.'; }" }) .SetPlotOptions(new PlotOptions { Line = new PlotOptionsLine { DataLabels = new PlotOptionsLineDataLabels { Enabled = true }, EnableMouseTracking = false } }) .SetLegend(new Legend { Enabled = false }) .SetSeries(new[] { new Series {Name = "Кількість проданих товарів", Data = new Data(data: data.Select(o => new object[] { o.Count }).ToArray()), Color =Color.Coral }, }); return chart; }
public ActionResult ViewPrice(int id) { var stockResponse = this.ModelService.GetStock(id); var stocks = stockResponse.Result; var model = new EditViewModel() { Stock = stocks }; int priceCount = stocks.Prices.Count(); string [] dates = new string[priceCount]; object[] prices = new object[priceCount]; int count =0; foreach (Models.PriceModel price in stocks.Prices) { dates[count] = price.HistoryDate.ToString(); prices[count] = price.Price; count++; } DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart") .InitChart(new DotNet.Highcharts.Options.Chart { DefaultSeriesType = ChartTypes.Line, MarginRight = 130, MarginBottom = 25, ClassName = "chart" }) .SetTitle(new Title { Text = "Stock Market Performance", X = -20 }) .SetXAxis(new DotNet.Highcharts.Options.XAxis { Categories = dates }) .SetYAxis(new DotNet.Highcharts.Options.YAxis { Title = new XAxisTitle { Text = "Price in US Dollars" }, PlotLines = new[] { new XAxisPlotLines { Value = 0, Width = 1, Color = ColorTranslator.FromHtml("#808080") } } }) .SetSeries(new[] { new Series { Name = "Prices", Data = new DotNet.Highcharts.Helpers.Data(prices) } }); return View(chart); // return View("ViewPrice", model); //return View(GetChart()); }
protected void Page_Load(object sender, EventArgs e) { var FASna = (List <string>)Session["AsName"]; var Frtta = (List <string>)Session["Rttave"]; List <int> Frttave = new List <int>(); int Rrtt11 = 0; foreach (var item in Frtta) { string Rrtttemp = item; char[] Rendchar = { ' ', 'm', 's' }; string Rtrimen = Rrtttemp.TrimEnd(Rendchar); Rrtt11 = Convert.ToInt16(Rtrimen); Frttave.Add(Rrtt11); } var g = FASna.GroupBy(i => i); int countLength = 0; foreach (var grp in g) { countLength++; } object[] data = new object[countLength]; int index = 0; foreach (var grp in g) { data[index] = new object[] { grp.Key, grp.Count() }; index++; } DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart").InitChart(new Chart { DefaultSeriesType = ChartTypes.Pie, PlotShadow = false }) .SetTitle(new Title { Text = "Province Based Institutions Registration" }) .SetTooltip(new Tooltip { Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }" }) .SetPlotOptions(new PlotOptions { Pie = new PlotOptionsPie { AllowPointSelect = true, Cursor = Cursors.Pointer, DataLabels = new PlotOptionsPieDataLabels { Color = ColorTranslator.FromHtml("#000000"), ConnectorColor = ColorTranslator.FromHtml("#000000"), Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ Math.round(this.percentage) +' %'; }" }, } }) .SetSeries(new Series { Data = new Data(data) }); Literal1.Text = chart.ToHtmlString(); //////////////////// RTT //////////////////////// Series[] series = new Series[Frttave.Count()]; string[] array_DistrictNames = new string[Frttave.Count()]; data = new object[Frttave.Count()]; int index2 = 0; foreach (var district in Frttave) { series[index2] = new Series { Name = index2.ToString(), Data = new Data(new object[] { district }) }; array_DistrictNames[index2] = index2.ToString(); index2++; } DotNet.Highcharts.Highcharts chart2 = new DotNet.Highcharts.Highcharts("chart").InitChart(new Chart { DefaultSeriesType = ChartTypes.Column, Margin = new int[] { 50, 50, 100, 80 } }) .SetTitle(new Title { Text = "District Based Registered Institutes" }) .SetPlotOptions(new PlotOptions { Bar = new PlotOptionsBar { DataLabels = new PlotOptionsSeriesDataLabels { Enabled = true } } } ) .SetXAxis(new XAxis { Categories = new [] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30" } }) .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Registered Institutions", Align = AxisTitleAligns.High } }) ; chart2.SetSeries(series); Literal2.Text = chart2.ToHtmlString(); }
public ActionResult Index() { DateTime lastGenerated; long totalSprays; long publishedSprays; long pendingSprays; long unlistedSprays; long privateSprays; long regularSprays; long nsfwSprays; long animatedSprays; long fadingSprays; long anonymousSprays; long loggedInSprays; List<ThingsOverTime> lastWeekSprays; long numUsers; if (cache.Contains("LastGenerated")) { lastGenerated = (DateTime)cache.Get("LastGenerated"); totalSprays = (long)cache.Get("TotalSprays"); publishedSprays = (long)cache.Get("PublishedSprays"); pendingSprays = (long)cache.Get("PendingSprays"); unlistedSprays = (long)cache.Get("UnlistedSprays"); privateSprays = (long)cache.Get("PrivateSprays"); regularSprays = (long)cache.Get("RegularSprays"); nsfwSprays = (long)cache.Get("NSFWSprays"); animatedSprays = (long)cache.Get("AnimatedSprays"); fadingSprays = (long)cache.Get("FadingSprays"); anonymousSprays = (long)cache.Get("AnonymousSprays"); loggedInSprays = (long)cache.Get("LoggedInSprays"); lastWeekSprays = (List<ThingsOverTime>)cache.Get("LastWeekSprays"); numUsers = (long)cache.Get("NumUsers"); } else { using (var db = new SprayContext()) { totalSprays = db.Sprays.LongCount(s => s.Status != Status.DELETED); anonymousSprays = db.Sprays.LongCount(s => s.Creator == null); loggedInSprays = totalSprays - anonymousSprays; publishedSprays = db.Sprays.LongCount(s => s.Status == Status.PUBLIC); pendingSprays = db.Sprays.LongCount(s => s.Status == Status.UNMODERATED); unlistedSprays = db.Sprays.LongCount(s => s.Status == Status.UNLISTED); privateSprays = totalSprays - publishedSprays - unlistedSprays - anonymousSprays; regularSprays = db.Sprays.LongCount(s => !s.NSFW && !s.Animated && !s.Fading && s.Status != Status.DELETED && s.Creator != null); nsfwSprays = db.Sprays.LongCount(s => s.NSFW && s.Status != Status.DELETED && s.Creator != null); animatedSprays = db.Sprays.LongCount(s => s.Animated && s.Status != Status.DELETED && s.Creator != null); fadingSprays = db.Sprays.LongCount(s => s.Fading && s.Status != Status.DELETED && s.Creator != null); DateTime oldestDate = DateTime.Now.Date.Subtract(TimeSpan.FromDays(30)); var a = db.Sprays.Where(s => s.DateAdded >= oldestDate).OrderBy(s => s.DateAdded).ToList(); var b = a.GroupBy(x => x.DateAdded.Date); var c = b.Select(y => new ThingsOverTime { Date = y.Key.Date, SprayCount = y.LongCount() }); lastWeekSprays = c.ToList(); numUsers = db.Users.LongCount(); } lastGenerated = DateTime.Now; // Remake the cache CacheItemPolicy slidingExpires = new CacheItemPolicy { SlidingExpiration = TimeSpan.FromMinutes(10) }; cache.Add("LastGenerated", lastGenerated, slidingExpires); cache.Add("TotalSprays", totalSprays, slidingExpires); cache.Add("PublishedSprays", publishedSprays, slidingExpires); cache.Add("PendingSprays", pendingSprays, slidingExpires); cache.Add("UnlistedSprays", unlistedSprays, slidingExpires); cache.Add("PrivateSprays", privateSprays, slidingExpires); cache.Add("RegularSprays", regularSprays, slidingExpires); cache.Add("NSFWSprays", nsfwSprays, slidingExpires); cache.Add("AnimatedSprays", animatedSprays, slidingExpires); cache.Add("FadingSprays", fadingSprays, slidingExpires); cache.Add("AnonymousSprays", anonymousSprays, slidingExpires); cache.Add("LoggedInSprays", loggedInSprays, slidingExpires); cache.Add("LastWeekSprays", lastWeekSprays, slidingExpires); cache.Add("NumUsers", numUsers, slidingExpires); } /* * Charts */ #region publishedChart Highcharts publishedChart = new Highcharts("publishedStatus") .InitChart(new Chart { PlotShadow = false }) .SetTitle(new Title { Text = "Spray Status" }) .SetSubtitle(new Subtitle { Text = "(Does not include anonymous sprays)" }) .SetTooltip(new Tooltip { Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.y; }" }) .SetPlotOptions(new PlotOptions { Pie = new PlotOptionsPie { AllowPointSelect = true, Cursor = Cursors.Pointer, DataLabels = new PlotOptionsPieDataLabels { Color = ColorTranslator.FromHtml("#000000"), ConnectorColor = ColorTranslator.FromHtml("#000000"), Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ Math.round(this.percentage) +' %'; }" } } }) .SetCredits(new Credits { Enabled = false }) .SetSeries(new Series { Type = ChartTypes.Pie, Name = "Percent of Each Status", Data = new Data(new object[] { new object[] { "Published", publishedSprays }, new object[] { "Pending Moderation", pendingSprays }, new object[] { "Unlisted", unlistedSprays }, new object[] { "Private", privateSprays } }) }); #endregion #region creatorChart Highcharts anonymousChart = new Highcharts("creatorStatus") .InitChart(new Chart { PlotShadow = false }) .SetTitle(new Title { Text = "Spray Creators" }) .SetTooltip(new Tooltip { Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.y; }" }) .SetPlotOptions(new PlotOptions { Pie = new PlotOptionsPie { AllowPointSelect = true, Cursor = Cursors.Pointer, DataLabels = new PlotOptionsPieDataLabels { Color = ColorTranslator.FromHtml("#000000"), ConnectorColor = ColorTranslator.FromHtml("#000000"), Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ Math.round(this.percentage) +' %'; }" } } }) .SetCredits(new Credits { Enabled = false }) .SetSeries(new Series { Type = ChartTypes.Pie, Data = new Data(new object[] { new object[] { "Anonymous", anonymousSprays }, new object[] { "Logged In", loggedInSprays }, }) }); #endregion #region sprayTypesChart Highcharts sprayTypes = new Highcharts("sprayTypes") .InitChart(new Chart { PlotShadow = false }) .SetTitle(new Title { Text = "Spray Types" }) .SetXAxis(new XAxis { Categories = new[] { "Animated", "Fading", "NSFW", "(Plain)" }, Title = new XAxisTitle { Text = String.Empty } }) .SetYAxis(new YAxis { Min = 0, Title = new YAxisTitle { Text = "# of Sprays", Align = AxisTitleAligns.High } }) .SetTooltip(new Tooltip { Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.y; }" }) .SetPlotOptions(new PlotOptions { Bar = new PlotOptionsBar { DataLabels = new PlotOptionsBarDataLabels { Enabled = true, } } }) .SetLegend(new Legend { Enabled = false }) .SetCredits(new Credits { Enabled = false }) .SetSeries(new Series { Type = ChartTypes.Bar, Data = new Data(new object[] { new object[] { "Animated", animatedSprays }, new object[] { "Fading", fadingSprays }, new object[] { "NSFW", nsfwSprays }, new object[] { "(Plain)", regularSprays } }) }); #endregion #region createdChart var cats = lastWeekSprays.Select(x => x.Date.ToShortDateString()).Take(30).ToList(); cats.Add("Today (so far)"); Highcharts weeklySprayChart = new Highcharts("weeklySprays") .InitChart(new Chart { DefaultSeriesType = ChartTypes.Line, ClassName = "chart" }) .SetTitle(new Title { Text = "Sprays Added Over the Last Month", X = -20 }) .SetXAxis(new XAxis { Categories = cats.ToArray(), Title = new XAxisTitle { Text = "Date" }, Labels = new XAxisLabels { Rotation = -45, Step = 7 }, Max = 31 }) .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "# of Sprays Created" }, PlotLines = new[] { new XAxisPlotLines { Value = 0, Width = 1, Color = ColorTranslator.FromHtml("#808080") } }, Min = 0 }) .SetTooltip(new Tooltip { Formatter = @"function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': '+ this.y; }" }) .SetLegend(new Legend { Enabled = false }) .SetCredits(new Credits { Enabled = false }) .SetSeries(new[] { new Series { Name = "Sprays Created", Data = new Data(lastWeekSprays.Select(x => x.SprayCount).Cast<object>().ToArray()) }, } ); #endregion Stats stats = new Stats { AnimatedSprays = animatedSprays, AnonymousSprays = anonymousSprays, FadingSprays = fadingSprays, LastGenerated = lastGenerated, LoggedInSprays = loggedInSprays, NSFWSprays = nsfwSprays, NumUsers = numUsers, PendingSprays = pendingSprays, PublishedSprays = publishedSprays, PrivateSprays = privateSprays, TotalSprays = totalSprays, UnlistedSprays = unlistedSprays, PublishedChart = publishedChart, AnonymousChart = anonymousChart, SprayTypeChart = sprayTypes, WeeklyChart = weeklySprayChart }; return View(stats); }
// FakeChartName should be unique for each chart on page, and best solution is to provide name without white spaces (e.g. chart1, chartN) public static Highcharts PieChart(string chartTitle, List<object[]> data, Number width, Number height, string fakeChartName, string chartSubtitle) { //remove data with 0 values if (data != null && data.Count > 0) data = data.Where(x => Convert.ToInt32(x[1]) != 0).ToList(); var dataArray = data.ToArray(); var chart = new Highcharts(fakeChartName) .InitChart(new Chart { PlotBackgroundColor = null, PlotBorderWidth = null, PlotShadow = false, Width = width, Height = height }) .SetTitle(new Title { Text = chartTitle }) .SetTooltip(new Tooltip { Formatter = "function() {return Math.round(this.percentage) + ' %' ; }" }) .SetPlotOptions(new PlotOptions { Pie = new PlotOptionsPie { AllowPointSelect = true, Cursor = Cursors.Pointer, DataLabels = new PlotOptionsPieDataLabels { Enabled = true, Color = ColorTranslator.FromHtml("#000000"), ConnectorColor = ColorTranslator.FromHtml("#000000"), Formatter = "function() { return Math.round(this.percentage) +' %'; }", Style = "fontSize: '13px',fontFamily: 'Verdana, sans-serif'" }, ShowInLegend = true } }) .SetSeries(new Series { Type = ChartTypes.Pie, Data = new Data(dataArray ?? new object[] { }) }) .SetCredits(new Credits { Enabled = false }); if (!string.IsNullOrEmpty(chartSubtitle)) { chart .SetSubtitle(new Subtitle { Style = "color: '#ff0000'", Text = chartSubtitle }); } return chart; }
private Highcharts GetChartPrice(List<ProductInOrderViewModel> data, string name) { if (!data.Any()) return null; var height = Math.Max(400, data.Count * 70); var chart = new Highcharts("cart_" + name) .InitChart(new Chart { DefaultSeriesType = ChartTypes.Bar, Height = height, Width = null }) .SetTitle(new Title { Text = "Загальна вартість проданих товарів" }) .SetXAxis(new XAxis { Categories = data.Select(o => o.Name.Length > 34 ? o.Name.Replace('\'', '`').Remove(34) + "..." : o.Name.Replace('\'', '`')).ToArray(), Labels = new XAxisLabels { Style = " fontSize: '16px'" }, Title = new XAxisTitle { Text = "" } }) .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Вартість товарів, грн.", Style = " fontSize: '18px'" }, Labels = new YAxisLabels { Style = " fontSize: '18px', fontWeight: 'bold'", Rotation = 45, //Format = "{value.format(0,3,' ')}" }, ShowFirstLabel = false, ShowLastLabel = false }) .SetTooltip(new Tooltip { Enabled = true, Formatter = @"function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': <b>'+ this.y + '</b> грн.'; }" }) .SetPlotOptions(new PlotOptions { Line = new PlotOptionsLine { DataLabels = new PlotOptionsLineDataLabels { Enabled = true }, EnableMouseTracking = false } }) .SetLegend(new Legend { Enabled = false }) .SetSeries(new[] { new Series {Name = "Загальна вартість", Data = new Data(data: data.Select(o => new object[] { o.Price }).ToArray()), Color =Color.Coral }, }); return chart; }
public static Highcharts StackColumnChart(string chartTitle, Number width, Number height, string[] categories, string yLabel, Series[] seriesData, string fakeChartName, string chartSubtitle, string tooltipFormatter) { var chart = new Highcharts(fakeChartName.Replace(" ", "")) .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column, Width = width, Height = height }) .SetTitle(new Title { Text = chartTitle }) .SetXAxis(new XAxis { Categories = categories }) .SetYAxis(new YAxis { Min = 0, Title = new YAxisTitle { Text = yLabel, Style = "background: '#ffffff',fontSize: '13px',fontFamily: 'Verdana, sans-serif'" }, StackLabels = new YAxisStackLabels { Enabled = true }, }) .SetLegend(new Legend { BorderWidth = 0 }) .SetTooltip(new Tooltip { Enabled = true, FollowPointer = true, Formatter = tooltipFormatter }) .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal, DataLabels = new PlotOptionsColumnDataLabels { Enabled = false } } }) .SetSeries(seriesData ?? new Series[] { }) .SetCredits(new Credits { Enabled = false }); if (!string.IsNullOrEmpty(chartSubtitle)) { chart .SetSubtitle(new Subtitle { Style = "color: '#ff0000'", Text = chartSubtitle }); } return chart; }
private Highcharts GetChartTransact(List<ChartDataViewModel> data, string name) { if (!data.Any()) return null; var chart = new Highcharts("cart_" + name) .InitChart(new Chart { DefaultSeriesType = ChartTypes.Spline, Height = null, Width = null }) .SetTitle(new Title { Text = "Загальні трансакційні витрати покупців" }) .SetXAxis(new XAxis { Categories = data.Select(o => o.Count.ToString()).ToArray(), Labels = new XAxisLabels { Style = " fontSize: '18px', fontWeight: 'bold'" }, AllowDecimals = false, Title = new XAxisTitle { Text = "Номер маршруту", Style = " fontSize: '18px'" } }) .SetYAxis(new YAxis { Labels = new YAxisLabels { Style = " fontSize: '18px', fontWeight: 'bold'" }, Title = new YAxisTitle { Text = "Трансакційні витрати, грн.", Style = " fontSize: '16px'" }, AllowDecimals = true }) .SetTooltip(new Tooltip { Enabled = true, Formatter = @"function() { return '<b>'+ this.series.name +'</b><br/>маршрут '+ this.x +': <b>'+ this.y + '</b> грн.'; }" }) .SetPlotOptions(new PlotOptions { Line = new PlotOptionsLine { DataLabels = new PlotOptionsLineDataLabels { Enabled = true }, EnableMouseTracking = false } }) .SetLegend(new Legend { Enabled = false }) .SetSeries(new[] { new Series {Name = "Трансакційні витрати індівідуальні", Data = new Data(data: data.Select(o => new object[] { o.Value2 }).ToArray()), Color =Color.Coral }, new Series {Name = "Трансакційні витрати колективні", Data = new Data(data: data.Select(o => new object[] { o.Value }).ToArray()), Color =Color.DodgerBlue } }); return chart; }
public static Highcharts ColumnChart(string chartTitle, string yAxisDescriptions, string[] categories, Object[][] categoriesNumbers, Number width, Number height, string mouseHoverDescription, string fakeChartName, string chartSubtitle) { var chart = new Highcharts(fakeChartName) .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column, Margin = new[] { 50, 50, 100, 80 }, Width = width, Height = height }) .SetTitle(new Title { Text = chartTitle }) .SetXAxis(new XAxis { Categories = categories, Labels = new XAxisLabels { Rotation = -45, Align = HorizontalAligns.Right, Style = "background: '#ffffff',fontSize: '13px',fontFamily: 'Verdana, sans-serif'" }, }) .SetYAxis(new YAxis { Min = 0, Title = new YAxisTitle { Text = yAxisDescriptions, Style = "background: '#ffffff',fontSize: '13px',fontFamily: 'Verdana, sans-serif'", } }) .SetLegend(new Legend { Enabled = false }) .SetTooltip(new Tooltip { Enabled = true, FollowPointer = true, Formatter = @"function() { return '<span style=""color: '+this.series.color+'"">' + '" + mouseHoverDescription + @"' + '</span> <b> '+ this.y +'</b>'; }" }) .SetSeries(new Series { Data = new Data(categoriesNumbers ?? new object[] { }) }) .SetCredits(new Credits() { Enabled = false }); if (!string.IsNullOrEmpty(chartSubtitle)) { chart .SetSubtitle(new Subtitle() { Style = "color: '#ff0000'", Text = chartSubtitle }); } return chart; }
public ActionResult Index() { var chartData = this._gameService.GetDataForChart(); var gamesNumbers = Enumerable.Range(0, chartData.FirstOrDefault().Item2.Length); var categories = gamesNumbers.Select(x => x.ToString()).ToArray(); var seriesList = chartData.Select(x => new Series { Name = x.Item1, Data = new Data(x.Item2) }).ToArray(); var chart = new Highcharts("chart") .InitChart(new Chart { DefaultSeriesType = ChartTypes.Line, Height = 600, ZoomType = ZoomTypes.Xy, MarginRight = 130, MarginBottom = 55, ClassName = "chart" }) .SetTitle(new Title { Text = "Punktacja", X = -20 }) .SetSubtitle(new Subtitle { Text = "", X = -20 }) .SetXAxis(new XAxis { Categories = categories, Title = new XAxisTitle { Text = "Mecze" }, ShowFirstLabel = false, StartOnTick = false, EndOnTick = true, Min= 0, ShowLastLabel = true }) .SetYAxis(new YAxis { Title = new XAxisTitle { Text = "Punkty" }, Min = 0, PlotLines = new[] { new XAxisPlotLines { Value = 0, Width = 1, Color = ColorTranslator.FromHtml("#808080") } } }) .SetTooltip(new Tooltip { Formatter = @"function() { return '<b>'+ this.series.name +'</b><br/>'+ 'mecz '+this.x +': pkt. '+ this.y; }" }) .SetLegend(new Legend { Layout = Layouts.Vertical, Align = HorizontalAligns.Right, VerticalAlign = VerticalAligns.Top, X = -10, Y = 100, BorderWidth = 0 }) .SetSeries(seriesList); return View(chart); }
public void BuildChart() { bool hasTarget = true; decimal currentValue = 0; int firstDayOfWeek = Artexacta.App.Configuration.Configuration.GetFirstDayOfWeek(); decimal progress = KPIBLL.GetKpiProgress(KpiId, CategoryId, CategoryItemId, firstDayOfWeek, ref hasTarget, ref currentValue); if (!hasTarget) { CurrentValueLiteral.Text = currentValue.ToString(CultureInfo.InvariantCulture); CurrentValuePanel.Visible = true; return; } DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts(ClientID) .InitChart(new Chart() { Type = ChartTypes.Gauge, PlotBackgroundColor = null, PlotBackgroundImage = null, PlotBorderWidth = 0, PlotShadow = false }) .SetTitle(new Title() { Text = "" }) .SetTooltip(new Tooltip() { ValueSuffix = "%" }) .SetPane(new Pane() { StartAngle = -150, EndAngle = 150, Background = new DotNet.Highcharts.Helpers.BackgroundObject[] { new DotNet.Highcharts.Helpers.BackgroundObject() { BackgroundColor = new DotNet.Highcharts.Helpers.BackColorOrGradient(new DotNet.Highcharts.Helpers.Gradient() { LinearGradient = new int[] { 0, 0, 0, 1 }, Stops = new object[, ] { { 0, "#FFF" }, { 1, "#333" } } }), BorderWidth = new DotNet.Highcharts.Helpers.PercentageOrPixel(1), OuterRadius = new DotNet.Highcharts.Helpers.PercentageOrPixel(109, true) }, new DotNet.Highcharts.Helpers.BackgroundObject() { BackgroundColor = new DotNet.Highcharts.Helpers.BackColorOrGradient(new DotNet.Highcharts.Helpers.Gradient() { LinearGradient = new int[] { 0, 0, 0, 1 }, Stops = new object[, ] { { 0, "#FFF" }, { 1, "#333" } } }), BorderWidth = new DotNet.Highcharts.Helpers.PercentageOrPixel(1), OuterRadius = new DotNet.Highcharts.Helpers.PercentageOrPixel(107, true) }, new DotNet.Highcharts.Helpers.BackgroundObject() , new DotNet.Highcharts.Helpers.BackgroundObject() { BackgroundColor = new DotNet.Highcharts.Helpers.BackColorOrGradient(ColorTranslator.FromHtml("#DDD")), BorderWidth = new DotNet.Highcharts.Helpers.PercentageOrPixel(0), OuterRadius = new DotNet.Highcharts.Helpers.PercentageOrPixel(105, true), InnerRadius = new DotNet.Highcharts.Helpers.PercentageOrPixel(103, true) } } }).SetYAxis(new YAxis() { Min = 0, Max = 100, MinorTickWidth = 1, MinorTickLength = 10, MinorTickPosition = TickPositions.Inside, MinorTickColor = ColorTranslator.FromHtml("#666"), TickPixelInterval = 30, TickWidth = 2, TickPosition = TickPositions.Inside, TickLength = 10, TickColor = ColorTranslator.FromHtml("#666"), Labels = new YAxisLabels() { Step = 2 }, Title = new YAxisTitle() { Text = "%" }, PlotBands = new YAxisPlotBands[] { new YAxisPlotBands() { From = 0, To = 33, Color = ColorTranslator.FromHtml("#DF5353") }, new YAxisPlotBands() { From = 33, To = 66, Color = ColorTranslator.FromHtml("#DDDF0D") }, new YAxisPlotBands() { From = 66, To = 100, Color = ColorTranslator.FromHtml("#55BF3B") } } }) .SetSeries(new Series() { Name = Resources.KpiDetails.CompleteLabel, Data = new DotNet.Highcharts.Helpers.Data(new object[] { progress }) }); ChartLiteral.Text = chart.ToHtmlString(); }