i want to represent the following array data which is stored in the variable $dataBycountry. this variable contain
(
[0] => Array
(
[country] => Russia
[sessions] => 132
[users] => 3
[pageviews] => 261
)
[1] => Array
(
[country] => India
[sessions] => 31
[users] => 20
[pageviews] => 67
)
[2] => Array
(
[country] => Austria
[sessions] => 18
[users] => 18
[pageviews] => 53
)
)
and this is my script
var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
var barChartData = {
labels : ["i want lables also to be dynamic"],
datasets : [
{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,0.8)",
highlightFill: "rgba(220,220,220,0.75)",
highlightStroke: "rgba(220,220,220,1)",
data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
},
{
fillColor : "rgba(151,187,205,0.5)",
strokeColor : "rgba(151,187,205,0.8)",
highlightFill : "rgba(151,187,205,0.75)",
highlightStroke : "rgba(151,187,205,1)",
data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
}
]
}
window.onload = function(){
var ctx = document.getElementById("canvas").getContext("2d");
window.myBar = new Chart(ctx).Bar(barChartData, {
responsive : true
});
}
i want to use those countries as lables and display barcharts dynamically.please give me a solution how to use that $dataByCountry variable in script.