private static Chart GenerateLineScatterChart() { Chart chart = new Chart(); chart.Type = Enums.ChartType.Line; Data data = new Data(); data.Labels = new List <string>() { "January", "February", "March", "April", "May", "June", "July" }; data.Datasets = new List <Dataset>(); Options options = new Options() { Scales = new Scales() }; Scales scales = new Scales() { YAxes = new List <Scale>() { new CartesianScale() } }; CartesianScale yAxes = new CartesianScale() { Ticks = new Tick() }; Tick tick = new Tick() { Callback = "function(value, index, values) {return '$' + value;}" }; yAxes.Ticks = tick; scales.YAxes = new List <Scale>() { yAxes }; options.Scales = scales; chart.Options = options; chart.Data = data; return(chart); }
public override void WriteLayerProperties(System.Xml.XmlTextWriter xmlWriter) { xmlWriter.WriteAttributeString("TimeSeries", TimeSeries.ToString()); xmlWriter.WriteAttributeString("BeginRange", BeginRange.ToString()); xmlWriter.WriteAttributeString("EndRange", EndRange.ToString()); xmlWriter.WriteAttributeString("Decay", Decay.ToString()); xmlWriter.WriteAttributeString("CoordinatesType", CoordinatesType.ToString()); xmlWriter.WriteAttributeString("LatColumn", LatColumn.ToString()); xmlWriter.WriteAttributeString("LngColumn", LngColumn.ToString()); xmlWriter.WriteAttributeString("GeometryColumn", GeometryColumn.ToString()); xmlWriter.WriteAttributeString("AltType", AltType.ToString()); xmlWriter.WriteAttributeString("MarkerMix", MarkerMix.ToString()); xmlWriter.WriteAttributeString("ColorMap", ColorMap.ToString()); xmlWriter.WriteAttributeString("MarkerColumn", MarkerColumn.ToString()); xmlWriter.WriteAttributeString("ColorMapColumn", ColorMapColumn.ToString()); xmlWriter.WriteAttributeString("PlotType", PlotType.ToString()); xmlWriter.WriteAttributeString("MarkerIndex", MarkerIndex.ToString()); xmlWriter.WriteAttributeString("MarkerScale", MarkerScale.ToString()); xmlWriter.WriteAttributeString("AltUnit", AltUnit.ToString()); xmlWriter.WriteAttributeString("AltColumn", AltColumn.ToString()); xmlWriter.WriteAttributeString("StartDateColumn", StartDateColumn.ToString()); xmlWriter.WriteAttributeString("EndDateColumn", EndDateColumn.ToString()); xmlWriter.WriteAttributeString("SizeColumn", SizeColumn.ToString()); xmlWriter.WriteAttributeString("HyperlinkFormat", HyperlinkFormat.ToString()); xmlWriter.WriteAttributeString("HyperlinkColumn", HyperlinkColumn.ToString()); xmlWriter.WriteAttributeString("ScaleFactor", ScaleFactor.ToString()); xmlWriter.WriteAttributeString("PointScaleType", PointScaleType.ToString()); xmlWriter.WriteAttributeString("ShowFarSide", ShowFarSide.ToString()); xmlWriter.WriteAttributeString("RaUnits", RaUnits.ToString()); xmlWriter.WriteAttributeString("HoverTextColumn", NameColumn.ToString()); xmlWriter.WriteAttributeString("XAxisColumn", XAxisColumn.ToString()); xmlWriter.WriteAttributeString("XAxisReverse", XAxisReverse.ToString()); xmlWriter.WriteAttributeString("YAxisColumn", YAxisColumn.ToString()); xmlWriter.WriteAttributeString("YAxisReverse", YAxisReverse.ToString()); xmlWriter.WriteAttributeString("ZAxisColumn", ZAxisColumn.ToString()); xmlWriter.WriteAttributeString("ZAxisReverse", ZAxisReverse.ToString()); xmlWriter.WriteAttributeString("CartesianScale", CartesianScale.ToString()); xmlWriter.WriteAttributeString("CartesianCustomScale", CartesianCustomScale.ToString()); xmlWriter.WriteAttributeString("DynamicData", DynamicData.ToString()); xmlWriter.WriteAttributeString("AutoUpdate", AutoUpdate.ToString()); xmlWriter.WriteAttributeString("DataSourceUrl", DataSourceUrl.ToString()); }
public static string GenerateLineChart() { Chart chart = new Chart(); chart.Type = "line"; Data data = new Data(); data.Labels = new List <string>() { "January", "February", "March", "April", "May", "June", "July" }; LineDataset dataset = new LineDataset() { Label = "My First dataset", Data = new List <double>() { 65, 59, 80, 81, 56, 55, 40 }, Fill = "false", LineTension = 0.1, BackgroundColor = "rgba(75, 192, 192, 0.4)", BorderColor = "rgba(75,192,192,1)", BorderCapStyle = "butt", BorderDash = new List <int> { }, BorderDashOffset = 0.0, BorderJoinStyle = "miter", PointBorderColor = new List <string>() { "rgba(75,192,192,1)" }, PointBackgroundColor = new List <string>() { "#fff" }, PointBorderWidth = new List <int> { 1 }, PointHoverRadius = new List <int> { 5 }, PointHoverBackgroundColor = new List <string>() { "rgba(75,192,192,1)" }, PointHoverBorderColor = new List <string>() { "rgba(220,220,220,1)" }, PointHoverBorderWidth = new List <int> { 2 }, PointRadius = new List <int> { 1 }, PointHitRadius = new List <int> { 10 }, SpanGaps = false }; data.Datasets = new List <Dataset>(); data.Datasets.Add(dataset); Options options = new Options() { Scales = new Scales() }; Scales scales = new Scales() { YAxes = new List <Scale>() { new CartesianScale() } }; CartesianScale yAxes = new CartesianScale() { Ticks = new Tick() }; Tick tick = new Tick() { Callback = "function(value, index, values) {return '$' + value;}" }; yAxes.Ticks = tick; scales.YAxes = new List <Scale>() { yAxes }; options.Scales = scales; chart.Options = options; chart.Data = data; string code = chart.CreateChartCode("lineChart"); return(code); }
private static Chart GenerateLineChart() { var chart = new Chart { Type = Enums.ChartType.Line }; var data = new Data { Labels = new List <string> { "January", "February", "March", "April", "May", "June", "July" } }; var dataset = new LineDataset { Label = "My First dataset", Data = new List <double> { 65, 59, 80, 81, 56, 55, 40 }, Fill = "false", LineTension = 0.1, BackgroundColor = ChartColor.FromRgba(75, 192, 192, 0.4), BorderColor = ChartColor.FromRgb(75, 192, 192), BorderCapStyle = "butt", BorderDash = new List <int> { }, BorderDashOffset = 0.0, BorderJoinStyle = "miter", PointBorderColor = new List <ChartColor> { ChartColor.FromRgb(75, 192, 192) }, PointBackgroundColor = new List <ChartColor> { ChartColor.FromHexString("#ffffff") }, PointBorderWidth = new List <int> { 1 }, PointHoverRadius = new List <int> { 5 }, PointHoverBackgroundColor = new List <ChartColor> { ChartColor.FromRgb(75, 192, 192) }, PointHoverBorderColor = new List <ChartColor> { ChartColor.FromRgb(220, 220, 220) }, PointHoverBorderWidth = new List <int> { 2 }, PointRadius = new List <int> { 1 }, PointHitRadius = new List <int> { 10 }, SpanGaps = false }; data.Datasets = new List <Dataset> { dataset }; var options = new Options { Scales = new Scales() }; var scales = new Scales { YAxes = new List <Scale> { new CartesianScale() } }; var yAxes = new CartesianScale { Ticks = new Tick() }; var tick = new Tick { Callback = "function(value, index, values) {return '$' + value;}" }; yAxes.Ticks = tick; scales.YAxes = new List <Scale> { yAxes }; options.Scales = scales; chart.Options = options; chart.Data = data; return(chart); }
public async Task <JsonResult> OnPostAsync(string UserInput) { if (!string.IsNullOrEmpty(UserInput)) { List <BinResult> binResults = new List <BinResult>(); string[] keywords = UserInput.Split(" ").Take(5).ToArray(); List <string> jReturns = new List <string>(); foreach (string keyword in keywords) { // data.Labels.Add(keyword); //todo add link to pastbin raw data based on binID try { HttpAsync httpAsync = new HttpAsync(); string response = await httpAsync.Get(PsDumpUrl.Replace("#keyword#", keyword)); if (!string.IsNullOrEmpty(response)) { try { binResults.Add(JsonConvert.DeserializeObject <BinResult>(response)); jReturns.Add(response); } catch (Exception) { } } } catch (Exception) { } } //Create chart Chart chart = new Chart(); chart.Type = Enums.ChartType.Line; LineDataset lineDataset = new LineDataset(); Data data = new Data(); data.Labels = new List <string>(); data.Datasets = new List <Dataset>(); foreach (BinResult binResult in binResults) { LineDataset dataset = new LineDataset(); List <double?> c = new List <double?>(); foreach (var line in binResult.data.GroupBy(f => DateTime.Parse(f.Time).ToUniversalTime() .ToString("Y", System.Globalization.CultureInfo.CreateSpecificCulture("en-US"))) .Select(group => new { xAxis = group.Key, yAxis = group.Count() }) .OrderBy(x => x.xAxis)) { Debug.WriteLine(line.xAxis); if (!data.Labels.Contains(line.xAxis)) { data.Labels.Add(line.xAxis); } if (c.Count() < data.Labels.IndexOf(line.xAxis)) { for (int i = c.Count(); i < data.Labels.IndexOf(line.xAxis); i++) { c.Add(0); } } c.Insert(data.Labels.IndexOf(line.xAxis), (line.yAxis)); Debug.WriteLine("{0} {1} {2}", binResult.Search, line.xAxis, line.yAxis); } lineDataset = CreateChartDataSet(binResult.Search, c); data.Datasets.Add(lineDataset); } Options options = new Options() { Scales = new Scales(), Responsive = true, MaintainAspectRatio = true }; Scales scales = new Scales() { YAxes = new List <Scale>() { new CartesianScale() }, XAxes = new List <Scale>() { new CartesianScale() { Type = "category", Position = "bottom", Ticks = new CartesianLinearTick() { BeginAtZero = false } } } }; CartesianScale yAxes = new CartesianScale() { Ticks = new Tick() }; Tick tick = new Tick() { Callback = "function(value, index, values) {return '#of bins' + value;}" }; yAxes.Ticks = tick; scales.YAxes = new List <Scale>() { yAxes }; options.Scales = scales; chart.Options = options; chart.Data = data; return(new JsonResult(new { table = jReturns, chart = chart.CreateChartCode("lineChart") })); } return(null); }
private static Chart GenerateTempChart() { Chart chart = new Chart(); chart.Type = Enums.ChartType.Line; ChartJSCore.Models.Data data = new ChartJSCore.Models.Data(); List <DateTime> labels = GetTempForecast().Select(e => e.dt).ToList(); List <string> shortLabels = labels.ConvertAll(x => x.ToString("ddd HH mm")); data.Labels = shortLabels; LineDataset dataset = new LineDataset() { Label = "Temperature", Data = GetTempForecast().Select(e => e.temperatureC).ToList(), LineTension = 0.5, BackgroundColor = "rgba(75, 192, 192, 0)", BorderColor = "rgba(244, 66, 66, 1)", BorderCapStyle = "butt", BorderDash = new List <int> { }, BorderDashOffset = 0.0, BorderJoinStyle = "miter", PointBorderColor = new List <string>() { "rgba(244, 66, 66, 1)" }, PointBackgroundColor = new List <string>() { "#fff" }, PointBorderWidth = new List <int> { 3 }, PointHoverRadius = new List <int> { 5 }, PointHoverBackgroundColor = new List <string>() { "rgba(244, 66, 66, 1)" }, PointHoverBorderColor = new List <string>() { "rgba(220,220,220,1)" }, PointHoverBorderWidth = new List <int> { 2 }, PointRadius = new List <int> { 1 }, PointHitRadius = new List <int> { 10 }, SpanGaps = false }; data.Datasets = new List <Dataset>(); data.Datasets.Add(dataset); Options options = new Options() { Scales = new Scales(), Legend = new Legend() { Labels = new LegendLabel() { BoxWidth = 0, FontSize = 18 } } }; Scales scale = new Scales() { }; TimeScale xAxes = new TimeScale() { Ticks = new Tick() }; Tick tick = new Tick() { FontColor = "rgba(244, 66, 66, 1)" }; CartesianScale yAxes = new CartesianScale() { Ticks = new CartesianLinearTick() { Max = 50, BeginAtZero = true, Callback = "function(value, index, values) {return value + ' °C' }" } }; xAxes.Ticks = tick; scale.YAxes = new List <Scale>() { yAxes }; scale.XAxes = new List <Scale>() { xAxes }; options.Scales = scale; chart.Options = options; chart.Data = data; return(chart); }