JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jscharting.com/latest/jscharting.js"></script>
<div id="chartDiv" style="width: 100%; height: 400px;"></div>
JavaScript
function showData(t) {
var jsonData = JSC.csv2Json(t, {
coerce: function (d) {
return {
Date: d.date,
s1: (parseFloat(d.s1) || null),
s2: (parseFloat(d.s2) || null),
s3: (parseFloat(d.s3) || null),
}
}
});
var s1Points = JSC.nest()
.key('Date')
.rollup('s1')
.points(jsonData);
var s2Points = JSC.nest()
.key('Date')
.rollup('s2')
.points(jsonData);
var s3Points = JSC.nest()
.key('Date')
.rollup('s3')
.points(jsonData);
var chart = JSC.chart('chartDiv', {
debug: true,
type: 'line',
legend_visible: true,
title: {
position: 'top',
padding: 7,
fill: ['orange', 'orange', 0],
opacity: 0.4,
boxVisible: true,
label: {
text: 'emptyPointMode: default / ignore / treatAsZero',
align: 'left'
}
},
legend: {
position: 'inside right top',
defaultEntry_value: '%value'
},
defaultCultureName: "hu-SK",
xAxis: {
crosshair_enabled: true,
scale: {
type: 'time',
time: {
parser: 'YYYY-MM-DD',
}
},
formatString: 'dd',
},
yAxis: {
orientation: 'opposite',
formatString: 'c'
},
defaultSeries: {
firstPoint_label_text: '<b>%seriesName</b>',
defaultPoint_marker: {
type: 'circle',
fill: 'white',
outline: { width: 2, color: 'currentColor' }
}
},
series: [
{
name: 'default',
points: s1Points,
emptyPointMode: 'default'
},
{
name: 'ignore',
points: s2Points,
emptyPointMode: 'ignore'
},
...