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; }
/// <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 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); }
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)); }
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 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; }
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); }
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; }
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); }
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); }
private void plotConsolidatedData() { //All data graph DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart").InitChart(new Chart { ZoomType = DotNet.Highcharts.Enums.ZoomTypes.X, }) .SetXAxis(new[] { new XAxis { Id = "Month Axes", Categories = datesList, Labels = new XAxisLabels { Step = 15, StaggerLines = 1 } // MinRange=30*24 } //, new XAxis // { // Id="RAM_X", // Type=DotNet.Highcharts.Enums.AxisTypes.Datetime, // // Max=350 // } }); chart.SetTitle(new Title { Text = "Space Weather and Altitude" }); chart.SetSeries(new[] { new Series { YAxis = "Sunspot", XAxis = "Month Axes", Name = "Smoothed SSN", Data = new Data(smoothedSSNList) // PlotOptionsLine=new PlotOptionsLine{PointInterval=24*24*3600000, PointStart=new PointStart(Convert.ToDateTime(datesList[0]))} }, // new Series // { // Name="CPD", // Data = new Data(cpd2), // Color= System.Drawing.Color.Red, // Type=DotNet.Highcharts.Enums.ChartTypes.Columnrange, // XAxis="RAM_X", // YAxis="RAM_Y", // PlotOptionsColumnrange=new PlotOptionsColumnrange{ // Tooltip=new PlotOptionsColumnrangeTooltip{ // PointFormat = "{point.low:%e %b, %y} - {point.high:%e %b, %y}", // HeaderFormat = "<b>{series.name}:</b>{point.y}<br />" //} // } // {PointFormat = "{point.low:%e %b, %y} - {point.high:%e %b, %y}", //HeaderFormat = "<b>{series.name}:</b>{point.x}<br />"}) // }, new Series { XAxis = "Month Axes", YAxis = "Altitude", Name = "Altitude", Data = new Data(altitudeList) }, new Series { XAxis = "Month Axes", YAxis = "Sunspot", Name = "Monthly SSN", Data = new Data(monthlySSNList) }, new Series { XAxis = "Month Axes", YAxis = "Altitude", Name = "Average Dose Values", Data = new Data(avgDoseInAllDataList) } }); chart.SetYAxis(new[] { new YAxis { Id = "Sunspot", Min = 0, Max = 400, TickInterval = 25, Title = new YAxisTitle { Text = "Sunspot Number" } }, new YAxis { Id = "Altitude", Min = 0, Max = 500, TickInterval = 30, Opposite = true, Title = new YAxisTitle { Text = "Altitude [km] and dose values [µGy]" } }, // new YAxis{ // Type=DotNet.Highcharts.Enums.AxisTypes.Linear, // Id="RAM_Y", //} }); ltrChart.Text = chart.ToHtmlString(); }
private void plotRAMData() { //RAM graph DotNet.Highcharts.Highcharts RAMChart = new DotNet.Highcharts.Highcharts("chart1").InitChart(new Chart { ZoomType = DotNet.Highcharts.Enums.ZoomTypes.Y, Type = DotNet.Highcharts.Enums.ChartTypes.Columnrange, Inverted = true }) .SetXAxis(new[] { new XAxis { Type = DotNet.Highcharts.Enums.AxisTypes.Linear, Max = 350, Reversed = false, Title = new XAxisTitle { Text = "Dose values [µGy]" } } }).SetYAxis(new[] { new YAxis { Type = DotNet.Highcharts.Enums.AxisTypes.Datetime, Title = new YAxisTitle { Text = "Date" } } }); RAMChart.SetTitle(new Title { Text = "RAM and CPD" }) .SetTooltip(new Tooltip { PointFormat = "{point.low:%e %b, %y} - {point.high:%e %b, %y}", HeaderFormat = "<b>{series.name}:</b>{point.x}<br />" }); RAMChart.SetSeries(new[] { new Series { Name = "CPD", Data = new Data(cpd), Color = System.Drawing.Color.Red }, new Series { Name = "SM-1", Data = new Data(loc1), }, new Series { Name = "SM-2", Data = new Data(loc2) }, new Series { Name = "SM-3", Data = new Data(loc3) }, new Series { Name = "SM-4", Data = new Data(loc4) } }); ltrRAM.Text = RAMChart.ToHtmlString(); }
/// <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 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; }