/// <summary> /// This is the constructor used by non-database-persisted charts <see cref="MonitoringStation.AverageDailyFlowAndCumulativePrecipitationSummaryGoogleChart()"/> /// </summary> public GoogleChartConfiguration(string chartTitle, bool isStacked, GoogleChartType googleChartType, GoogleChartDataTable googleChartDataTable, GoogleChartAxis googleChartAxisHorizontal, List <GoogleChartAxis> googleChartAxisVerticals) { Title = string.IsNullOrWhiteSpace(chartTitle) ? "[MISSING CHART TITLE]" : chartTitle; Legend = new GoogleChartLegend(); HorizontalAxis = googleChartAxisHorizontal; VerticalAxes = googleChartAxisVerticals; BackgroundColor = new GoogleChartBackground("white"); IsStacked = isStacked; LineWidth = 2; SetChartMetaData(googleChartType); var dictionary = new Dictionary <string, GoogleChartSeries>(); var googleChartSeries = googleChartDataTable.GoogleChartColumns.Select(x => x.GoogleChartSeries).ToList(); for (var i = 0; i < googleChartSeries.Count; i++) { dictionary.Add(i.ToString(), googleChartSeries[i]); } Series = dictionary; Annotations = new GoogleChartAnnotations(); }
public GoogleChartSeries(GoogleChartType googleChartType, GoogleChartAxisType googleChartAxisType, string color, int?lineWidth, int?pointSize) { Type = googleChartType.SeriesDataDisplayType; GetTargetAxisIndex(googleChartAxisType); Color = color; LineWidth = lineWidth; PointSize = pointSize; }
//Use this constructor when the chart display is not user-configurable public GoogleChartJson(string legendTitle, string chartContainerID, GoogleChartConfiguration googleChartConfiguration, GoogleChartType googleChartType, GoogleChartDataTable googleChartDataTable, List <string> chartColumns) : this(legendTitle, chartContainerID, googleChartConfiguration, googleChartType, googleChartDataTable, chartColumns, null, null) { }
/// <summary> /// This is the constructor used by <see cref="IndicatorController.New()"/> for creating a default google chart configuation json for new indicators /// </summary> public GoogleChartConfiguration(string chartTitle, bool isStacked, GoogleChartType googleChartType, GoogleChartAxis googleChartAxisHorizontal, List <GoogleChartAxis> googleChartAxisVerticals) { Title = string.IsNullOrWhiteSpace(chartTitle) ? "[MISSING CHART TITLE]" : chartTitle; Legend = new GoogleChartLegend(); HorizontalAxis = googleChartAxisHorizontal; VerticalAxes = googleChartAxisVerticals; BackgroundColor = new GoogleChartBackground("white"); IsStacked = isStacked; LineWidth = 2; SetChartMetaData(googleChartType); Annotations = new GoogleChartAnnotations(); }
//Used where chartConfiguration comes as a GoogleChartConfiguration object public GoogleChartJson(string legendTitle, string chartContainerID, GoogleChartConfiguration googleChartConfiguration, GoogleChartType googleChartType, GoogleChartDataTable googleChartDataTable, string optionalSaveConfigurationUrl, List <string> chartColumns) { LegendTitle = legendTitle; ChartContainerID = chartContainerID; GoogleChartConfiguration = googleChartConfiguration; ChartColumns = chartColumns; ChartType = googleChartType.GoogleChartTypeDisplayName; GoogleChartDataTable = googleChartDataTable; SaveConfigurationUrl = optionalSaveConfigurationUrl; }
public GooglePieChartConfiguration(string chartTitle, MeasurementUnitTypeEnum measurementUnitTypeEnum, List <GooglePieChartSlice> googlePieChartSlices, GoogleChartType googleChartType, GoogleChartDataTable googleChartDataTable) : base(chartTitle, true, googleChartType, googleChartDataTable, new GoogleChartAxis("Year", null, null), new List <GoogleChartAxis> { new GoogleChartAxis(null, measurementUnitTypeEnum, null) }) { PieSliceTextStyle = new GoogleChartTextStyle("black"); ChartArea = new GoogleChartConfigurationArea(10, 10); Slices = googlePieChartSlices; }
private void SetChartMetaData(GoogleChartType googleChartType) { //Never show title TitlePosition = "none"; if (googleChartType == Models.GoogleChartType.PieChart) { Legend.SetLegendPosition(GoogleChartLegendPosition.None); } else { Legend.SetLegendPosition(GoogleChartLegendPosition.Top); Legend.MaxLines = 3; } //Makes it so that the tooltip shows all items, not just the selected one FocusTarget = "category"; }
//Used where chartConfiguration comes as a GoogleChartConfiguration object //Use this constructor when the chart is not configurable - currently only PM charts public GoogleChartJson(string legendTitle, string chartContainerID, GoogleChartConfiguration googleChartConfiguration, GoogleChartType googleChartType, GoogleChartDataTable googleChartDataTable, List <string> chartColumns, string optionalSaveConfigurationUrl, string optionalResetConfigurationUrl, bool isCumulativeChart) { LegendTitle = legendTitle; ChartContainerID = chartContainerID; GoogleChartConfiguration = googleChartConfiguration; ChartColumns = chartColumns; CanConfigureChart = true; ChartType = googleChartType.GoogleChartTypeDisplayName; GoogleChartDataTable = googleChartDataTable; SaveConfigurationUrl = optionalSaveConfigurationUrl; OptionalResetConfigurationUrl = optionalResetConfigurationUrl; IsCumulativeChart = isCumulativeChart; }
public GoogleChartSeries(GoogleChartType googleChartType, GoogleChartAxisType googleChartAxisType) { Type = googleChartType.SeriesDataDisplayType; GetTargetAxisIndex(googleChartAxisType); LineWidth = 2; }
public GoogleChartColumn(string columnLabel, GoogleChartColumnDataType googleChartColumnDataType, GoogleChartType googleChartType) : this(columnLabel, columnLabel, googleChartColumnDataType.ColumnDataType, new GoogleChartSeries(googleChartType, GoogleChartAxisType.Primary), null, null) { }
/// <summary> /// Returns the javascript needed to create the Google Chart /// </summary> /// <param name="area"></param> /// <param name="name"></param> /// <param name="index">should be unique to the page</param> /// <returns></returns> private string GetChartJS(Dictionary <string, int> area, string name, int index, GoogleChartType type) { var jsData = string.Concat("data", index); var script = new StringBuilder(); script.Append(string.Concat("var ", jsData, " = new google.visualization.DataTable();")); script.Append(string.Concat(jsData, ".addColumn('string', '", name, "');")); script.Append(string.Concat(jsData, ".addColumn('number', 'Count');")); script.Append(string.Concat(jsData, ".addRows([")); foreach (var grp in area) { script.Append(string.Concat("['", grp.Key, "',", grp.Value, "],")); } script.Length = script.Length - 1;//delete last comma script.Append("]);"); var defaults = string.Concat("title: '", name, "', width: 400, height: 300, fontSize:12, fontName: 'Segoe UI', colors: ['#008299', '#AC193D', '#D24726', '#008A00', '#006AC1']"); if (type == GoogleChartType.Pie) { var opts = string.Concat("var options = { legend: { position: 'right' }, chartArea: { left:50, top:50, width: '100%', height: '100%'},", defaults, "};"); script.Append(opts); script.Append(string.Concat("var chart = new google.visualization.PieChart(document.getElementById('chart_div", index, "'));")); } else if (type == GoogleChartType.Bar) { var opts = string.Concat("var options = { chartArea: { left:50, top:50, width: '90%', height: '90%'}, hAxis: { textPosition: 'in'},", defaults, "};"); script.Append(opts); script.Append(string.Concat("var chart = new google.visualization.BarChart(document.getElementById('chart_div", index, "'));")); } script.Append(string.Concat("chart.draw(", jsData, ", options);")); return(script.ToString()); }
/// <summary> /// Initializes a new instance of <see cref="GoogleChartUrlBuilder"/> class. /// </summary> /// <param name="chartSize"></param> /// <param name="chartType"></param> /// <param name="encoder"></param> public GoogleChartUrlBuilder(Size chartSize, GoogleChartType chartType, IGoogleChartDataEncoder encoder) { this.chartSize = chartSize; this.chartType = chartType; this.encoder = encoder; }