GoogleWebComponents / google-chart

Google Charts API web components
https://www.webcomponents.org/element/@google-web-components/google-chart/elements/google-chart
Apache License 2.0
358 stars 130 forks source link

Google Chart option: hAxes title and direction doesnt work together #178

Closed ponnex closed 7 years ago

ponnex commented 7 years ago

Hi I have problem adding title and direction at the same time in hAxes.

When writing hAxes": [ {"direction": -1} ] or hAxes": [ {"title": "Date"} ] works well but hAxes": [ {"title":"Date"}, {"direction": -1} ] doesnt.

And I observed that whichever among title and direction comes first in hAxes": [ {"title":"Date"}, {"direction": -1} ] is the one that will append on the code e.g. hAxes": [ {"title":"Date"}, {"direction": -1} ] Date will show on the graph but direction will not work however, hAxes": [ {"direction": -1}, {"title":"Date"} ] direction will work but title doesnt.

<google-chart
  id="strmflow"
  type='line'
  options='{"title": "Stream Flow", 
      "vAxes": [ {"title": "Flow Duration Curve"}, {"title": "Module Summary"}, 
               "scaleType": "log"}, {"scaleType": "log"} ], 
      "hAxes": [ {"direction": -1} ],
      "series": [ {"targetAxisIndex": 0}, {"targetAxisIndex": 1} ]}'
  cols='[ {"label":"Date", "type":"string"}, {"label":"Flow Duration Curve", "type":"number"}, 
      {"label":"Module Summary", "type":"number"} ]'
  rows='[ [" ", 0, 0],[" ", 0, 0],[" ", 0, 0] ]'>
</google-chart>
wesalvaro commented 7 years ago

The chart in your example only has one series. The vAxes and hAxes options are an array of objects, one for each series. You should only be using one object, like so:

{"title": "Date", "direction": -1}

Line Chart configuration documentation

If you still feel like this is an issue, please file it against this other project, instead. The google-chart element is simply a wrapper around it and most issues with chart drawing are unrelated.

ponnex commented 7 years ago

Thanks a lot! I already solve this issue by instead of

'"hAxes": [ {"title":"Date"}, {"direction": -1}, {"title":"Date"}, {"direction": -1} ]'

use

'"hAxes": [ {"title": "Date", "direction": -1}, {"title": "Date", "direction": -1} ]'

Thanks again! :D

wesalvaro commented 7 years ago

Yup! That'll do it! Glad you figured it out.