i'm trying to make my bar chart a little more dynamic so that the user would be able to change the number of values entered. I'm using a php variable which is converted into a JQuery variable. Now the chart works fine but when I try and add an if statement for if the no of bars is more than or equal to the number of values the chart disapears. Anyone know where I'm going wrong here?
<script>
window.onload = function (){
var pValue1 = <?php echo $pValue1;?>;
var pValue2 = <?php echo $pValue2;?>;
var pValue3 = <?php echo $pValue3;?>;
var pValue4 = <?php echo $pValue4;?>;
var pValue5 = <?php echo $pValue5;?>;
var NoOfBars = <?php echo $NoOfBars;?>;
var bar = new RGraph.Bar({
id:'cvs1',
data:
if (NoOfBars >= 1){
[pValue1],
}
if (NoOfBars >= 2){
[pValue1, pValue2],
}
if (NoOfBars >= 3){
[pValue1, pValue2, pValue3],
}
if (NoOfBars >= 4){
[pValue1, pValue2, pValue3, pValue4],
}
if (NoOfBars >= 5){
[pValue1, pValue2, pValue3, pValue4, pValue5],
}
options: {
backgroundGridDashed: true,
labels: ['Mal', 'Barry', 'Gary', 'Neil', 'Kim', 'Pete', 'Lou', 'Fred', 'Jobe'],
title: 'Title of Chart',
strokestyle: 'rgba(0,0,0,0)',
textAccessible: true
}
}).draw();
};
</script>