ZingChart has a basic grid type built in to display your chart data as a table. For more interactive tables and grids with data visualization features, check out ZingGrid!
ZingGrid is a JavaScript library for rendering grids and data tables. ZingGrid's main focus is on fast, responsive, and customizable grids utilizing ES6 and native web components. The goal is to solve the problem of creating a CRUD grid in under five minutes. With an appropriate REST endpoint, this is easily achievable. Download ZingGrid for free here.
Note: See our Grid Chart Gallery for inspiration on all the different grid chart possibilities.
Add a type
attribute to your chart object and set the value to grid
.
{ type: "grid" }
Grid charts support a series
array of objects.
Create a series
object array. Each object corresponds to a row in the grid. Within each object, create a values
array of numbers and/or strings to populate each cell of a row.
{ type: "grid", series: [ // Array of objects { values: [ // Array of numbers | strings (Row 1-Col 1), (Row 1-Col 2), ..., (Row 1-Col N) ] }, { values: [ (Row 2-Col 1), (Row 2-Col 2), ..., (Row 2-Col N) ] }, ..., { values: [ (Row N-Col 1), (Row N-Col 2), ..., (Row N-Col N) ] } ] }
JavaScript grids include a number of unique chart-specific properties that allow you to manipulate the appearance and behaviors of your HTML5 grid. They can be implemented into your chart by placing them within an options
object.
The header-col
attribute sets whether the grid has a header column or not. It can be added by setting the header-col
attribute to true
, or by creating an empty header-col
object.
{ options: { 'header-col': true } }
The header-row
attribute sets whether the grid has a header row or not. It can be added by setting the header-row
attribute to true
, or by creating an empty header-row
object.
{ options: { 'header-row': true } }
The col-labels
attribute defines the labels of the grid columns.
{ options: { 'col-labels': [ "ID", "FIRST id", "LAST id", "BIRTHDAY", "SEX", "COUNTRY" ], } }
The col-widths
attribute defines the widths of the grid columns, specified either in fixed values or as a percentage.
{ options: { 'col-widths': [ "5%", "25%", "25%", "15%", "5%", "25%" ], } }
The flat
attribute sets whether the grid cells are clickable or not. Enter a boolean value.
{ options: { flat: true } }
The graph
attribute sets the ID of the chart that the grid is being linked with.
{ options: { 'data-source': { graph: "..." } } }
The scale
attribute sets the ID of the scale from which the column labels are being imported.
{ options: { 'data-source': { scale: "..." } } }
Once you have your basic grid, you can customize and style it to fit your data visualization needs.
The following attributes can be used to style grid charts:
Attribute | Description |
---|---|
.td | Defines the style for grid cells |
.td_3 | Defines the style for grid cells on column 3 |
.td_2_3 | Defines the style for grid cells on row 2, column 3 |
.td_even | Defines the style for the even grid cells |
.td_odd | Defines the style for the odd grid cells |
.td_first | Defines the style for the first grid cells |
.td_last | Defines the style for the last grid cells |
.th | Defines the style for the header cells |
.th_3 | Defines the style for the header cells on column 3 |
.th_even | Defines the style for the even header cells |
.th_odd | Defines the style for the odd header cells |
.th_first | Defines the style for the first header cells |
.th_last | Defines the style for the last header cells |
.tr | Defines the style for the grid rows |
.tr_3 | Defines the style for the grid rows on row 3 |
.tr_even | Defines the style for the even grid rows |
.tr_odd | Defines the style for the odd grid rows |
.tr_first | Defines the style for the first grid rows |
.tr_last | Defines the style for the last grid rows |