javascript - ChartNew does not show item legend -
i'm facing issue couldn't find here helps me.
i'm using chartnew.js possible set legend of datas in chart end user. set option in javascript, option seems nos working me. although chart works ajax request , shows results in screen, legend option seems not cooperate.
can me , find out why legend not working?
my entire javascript code bellow:
$(document).ready(function(){ $.ajax({ type: "get", url: "<?php echo "http://".$_server['server_name']."/epedidos/dashboard/datachart/";?>", success: function(response) { var obj = json.parse(response); //console.log(obj.cidade); var valormax = obj.reduce(function(a, b) { return math.max(a, b.valor); }, 0); var scale = valormax / 10; //console.log(valormax); var cidade = new array(); var valor = new array(); var = 0; ( in obj) { cidade[i] = obj[i].cidade; valor[i] = obj[i].valor; } drawbarchart(cidade, valor, scale); } }); function drawbarchart(cidade, valor, scale){ var barchartdata = { labels : cidade, datasets : [ { label : "vendas", fillcolor : "rgba(0,0,220,0.5)", strokecolor : "rgba(0,0,220,0.8)", highlightfill: "rgba(0,0,220,0.75)", highlightstroke: "rgba(0,0,220,1)", legend: "vendas mensais", data : valor } ] } var baroptions = { responsive : true, barvaluespacing : 12, bardatasetspacing : 5, scalefontsize: 12, legend: true, ingraphdatashow: true, showtooltips: true, yaxisunit: "r$", yaxislabel: "valores r$", yaxisleft : true, xaxislabel: "top 10 cidades", xaxistop: true, scalelabel : "r$ <%=value%>", ingraphdatatmpl : "r$ <%=v3%>", scaleoverride : true, scalestartvalue : 0, scalesteps : 10, scalestepwidth : scale, thousandseparator : ".", decimalseparator : ",", roundnumber : 0 } var ctx = document.getelementbyid("bar-chart").getcontext("2d"); window.mybar = new chart(ctx).bar(barchartdata, baroptions); } });
i have same problem remove legend in code
legend: "vendas mensais"
flw manolo
Comments
Post a Comment