I have this Jscharting script which loads data from a csv file. It works great, but unfortunately it doesn't load at all if there is any empty data in the source. How would you add handling empty data into following script?
JSC.fetch(
'./js/data.csv'
).then(function(response) {
response.text().then(function(t) {
var jsonData = JSC.csv2Json(t,{coerce:function(d){
return {
Date: d.date,
s1: parseFloat(d.s1),
s2: parseFloat(d.s2),
}
}});
var s1Points = JSC.nest()
.key('Date')
.rollup('s1')
.points(jsonData);
var s2Points = JSC.nest()
.key('Date')
.rollup('s2')
.points(jsonData);
var chart = JSC.chart('chartDiv', {
debug: true,
type: 'line',
legend_visible: false,
defaultCultureName: "hu-SK",
xAxis: {
crosshair_enabled: true,
scale: {
type: 'time',
time: {
parser: 'YYYY-MM-DD',
}
},
formatString: 'd',
},
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: 's1',
points: s1Points
},
{
name: 's2',
points: s2Points
}
]
});
});
});
I tried simple thing as:
s1: (parseFloat(d.s1) || '0'),
s2: (parseFloat(d.s2) || '0'),
...but the result is quite unreadable:
I would like to have in this case break the continuous line instead of zero value, if it's possible.