chartjs-chart-timeline
Timeline chart library for Chart.js.
"type": "timeline""options": // Depricated and will be removed in future. Please use elements.* instead. // "colorFunction": function(text, data, dataset, index) { // return Color('black'); // }, // "showText": true, // "textPadding": 4 "elements": { return ; } "showText": true "textPadding": 4 "data": "labels": "Cool Graph" "heater1" "datasets": "data": "2018-01-22T16:00:00.000Z" "2018-01-23T05:40:44.626Z" "Unknown" "data": "2018-01-22T16:00:00.000Z" "2018-01-23T04:57:43.736Z" "On" "2018-01-23T04:57:43.736Z" "2018-01-23T04:57:55.437Z" "Off" "2018-01-23T04:57:55.437Z" "2018-01-23T05:40:44.626Z" "On"
Example for dynamic resize by dataset count:
{ if !this_chart return; // Chart not ready if this$chartTargetclientWidth === 0 if this_resizeTimer === undefined this_resizeTimer = ; return; ; this_resizeTimer = undefined; this;} { const chartTarget = this$chartTarget; const options = thisdata; const data = optionsdata; if datadatasetslength === 0 return; if !thisisTimeline this_chart; return; // Recalculate chart height for Timeline chart var axis = this_chartboxes0; if axis && axisheight > 0 this_axisHeight = axisheight; if !this_axisHeight chartTargetstyleheight = '100px'; chartTargetheight = '100px'; this_chart; axis = this_chartboxes0; if axis && axisheight > 0 this_axisHeight = axisheight; if this_axisHeight const cnt = datadatasetslength; const targetHeight = 30 * cnt + this_axisHeight + 'px'; if chartTargetstyleheight !== targetHeight chartTargetstyleheight = targetHeight; chartTargetheight = targetHeight; this_chart; }
Usage: https://github.com/fanthos/chartjs-chart-timeline/wiki