1
I have the following code:
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer",
{
title:{
text: "Desktop Search Engine Market Share, Dec-2012"
},
animationEnabled: true,
legend:{
verticalAlign: "center",
horizontalAlign: "left",
fontSize: 20,
fontFamily: "Helvetica"
},
theme: "theme2",
data: [
{
type: "pie",
indexLabelFontFamily: "Garamond",
indexLabelFontSize: 20,
indexLabel: "{label} {y}%",
startAngle:-20,
showInLegend: true,
toolTipContent:"{legendText} {y}%",
dataPoints: [
{ y: 83.24, legendText:"Google", label: "Google" },
{ y: 8.16, legendText:"Yahoo!", label: "Yahoo!" },
{ y: 4.67, legendText:"Bing", label: "Bing" },
{ y: 1.67, legendText:"Baidu" , label: "Baidu"},
{ y: 0.98, legendText:"Others" , label: "Others"}
]
}
]
});
chart.render();
}
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<!DOCTYPE HTML>
<body>
<div id="chartContainer" style="height: 300px; width: 100%;"></div>
I’d like to put my own value on the chart. The return of my php is like this:
[
{
"y": 83.24,
"legendText": "Google",
"label": "Google"
},
{
"y": 8.16,
"legendText": "Yahoo!",
"label": "Yahoo!"
},
{
"y": 4.67,
"legendText": "Bing",
"label": "Bing"
},
{
"y": 1.67,
"legendText": "Baidu",
"label": "Baidu"
},
{
"y": 0.98,
"legendText": "Others",
"label": "Others"
}
]
I’m trying to put this figure in place and I can’t:
I’ve tried it like this:
var dados = [];
$.ajax({
url : 'file.php',
type : 'post',
dataType : 'json',
data :{
acao : 'a'
}
,success : function( data ){
$.each( data, function( i, j ){
dados.push( j )
} );
}
});
I overwrite the data by mine and nothing.
You have a tutorial on how to use fusioncharts ?
– adventistaam
is the same thing practically, the only difference, is that instead of instantiating a JS, you instantiate a php class, and you pass a json very similar to that, http://www.fusioncharts.com/php-charts/ take a look here.
– AnthraxisBR