javascript - Can we draw a Line Chart with both solid and dotted line in it? -


in real time analytics, might want state explicitly, present day has not been on yet , data day incomplete.

so, might want draw line joins last , penultimate point dotted stroke.

this how mixpanel it.

enter image description here

can done using chart js v2 pre-alpha?

yes, have work around couple of glitches

warning: sub-optimal example work around glitches

var linechartdata = {     labels: ['a', 'b', 'c', 'd', 'e', 'f', 'g'],     datasets: [{         label: "my first dataset",         data: [1, 8, 3, 4, 2, 3, 4],         bordercolor: '#66f',         borderdash: [20, 30]     },{         label: "my first dataset",         data: [1, 8, 3, 4, 2, , ],         bordercolor: '#66f',     }] };  var ctx = document.getelementbyid("chart").getcontext("2d"); var mychart = new chart(ctx, {     type: "line",     data: linechartdata,     options: {         elements: {             line: {                 fill: false             }         }     } }); 

notice first dataset doesn't have values set blank , 2nd dataset has 1 value required - these work around couple of glitches (including https://github.com/nnnick/chart.js/issues/1284)


fiddle - https://jsfiddle.net/uwb8357r/


Comments