Google Chart API Implementation -
am using google api implement chart in project. using scatter chart. need implement chart below. how can achieve this.? there other way achieve using other open source chart.?
you can use combochart combine scatter , area series
the area series should stacked
set color of first layer 'transparent'
use null
values series not coincide
see following working snippet...
google.charts.load('current', { callback: drawchart, packages: ['corechart'] }); function drawchart() { var data = new google.visualization.datatable(); data.addcolumn('number', 'x'); data.addcolumn('number', 'area bottom'); data.addcolumn('number', 'area top'); data.addcolumn('number', 'scatter'); data.addrows([ [1.5, null, null, 1.5], [3, 3, 3, null], [6, 3, 3, null] ]); var options = { areaopacity: 1, colors: ['transparent', '#ff9900', '#3366cc'], haxis: { format: '#,##0.0', ticks: [0, 1.5, 3, 4.5, 6], title: 'final score' }, height: 320, legend: { position: 'none' }, isstacked: true, seriestype: 'area', series: { 2: { type: 'scatter' } }, title: 'final score', vaxis: { format: '#,##0.0', ticks: [0, 1.5, 3, 4.5, 6], title: 'final score' }, width: 320 }; var chart = new google.visualization.combochart( document.getelementbyid('chart_div') ); chart.draw(data, options); }
<script src="https://www.gstatic.com/charts/loader.js"></script> <div id="chart_div"></div>
update
just add area layer new requirement...
google.charts.load('current', { callback: drawchart, packages: ['corechart'] }); function drawchart() { var data = new google.visualization.datatable(); data.addcolumn('number', 'x'); data.addcolumn('number', 'area bottom'); data.addcolumn('number', 'area middle'); data.addcolumn('number', 'area top'); data.addcolumn('number', 'scatter'); data.addrows([ [1.5, null, null, null, 1.5], [3, 3, 3, null, null], [4.5, 3, 3, null, null], [4.5, 3, 1.5, 1.5, null], [6, 3, 1.5, 1.5, null] ]); var options = { areaopacity: 1, colors: ['transparent', '#ff9900', '#f8bbd0', '#3366cc'], haxis: { format: '#,##0.0', ticks: [0, 1.5, 3, 4.5, 6], title: 'final score' }, height: 320, legend: { position: 'none' }, isstacked: true, seriestype: 'area', series: { 3: { type: 'scatter' } }, title: 'final score', vaxis: { format: '#,##0.0', ticks: [0, 1.5, 3, 4.5, 6], title: 'final score' }, width: 320 }; var chart = new google.visualization.combochart( document.getelementbyid('chart_div') ); chart.draw(data, options); }
<script src="https://www.gstatic.com/charts/loader.js"></script> <div id="chart_div"></div>
Comments
Post a Comment