How to set the legend icons of a google line chart as lines not squares -
i've been trying figure out how first chart in this jsfiddle has legend icons lines instead of squares. compared line chart legend here has squares icons. think has x axis being date, doesn't seem work data. does know how explicitly set icons of google line chart legend lines , not squares?
these chart options correctly displaying line chart:
var classicoptions = { title: 'average temperatures , daylight in iceland throughout year', width: 900, height: 500, // gives each series axis matches vaxes number below. series: { 0: {targetaxisindex: 0}, 1: {targetaxisindex: 1} }, vaxes: { // adds titles each axis. 0: {title: 'temps (celsius)'}, 1: {title: 'daylight'} }, haxis: { ticks: [new date(2014, 0), new date(2014, 1), new date(2014, 2), new date(2014, 3), new date(2014, 4), new date(2014, 5), new date(2014, 6), new date(2014, 7), new date(2014, 8), new date(2014, 9), new date(2014, 10), new date(2014, 11) ] }, vaxis: { viewwindow: { max: 30 } }, legend: {position: 'bottom'} };
in fact, if using latest version (v1.1) of google.visualization.linechart legend rendered using line style demonstrated below.
example
google.setonloadcallback(drawchart); function drawchart() { var data = google.visualization.arraytodatatable([ ['year', 'sales', 'expenses'], ['2004', 1000, 400], ['2005', 1170, 460], ['2006', 660, 1120], ['2007', 1030, 540] ]); var options = { title: 'company performance', curvetype: 'function', legend: { position: 'bottom' } }; var chart = new google.visualization.linechart(document.getelementbyid('chart')); chart.draw(data, options); }
<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.1','packages':['corechart']}]}"></script> <div id="chart" style="width: 640px; height: 480px"></div>
in prevision version legend rendered boxed icons.
example
google.setonloadcallback(drawchart); function drawchart() { var data = google.visualization.arraytodatatable([ ['year', 'sales', 'expenses'], ['2004', 1000, 400], ['2005', 1170, 460], ['2006', 660, 1120], ['2007', 1030, 540] ]); var options = { title: 'company performance', curvetype: 'function', legend: { position: 'bottom' } }; var chart = new google.visualization.linechart(document.getelementbyid('chart')); chart.draw(data, options); }
<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.0','packages':['corechart']}]}"></script> <div id="chart" style="width: 640px; height: 480px"></div>
note: difference between 2 examples version of library
regarding customizing chart legend.
according configuration options following legend
properties customized:
alignment
alignment of legendmaxlines
maximum number of lines in legendposition
position of legendtextstyle
object specifies legend text style.
since there no property specifies icon style, in order create more customized legend disable chart legend , create custom 1 using html/css.
Comments
Post a Comment