A lit-element component for creating data visualizations using the Grammar of Graphics.
npm i @brightspaceuilabs/gg-chart
<script type="module">
import 'gg-chart/src/gg-chart.js';
</script>
<gg-chart
data='[{"grade": 82, "timeInContent": 78}, ...]'
aes="grade, timeInContent"
geom="point"
scale='[{"name": "Grades"}, {"name": "Time in Content"}]'
stats="ymean"
theme="daylight"
tooltip="point"
width="300"
height="250"
></gg-chart>
@gg-chart-point-click
-> Point : Event is triggered when a point in the chart is clicked. Parameter is the point with its aesthetic values@gg-chart-area-click
-> Area : Event is triggered when an area in the chart is clicked. Parameter is the point with its aesthetic values
aes
: The charts aesthetics, keys from the data records in axis order. 0 -> x, 1 -> ygeom
: The visual data representation.bar
,line
,point
scale
: A JSON string that defines the axis names, limits, and breaks.stats
: Statistical additions,xmean
,ymean
,bin:{width}
coord
: Coordinate system,polar:x
,polar:y
,flip
tooltip
: Which elements you want the tooltip to show on,point
,area
pos
: Where the geoms should be positioned.stacked
,dodged
theme
: The charts styling themelegend
: Toggles the legend,hidden
. Only shows when special aesthetics are used.data
: The data as a JSON stringwidth
: The width in pixelsheight
: The height in pixels.style
: A css object for selective styles.
To scan the project for linting and formatting errors, run
npm run lint
To automatically fix linting and formatting errors, run
npm run format
To execute a single test run:
npm run test
To run the tests in interactive watch mode run:
npm run test:watch
For most of the tools, the configuration is in the package.json
to minimize the amount of files in your project.
If you customize the configuration a lot, you can consider moving them to individual files.
npm start
To run a local development server that serves the basic demo located in demo/index.html
Proof of Concept
- Draws Axis
- Draws labels and numbers
- Draws headings
- Accepts data
- Keyboard navigable
- Hovering shows tooltips
- Updates when data changes
- Animates when data changes