Click or drag to resize

ChartWidget Class

The class ChartWidget provides base chart dashboard widget
Inheritance Hierarchy

Namespace:  Dynamicweb.Dashboards.Widgets
Assembly:  Dynamicweb.Dashboards (in Dynamicweb.Dashboards.dll) Version: 2.9.4
Syntax
public abstract class ChartWidget : DashboardElementWidget, 
	IDropDownOptions

The ChartWidget type exposes the following members.

Constructors
  NameDescription
Public methodChartWidget
The chart widget default constructor
Top
Properties
  NameDescription
Public propertyChartType
Gets or sets chart presentation type
Public propertyColor
Gets or sets chart color
Public propertyColumns
Gets or sets widget size
(Inherited from DashboardWidget.)
Public propertyCreatedDate
Gets the created date and time.
(Inherited from DashboardWidget.)
Protected propertyCssClass
Gets or sets css class
Public propertyElement
The to be shown
(Inherited from DashboardElementWidget.)
Public propertyId
Gets widget Id
(Inherited from DashboardWidget.)
Protected propertyInstantFetch
Gets or sets value indicating whether data should be fetch to widget instantly, otherwise - using ajax
Public propertyModifiedDate
Gets the last modified date and time.
(Inherited from DashboardWidget.)
Public propertyOrder
Gets or sets widget order
(Inherited from DashboardWidget.)
Public propertyPresentation
Gets or sets chart presentation
Public propertyShowTitle
Gets or sets value indicating whether to show widget title.
(Inherited from DashboardWidget.)
Public propertyTitle
Gets or sets widget title
(Inherited from DashboardWidget.)
Public propertyTitleAction
Gets or sets widget title action
(Inherited from DashboardWidget.)
Top
Methods
  NameDescription
Public methodFetch
Fetches widget with data
(Overrides DashboardWidgetFetch(IDashboard, String).)
Public methodGetData
Gets chart data
Public methodGetIdSuitableString (Inherited from ConfigurableAddIn.)
Public methodGetOptions
Return dropdown options
(Overrides DashboardWidgetGetOptions(String).)
Public methodGetParametersToXml (Inherited from ConfigurableAddIn.)
Public methodGetParametersToXml(Boolean) (Inherited from ConfigurableAddIn.)
Public methodLoadParametersFromXml (Inherited from ConfigurableAddIn.)
Public methodRender
The method render widget and return html
(Inherited from DashboardElementWidget.)
Public methodRenderAdditionalContent (Inherited from ConfigurableAddIn.)
Public methodScriptDependencies
Specifies relative paths to all script files that this widget is dependent upon.
(Inherited from DashboardWidget.)
Public methodSetValue (Inherited from ConfigurableAddIn.)
Public methodStylesheetDependencies
Specifies relative paths to all style files that this widget is dependent upon.
(Inherited from DashboardWidget.)
Public methodUpdateFromPost (Inherited from ConfigurableAddIn.)
Top
Examples
How to inherit ChartWidget
using System;
using System.Collections;
using System.Collections.Generic;
using Dynamicweb.Dashboards.Widgets;
using Dynamicweb.UI.Elements.Displays.Charts;
using Dynamicweb.Extensibility.AddIns;
using Dynamicweb.Extensibility.Editors;

namespace Dynamicweb.Dashboards.Examples
{
    [AddInName("Simple multi-series chart")]
    [AddInDescription("Show simple chart with 2 series")]
    [AddInIcon(Core.UI.Icons.KnownIcon.LineChart)]
    public sealed class SimpleChartWidget : ChartWidget
    {
        /// <summary>
        /// Gets or sets chart legend position
        /// </summary>
        [AddInLabel("Legend position"), AddInParameter("LegendPosition"), AddInParameterEditor(typeof(DropDownParameterEditor), "none=false;container=body")]
        public string LegendPosition { get; set; }

        public SimpleChartWidget()
        {
            Title = "Total cities population";
            ChartType = ChartType.Line;
            InstantFetch = true;
        }

        public override ChartData GetData(IDashboard dashboard, string path)
        {
            var series = new List<double[]> {
                new double[] { 500d, 200d, 150d, 300d },
                new double[] { 300d, 400d, 250d, 100d }
            };

            var data = new ChartData
            {
                Labels = new[] { "London", "New York", "Moscow", "Copenhagen" },
                MultiSeries = series,
                Legends = new[] { "Man", "Woman" },
                LegendPosition = LegendPosition //(LegendPosition)Enum.Parse(typeof(LegendPosition), LegendPosition)
            };

            return data;
        }

        /// <summary>
        /// Return dropdown options
        /// </summary>
        /// <param name="dropdownName"></param>
        /// <returns></returns>
        public override Hashtable GetOptions(string dropdownName)
        {
            var hash = base.GetOptions(dropdownName) ?? new Hashtable();

            if ("LegendPosition".Equals(dropdownName, StringComparison.OrdinalIgnoreCase))
            {
                hash.Add("top", "Top");
                hash.Add("right", "Right");
                hash.Add("bottom", "Bottom");
                hash.Add("left", "Left");
            }
            return hash;
        }

    }
}
See Also