JChart

JChart consist of line chart, bar chart and pie chart which designed for basic data visualization.
demo
install
npm i @joskii/jchart
Features
- Reactive Data
- Plugin based
- 3 canvas layers
- auto layout (y-axis margin adaptive)
Conceptions
Layer
JChart include 3 layers from bottom to top, one layer corresponds to a canvas element:
- Coodinate Layer
- Calculate basic transform matric based on layout, global DPR, origin data and axis.
- Paint axis
- Reactive to mouse pointer event
- Chart Layer
- Calculate chart point based on coordinate transform matric and origin data.
- Paint Chart
- Reactive to mouse pointer event
- Over Layer
- Handle mouse event and emit to Coodinate and Chart
- Paint Indicator
Data
Data is reactive. Every Layer will react to data change in fixed order.
Plugins
Plugins devided into 4 parts:
- Data
- Coodinate
- Chart
- Over
Configure
Data Configure
- 2d-data
BarChart and LineChart use 2d data
{
reference: {
type: 'continuous',
},
series: [
{
name: 'foo',
values: [
[1626150094.407, 40],
[1626150694.407, 30],
[1626151294.407, 10],
...
],
},
{
name: 'bar',
values: [
[1626150094.407, 20],
[1626150694.407, 70],
[1626151294.407, 50],
...
],
},
...
],
stack: true,
xAxis: {
span: 6,
format(value) {
const datetime = new Date(value);
return dataFormatter.format(datetime);
},
},
yAxis: {
min: 0,
format(value) {
return NumberFormatter.format(value);
},
},
- 1d-data
PieChart use 1d data
{
series: [
{
name: 'foo',
value: 4
},
{
name: 'bar',
value: 8
},
...
]
}
LineChart Configure
{
smooth: Boolean,
fill: Boolean,
}
Legend Configure
{
callback(legendMeta) {
...
}
}
LineIndicator Configure
{
callback(meta) {
...
},
bar: Boolean,
}
Additional Configure
{
layout: {
left: 0,
top: 20,
bottom: 40,
right: 30,
xFloat: 20
}
}
{
theme: {
colors: [
[ 103, 170, 245 ],
[ 255, 174, 60 ],
[ 78, 201, 171 ],
...
],
disabledOpacity: 0.1
fadeOpacity: 0.4
}
}
Who use Jchart
KubeCube
KubeCube is an open source enterprise-level container platform