Class that can be JSON'd and used for Flot Charts (properties are case sensitive)
예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FlotChart"/> class.
        /// </summary>
        public FlotChart()
        {
            Options = new ChartOptions();

            // set default options, but ChartStyle or child class can override some of it
            this.Options.xaxis = new AxisOptions { mode = AxisMode.time };
            this.Options.grid = new GridOptions { hoverable = true, clickable = true };
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FlotChart"/> class.
        /// </summary>
        public FlotChart()
        {
            Options = new ChartOptions();

            // set default options, but ChartStyle or child class can override some of it
            this.Options.xaxis = new AxisOptions {
                mode = AxisMode.time
            };
            this.Options.grid = new GridOptions {
                hoverable = true, clickable = true
            };
        }
예제 #3
0
        private void SetChartOptions()
        {
            var options = new ChartOptions();
            options.series = new SeriesOptions( false, true, false );
            options.xaxis = new AxisOptions { mode = AxisMode.time };
            options.grid = new GridOptions { hoverable = true, clickable = false };

            options.SetChartStyle( GetAttributeValue( "ChartStyle" ).AsGuidOrNull() );

            options.xaxis.timeformat = "%I:%M";

            hfChartOptions.Value = JsonConvert.SerializeObject( options, Formatting.Indented, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore, NullValueHandling = NullValueHandling.Ignore } );
        }
예제 #4
0
        private void RegisterStartupScript()
        {
            var options = new ChartOptions();
            options.series = new SeriesOptions( false, true, false );
            options.yaxis = new AxisOptions { min = 0, minTickSize = 1 };
            options.xaxis = new AxisOptions { mode = AxisMode.time };
            options.grid = new GridOptions { hoverable = true, clickable = false };
            options.SetChartStyle( GetAttributeValue( "ChartStyle" ).AsGuidOrNull() );
            options.xaxis.timeformat = "%I:%M";

            string script = string.Format( @"
            var data = eval($('#{1}').val());
            var options = {2};
            $.plot( $('#{0}'), data, options );
            ",
                pnlChart.ClientID, hfChartData.ClientID,
                JsonConvert.SerializeObject(
                    options,
                    Formatting.Indented,
                    new JsonSerializerSettings() {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                        NullValueHandling = NullValueHandling.Ignore
                    } ) );

            ScriptManager.RegisterStartupScript( pnlChart, pnlChart.GetType(), "chart", script, true );
        }
예제 #5
0
        private void RegisterStartupScript()
        {
            var options = new ChartOptions();
            options.series = new SeriesOptions( false, true, false );
            options.yaxis = new AxisOptions { min = 0, minTickSize = 1 };
            options.xaxis = new AxisOptions { mode = AxisMode.time };
            options.grid = new GridOptions { hoverable = true, clickable = false };
            options.SetChartStyle( GetAttributeValue( "ChartStyle" ).AsGuidOrNull() );
            options.xaxis.timeformat = "%I:%M";

            string script = string.Format( @"
            var data = eval($('#{1}').val());
            var options = {2};
            $.plot( $('#{0}'), data, options );

            $('.js-threshold-btn-edit').click(function(e){{
            var $parentDiv = $(this).closest('div.js-threshold');
            $parentDiv.find('.js-threshold-nb').val($parentDiv.find('.js-threshold-hf').val());
            $parentDiv.find('.js-threshold-view').hide();
            $parentDiv.find('.js-threshold-edit').show();
            }});

            $('a.js-threshold-edit').click(function(e){{
            var $parentDiv = $(this).closest('div.js-threshold');
            $parentDiv.find('.js-threshold-edit').hide();
            $parentDiv.find('.js-threshold-view').show();
            return true;
            }});

            $('.js-threshold').click(function(e){{
            e.stopPropagation();
            }});
            ",
                pnlChart.ClientID, hfChartData.ClientID,
                JsonConvert.SerializeObject(
                    options,
                    Formatting.Indented,
                    new JsonSerializerSettings()
                    {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                        NullValueHandling = NullValueHandling.Ignore
                    } ) );

            ScriptManager.RegisterStartupScript( pnlChart, pnlChart.GetType(), "chart", script, true );
        }