1
votes

I am new to using google charts. I've successfully included the chart into the website and connected the data to mySQL database, but now I'm just trying to work on formatting the vertical axis.

    var options = {
      title: 'Company Performance',
      hAxis: {title: 'Year',  titleTextStyle: {color: '#333'}},
      vAxis: {
        minValue: 0,
        title: "price",
        format: "currency"
      },
      explorer: { actions: ['dragToZoom', 'rightClickToReset']}
    };

    var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
    chart.draw(data, options);

This is the code that I'm using to format the chart, however, the output on the website turns what should be $1.50, for example, into "4urren41970". I have tried using format: "$#,###" but then it just literally prints "$#,###" on the chart. I've also tried several of the other formating options just to experiment, but none of them are working and they just spit out a code in a similar fashion to "4urren41970".

Any help with this would be greatly apprecaited!

1
will you please share a sample of the data?WhiteHat
@WhiteHat the data is just two columns: Dates, Prices, formatted as Datetime and Double, respectively. I'm populating the chart with: while ($row = mysqli_fetch_array($result)) { echo "['".$row['date']."', ['".$row['price']."']],"; }Chrisk

1 Answers

0
votes

the price column should be a number, not a string.
and there are an extra set of brackets...

echo "['".$row['date']."', ['".$row['price']."']],";

try removing the single quotes surrounding the price column above...

echo "['".$row['date']."', ".$row['price']."],";