Chart Style class. All values are optional. The chart will decide the style if a value is not specified Color values can be any html color specification Gradients can be 2 or more html colors that will result in a vertical gradient (limited to vertical because that's what works in IE)
コード例 #1
0
 /// <summary>
 /// Sets the flot lines points bars style.
 /// </summary>
 /// <param name="chartStyle">The chart style.</param>
 /// <param name="linesPointsBars">The lines points bars.</param>
 private void SetFlotLinesPointsBarsStyle(ChartStyle chartStyle, LinesPointsBars linesPointsBars)
 {
     if (linesPointsBars != null)
     {
         linesPointsBars.fill      = chartStyle.FillOpacity;
         linesPointsBars.fillColor = chartStyle.FillColor;
     }
 }
コード例 #2
0
        /// <summary>
        /// Sets the chart style.
        /// </summary>
        /// <param name="chartStyleDefinedValueGuid">The chart style defined value unique identifier.</param>
        public void SetChartStyle(Guid?chartStyleDefinedValueGuid)
        {
            ChartStyle chartStyle = null;

            if (chartStyleDefinedValueGuid.HasValue)
            {
                var definedValue = DefinedValueCache.Get(chartStyleDefinedValueGuid.Value);
                if (definedValue != null)
                {
                    chartStyle = ChartStyle.CreateFromJson(definedValue.Value, definedValue.GetAttributeValue("ChartStyle"));
                }
            }

            SetChartStyle(chartStyle ?? new ChartStyle());
        }
コード例 #3
0
        /// <summary>
        /// Sets the chart style.
        /// </summary>
        /// <param name="chartStyleDefinedValueGuid">The chart style defined value unique identifier.</param>
        public void SetChartStyle(Guid?chartStyleDefinedValueGuid)
        {
            ChartStyle chartStyle = null;

            if (chartStyleDefinedValueGuid.HasValue)
            {
                using (var rockContext = new Rock.Data.RockContext())
                {
                    var definedValue = new DefinedValueService(rockContext).Get(chartStyleDefinedValueGuid.Value);
                    if (definedValue != null)
                    {
                        definedValue.LoadAttributes(rockContext);
                        chartStyle = ChartStyle.CreateFromJson(definedValue.Value, definedValue.GetAttributeValue("ChartStyle"));
                    }
                }
            }

            SetChartStyle(chartStyle ?? new ChartStyle());
        }
コード例 #4
0
        /// <summary>
        /// Sets the chart style.
        /// </summary>
        /// <param name="chartStyle">The chart style.</param>
        public void SetChartStyle(ChartStyle chartStyle)
        {
            if (chartStyle.SeriesColors != null && chartStyle.SeriesColors.Count() > 0)
            {
                this.colors = chartStyle.SeriesColors.ToArray();
            }

            if (chartStyle.Grid != null)
            {
                this.grid = this.grid ?? new GridOptions();
                this.grid.backgroundColor = chartStyle.Grid.BackgroundColorGradient != null?ToFlotColorGradient(chartStyle.Grid.BackgroundColorGradient) : chartStyle.Grid.BackgroundColor;

                this.grid.color = chartStyle.Grid.ColorGradient != null?ToFlotColorGradient(chartStyle.Grid.ColorGradient) : chartStyle.Grid.Color;

                this.grid.borderWidth = chartStyle.Grid.BorderWidth;
                this.grid.borderColor = chartStyle.Grid.BorderColor;
            }

            this.xaxis = this.xaxis ?? new AxisOptions();
            SetFlotAxisStyle(chartStyle.XAxis, this.xaxis);
            this.yaxis = this.yaxis ?? new AxisOptions();
            SetFlotAxisStyle(chartStyle.YAxis, this.yaxis);

            this.yaxis.tickFormatter = @"
function (val, axis) {
  // round to at most 2 decimal places
  var roundedVal = (Math.round(val * 100))/100;

  // show commas 
  // from http://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript
  var formattedValue =  roundedVal.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');

  return formattedValue;
}".Trim();

            SetFlotLinesPointsBarsStyle(chartStyle, this.series.lines);
            SetFlotLinesPointsBarsStyle(chartStyle, this.series.bars);
            SetFlotLinesPointsBarsStyle(chartStyle, this.series.points);

            if (chartStyle.Legend != null)
            {
                this.legend      = new Legend();
                this.legend.show = chartStyle.Legend.Show ?? true;
                this.legend.labelBoxBorderColor = chartStyle.Legend.LabelBoxBorderColor;
                this.legend.noColumns           = chartStyle.Legend.NoColumns;
                this.legend.position            = chartStyle.Legend.Position;
                this.legend.backgroundColor     = chartStyle.Legend.BackgroundColor;
                this.legend.backgroundOpacity   = chartStyle.Legend.BackgroundOpacity;
                this.legend.container           = chartStyle.Legend.Container;
            }

            this.customSettings = this.customSettings ?? new CustomSettings();

            // copy Title styles to Flot custom settings
            if (chartStyle.Title != null)
            {
                if (chartStyle.Title.Font != null)
                {
                    this.customSettings.titleFont        = new ChartFont();
                    this.customSettings.titleFont.color  = chartStyle.Title.Font.Color;
                    this.customSettings.titleFont.family = chartStyle.Title.Font.Family;
                    this.customSettings.titleFont.size   = chartStyle.Title.Font.Size;
                }

                if (chartStyle.Title.Align != null)
                {
                    this.customSettings.titleAlign = chartStyle.Title.Align;
                }
            }

            // copy SubTitle styles to Flot custom settings
            if (chartStyle.Subtitle != null)
            {
                if (chartStyle.Subtitle.Font != null)
                {
                    this.customSettings.subtitleFont        = new ChartFont();
                    this.customSettings.subtitleFont.color  = chartStyle.Subtitle.Font.Color;
                    this.customSettings.subtitleFont.family = chartStyle.Subtitle.Font.Family;
                    this.customSettings.subtitleFont.size   = chartStyle.Subtitle.Font.Size;
                }

                if (chartStyle.Subtitle.Align != null)
                {
                    this.customSettings.subtitleAlign = chartStyle.Subtitle.Align;
                }
            }

            // copy Goal Series Color to Flot custom settings
            this.customSettings.goalSeriesColor = chartStyle.GoalSeriesColor;

            if (chartStyle.PieLabels != null)
            {
                this.series.pie                  = this.series.pie ?? new Pie();
                this.series.pie.label            = new PieLabel();
                this.series.pie.label.background = new
                {
                    color   = chartStyle.PieLabels.BackgroundColor,
                    opacity = chartStyle.PieLabels.BackgroundOpacity
                };
            }
        }
コード例 #5
0
ファイル: ChartOptions.cs プロジェクト: Ganon11/Rock
 /// <summary>
 /// Sets the flot lines points bars style.
 /// </summary>
 /// <param name="chartStyle">The chart style.</param>
 /// <param name="linesPointsBars">The lines points bars.</param>
 private void SetFlotLinesPointsBarsStyle( ChartStyle chartStyle, LinesPointsBars linesPointsBars )
 {
     if ( linesPointsBars != null )
     {
         linesPointsBars.fill = chartStyle.FillOpacity;
         linesPointsBars.fillColor = chartStyle.FillColor;
     }
 }
コード例 #6
0
ファイル: ChartOptions.cs プロジェクト: Ganon11/Rock
        /// <summary>
        /// Sets the chart style.
        /// </summary>
        /// <param name="chartStyle">The chart style.</param>
        public void SetChartStyle( ChartStyle chartStyle )
        {
            if ( chartStyle.SeriesColors != null && chartStyle.SeriesColors.Count() > 0 )
            {
                this.colors = chartStyle.SeriesColors.ToArray();
            }

            if ( chartStyle.Grid != null )
            {
                this.grid = this.grid ?? new GridOptions();
                this.grid.backgroundColor = chartStyle.Grid.BackgroundColorGradient != null ? ToFlotColorGradient( chartStyle.Grid.BackgroundColorGradient ) : chartStyle.Grid.BackgroundColor;
                this.grid.color = chartStyle.Grid.ColorGradient != null ? ToFlotColorGradient( chartStyle.Grid.ColorGradient ) : chartStyle.Grid.Color;
                this.grid.borderWidth = chartStyle.Grid.BorderWidth;
                this.grid.borderColor = chartStyle.Grid.BorderColor;
            }

            this.xaxis = this.xaxis ?? new AxisOptions();
            SetFlotAxisStyle( chartStyle.XAxis, this.xaxis );
            this.yaxis = this.yaxis ?? new AxisOptions();
            SetFlotAxisStyle( chartStyle.YAxis, this.yaxis );

            this.yaxis.tickFormatter = @"
            function (val, axis) {
              // show commas
              // from http://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript
              return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
            }".Trim();

            SetFlotLinesPointsBarsStyle( chartStyle, this.series.lines );
            SetFlotLinesPointsBarsStyle( chartStyle, this.series.bars );
            SetFlotLinesPointsBarsStyle( chartStyle, this.series.points );

            if ( chartStyle.Legend != null )
            {
                this.legend = new Legend();
                this.legend.show = chartStyle.Legend.Show ?? true;
                this.legend.labelBoxBorderColor = chartStyle.Legend.LabelBoxBorderColor;
                this.legend.noColumns = chartStyle.Legend.NoColumns;
                this.legend.position = chartStyle.Legend.Position;
                this.legend.backgroundColor = chartStyle.Legend.BackgroundColor;
                this.legend.backgroundOpacity = chartStyle.Legend.BackgroundOpacity;
                this.legend.container = chartStyle.Legend.Container;
            }

            this.customSettings = this.customSettings ?? new CustomSettings();

            // copy Title styles to Flot custom settings
            if ( chartStyle.Title != null )
            {
                if ( chartStyle.Title.Font != null )
                {
                    this.customSettings.titleFont = new ChartFont();
                    this.customSettings.titleFont.color = chartStyle.Title.Font.Color;
                    this.customSettings.titleFont.family = chartStyle.Title.Font.Family;
                    this.customSettings.titleFont.size = chartStyle.Title.Font.Size;
                }

                if ( chartStyle.Title.Align != null )
                {
                    this.customSettings.titleAlign = chartStyle.Title.Align;
                }
            }

            // copy SubTitle styles to Flot custom settings
            if ( chartStyle.Subtitle != null )
            {
                if ( chartStyle.Subtitle.Font != null )
                {
                    this.customSettings.subtitleFont = new ChartFont();
                    this.customSettings.subtitleFont.color = chartStyle.Subtitle.Font.Color;
                    this.customSettings.subtitleFont.family = chartStyle.Subtitle.Font.Family;
                    this.customSettings.subtitleFont.size = chartStyle.Subtitle.Font.Size;
                }

                if ( chartStyle.Subtitle.Align != null )
                {
                    this.customSettings.subtitleAlign = chartStyle.Subtitle.Align;
                }
            }

            // copy Goal Series Color to Flot custom settings
            this.customSettings.goalSeriesColor = chartStyle.GoalSeriesColor;

            if ( chartStyle.PieLabels != null )
            {
                this.series.pie = this.series.pie ?? new Pie();
                this.series.pie.label = new PieLabel();
                this.series.pie.label.background = new
                {
                    color = chartStyle.PieLabels.BackgroundColor,
                    opacity = chartStyle.PieLabels.BackgroundOpacity
                };
            }
        }