Binding to Various Datasources
- Getting Started
- Setting Up ASP.NET Core MVC
- Accessibility
- Chart
- ASP.NET
- Overview
- Getting Started
- Design-time Support
- ItemTypes
- Chart Elements
- Chart Types
- Area Chart
- Bar Chart
- Bubble Chart
- Line Chart
- Pie Chart
- Sparklines
- Donut Chart
- Scatter Chart
- Spline Chart
- SplineArea Chart
- RangeArea Chart
- RangeBar Chart
- RangeSpline Chart
- StepLine Chart
- StepArea Chart
- PolarLine Chart
- PolarArea Chart
- PolarBar Chart
- PolarSpline Chart
- PolarSplineArea Chart
- PolarScatter Chart
- Combining Chart Types
- Data Binding
- Exporting
- Localization
- Selection
- Zooming and Panning
- Appearance and Styling
- Server Side Events
- Client Events
- Supported Browsers
- ASP.NET Core
- ASP.NET MVC
- JAVA Apache Wicket
- API
- allowUTCFormatting
- applyAnimation
- axisX
- axisTickText
- axisType
- categoricalValues
- decimalTicks
- drawColor
- drawWidth
- endOffset
- fixedEnd
- inverseOrder
- max
- min
- minorPlotStripColor
- minorPlotStripDashStyle
- minorPlotStripWidth
- minorTicksColor
- minorTicksHeight
- minorTicksRepeat
- minorTicksWidth
- offset
- plotBands
- plotLines
- plotStripColor
- plotStripDashStyle
- plotStripWidth
- startOffset
- swapLocation
- ticksColor
- ticksHeight
- ticksPlacement
- ticksRepeat
- ticksWidth
- title
- axisY
- axisTickText
- axisType
- decimalTicks
- drawColor
- drawWidth
- endOffset
- fixedEnd
- inverseOrder
- max
- min
- minorPlotStripColor
- minorPlotStripDashStyle
- minorPlotStripWidth
- minorTicksColor
- minorTicksHeight
- minorTicksRepeat
- minorTicksWidth
- offset
- plotBands
- plotLines
- plotStripColor
- plotStripDashStyle
- plotStripWidth
- startOffset
- swapLocation
- ticksColor
- ticksHeight
- ticksPlacement
- ticksRepeat
- ticksWidth
- title
- backgroundColor
- borderColor
- borderRadius
- borderWidth
- chartAreaBackgroundColor
- chartAreaBackgroundImage
- chartAreaBorderColor
- chartAreaBorderWidth
- chartAreaPaddingBottom
- chartAreaPaddingLeft
- chartAreaPaddingRight
- chartAreaPaddingTop
- chartLegend
- dataSeries
- enableAutoFit
- events
- exportOptions
- height
- isInverted
- margin
- primaryHeader
- secondaryHeader
- seriesPalette
- seriesSettings
- area
- bar
- bubble
- donut
- line
- pie
- polararea
- polarbar
- polarline
- polarscatter
- polarspline
- polarsplinearea
- rangearea
- rangebar
- rangesplinearea
- scatter
- spline
- splinearea
- steparea
- stepline
- seriesType
- theme
- tooltipSettings
- width
- zoomMode
- Getting Started
- Events
- How-To
- Methods
- Styling
- Supported Browsers
- ASP.NET
- Barcode
- QR Code
- TagCloud
- TreeMap
- Grid
- ASP.NET
- ASP.NET Core
- ASP.NET MVC
- JAVA Apache Wicket
- JavaScript
- API
- Settings
- altRowTemplate
- altRows
- columnReorder
- columns
- dataSource
- detailCollapseCssClass
- detailCollapseText
- detailExpandCollapse
- detailExpandCssClass
- detailExpandText
- detailTemplate
- editing
- exportOptions
- filtering
- grouping
- height
- maxHeight
- noRecordsTemplate
- noRecordsText
- paging
- resizing
- rowHover
- rowTemplate
- scrolling
- selection
- showHeader
- sorting
- toolbar
- Events
- Properties
- Methods
- addRow
- cancelEditing
- clearSelection
- collapseRow
- dataItem
- deleteRow
- destroy
- editCell
- editRow
- expandRow
- exportCsv
- exportExcel
- exportPdf
- filter
- hideColumn
- insertRow
- isHidden
- isLocked
- lockColumn
- page
- pageSize
- refresh
- reorderColumn
- revertChanges
- saveChanges
- scrollTop
- select
- selectedRowIndices
- showColumn
- sort
- ungroup
- unlockColumn
- Settings
- Getting Started
- Autogenerated Editors
- Binding to Data
- Cancel User Iteraction
- Change Options Dynamically
- Columns
- Custom Editors
- Exporting
- Filtering
- Footer Total Aggregates
- Grouping
- Hierarchy
- Paging
- RTL
- Scrolling
- Selection
- Sorting
- Templates
- Themes
- Validation
- API
- Accordion
- AutoComplete
- Button
- Calendar
- CheckBox
- ColorPicker
- ComboBox
- ContextMenu
- DataSource
- DatePicker
- DateTimePicker
- Draggable
- DropDown
- Droppable
- Editor
- ListBox
- LoadingPanel
- MaskedTextBox
- Menu
- MonthYearPicker
- NumericTextBox
- Pager
- ProgressBar
- RadioButton
- Rating
- RecursiveDataSource
- Slider
- SplitButton
- Splitter
- Switch
- Tabs
- TextBox
- TimePicker
- Timeline
- Tooltip
- TreeView
- Upload
- Window
Binding to a Generic List of Simple Types
The ShieldChart can be bound to a simple list of objects in the same way as binding to a regular array can be done. The following sample demonstrates binding to different datasources:
<shield:ShieldChart ID="ShieldChart1" Width="100%" Height="400px" runat="server" CssClass="chart" > <DataSeries> <shield:ChartBarSeries> </shield:ChartBarSeries> </DataSeries> </shield:ShieldChart>
protected void Page_Load(object sender, System.EventArgs e) { double[] ValuesArray = { 20.6, 20.5, 20.8, 20.3, 21.9, 21.2, 21.0, 21.4 }; ShieldChart1.DataSource = ValuesArray; ShieldChart1.DataBind(); }
Binding to a Generic List of Objects
The ShieldChart
can use a list of custom objects which mimics a declarative datasource. In this case the DataFieldY
or DataFieldX
property (DataFieldLow
or DataFieldHigh
for range series) of the series need to be set.
<shield:ShieldChart ID="ShieldChart1" Width="100%" Height="400px" runat="server" OnTakeDataSource="ShieldChart1_TakeDataSource" CssClass="chart" ZoomMode="XY"> <PrimaryHeader Text="Internet usage statistics"></PrimaryHeader> <ExportOptions AllowExportToImage="false" AllowPrint="false" /> <Axes> <shield:ChartAxisX CategoricalValues="Jan, Feb, Mar, Apr, May, Jun"></shield:ChartAxisX> <shield:ChartAxisY> <Title Text="Visitor statistics"></Title> </shield:ChartAxisY> </Axes> <DataSeries> <shield:ChartBarSeries DataFieldY="Total" CollectionAlias="Total Visits"> </shield:ChartBarSeries> <shield:ChartBarSeries DataFieldY="Unique" CollectionAlias="Unique Visits"> </shield:ChartBarSeries> </DataSeries> </shield:ShieldChart>
protected void ShieldChart1_TakeDataSource(object sender, Shield.Web.UI.ChartTakeDataSourceEventArgs e) { Listdatasource = new List () { new VisitorStatistic() { Total = 565000, Unique = 152000 }, new VisitorStatistic() { Total = 630400, Unique = 234000 }, new VisitorStatistic() { Total = 743000, Unique = 123000 }, new VisitorStatistic() { Total = 910200, Unique = 348000 }, new VisitorStatistic() { Total = 1170200, Unique = 167000 }, new VisitorStatistic() { Total = 1383000, Unique = 283000 } }; ShieldChart1.DataSource = datasource; } private class VisitorStatistic { public double Unique { get; set; } public double Total { get; set; } }
Binding to dataset
<shield:ShieldChart ID="ShieldChart1" Width="100%" Height="400px" runat="server" CssClass="chart" > <DataSeries> <shield:ChartBarSeries DataFieldY="UnitsInStock"> </shield:ChartBarSeries> </DataSeries> </shield:ShieldChart>
protected void Page_Load(object sender, System.EventArgs e) { ShieldChart1.DataSource = GetData(); ShieldChart1.DataBind(); } private DataSet GetData() { DataSet ds = new DataSet("Test"); DataTable dt = new DataTable("Products"); dt.Columns.Add("Id ", Type.GetType("System.Int32 ")); dt.Columns.Add("UnitsInStock ", Type.GetType("System.Double ")); dt.Rows.Add(1, 3.45); dt.Rows.Add(2, 5.95); dt.Rows.Add(3, 7.99); dt.Rows.Add(4, 11.95); ds.Tables.Add(dt); return ds; }