Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Google bar chart

Options

Comments

  • Registered Users Posts: 647 ✭✭✭Freddio


    Does altering the querystrings work ?


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Freddio wrote: »
    Does altering the querystrings work ?

    Yes it does, I've sorted the left legend values and included a zero to get:

    chart?chxt=x,y&cht=bvs&chd=t:40,20,80,2,11&chco=76A4FB&chls=1.0&chs=200x125&chxl=0:|mon|tues|wed|thu|fr|1:|0|2|11|20|40|80

    Here's the url:
    http://chart.apis.google.com/chart?chxt=x,y&cht=bvs&chd=t:40,20,80,2,11&chco=76A4FB&chls=1.0&chs=200x125&chxl=0:|mon|tues|wed|thu|fr|1:|0|2|11|20|40|80
    

    Without the zero you get:

    chart?chxt=x,y&cht=bvs&chd=t:40,20,80,2,11&chco=76A4FB&chls=1.0&chs=200x125&chxl=0:|mon|tues|wed|thu|fr|1:|2|11|20|40|80

    Here's the url for that:
    http://chart.apis.google.com/chart?chxt=x,y&cht=bvs&chd=t:40,20,80,2,11&chco=76A4FB&chls=1.0&chs=200x125&chxl=0:|mon|tues|wed|thu|fr|1:|2|11|20|40|80
    


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    However, after having a look at the data (which is what I should have done in the first place) I don't think the legend is correct.

    @Placebo - it seems you're trying to match the legend to the values in the chart, and you haven't sorted them. Because they're not sorted is why you're getting the 11 at the top. The legend is the very last query string parameter chxl, and its the y-axis legend so it comes after 1:

    The second issue is that google doesn't match the bars to the values in the legend so even if you sort the y-axis legend it going to be skewed anyway. You're better off going for increments of 10 starting from 0, or leaving the y-axis legend out altogether.

    Increments of 10 gives you:
    chart?chxt=x,y&cht=bvs&chd=t:40,20,80,2,11&chco=76A4FB&chls=1.0&chs=200x125&chxl=0:|mon|tues|wed|thu|fr|1:|0|10|20|30|40|50|60|70|80

    url:
    http://chart.apis.google.com/chart?chxt=x,y&cht=bvs&chd=t:40,20,80,2,11&chco=76A4FB&chls=1.0&chs=200x125&chxl=0:|mon|tues|wed|thu|fr|1:|0|10|20|30|40|50|60|70|80
    

    No y-axis legend gives you:
    chart?chxt=x,y&cht=bvs&chd=t:40,20,80,2,11&chco=76A4FB&chls=1.0&chs=200x125&chxl=0:|mon|tues|wed|thu|fr|

    url:
    http://chart.apis.google.com/chart?chxt=x,y&cht=bvs&chd=t:40,20,80,2,11&chco=76A4FB&chls=1.0&chs=200x125&chxl=0:|mon|tues|wed|thu|fr|
    

    Other than that how are you finding the performance of Google Charts? I'm finding them very quick indeed.


  • Registered Users Posts: 8,070 ✭✭✭Placebo


    Thanks phil, i was doing it complete wrong, speeds has gotten some what better but when reading from db to populate the data, u notice slight delays in total.

    anyway im still doing something wrong,

    notice the 10 displaying bit over 10?
    notice the 150, going to 300?

    i need to set the 2nd axis as leaving it out turnicates to 100


    chart?chxt=x,y&cht=bvs&chbh=a&chd=t:10,150,16,2,11,17,8,5&chco=76A4FB&chls=1.0&chs=600x300&chxl=0:|24+Mar|25+Mar|26+Mar|27+Mar|28+Mar|29+Mar|30+Mar|31+Mar|1:|0|10|20|30|40|50|60|70|80|90|100|150|200|250|300
    chart.apis.google.com/chart?chxt=x,y&cht=bvs&chbh=a&chd=t:10,150,16,2,11,17,8,5&chco=76A4FB&chls=1.0&chs=600x300&chxl=0:|24+Mar|25+Mar|26+Mar|27+Mar|28+Mar|29+Mar|30+Mar|31+Mar|1:|0|10|20|30|40|50|60|70|80|90|100|150|200|250|300
    


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    I've run into a similar problem myself, if you find a solution let me know, I'll do the same.


  • Advertisement
  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Okay I've gotten it figured out um, sort of ...

    To scale the y-axis you don't use chxl. You need to use a combination of chxt, chxr and chds. I'll post the url first and then break it down. I've put the relevant params at the start of of the url.
    http://chart.apis.google.com/chart?chxt=x,y&chxr=1,0,160,10&chds=0,160&cht=bvs&chbh=a&chd=t:10,150,16,2,11,17,8,5&chco=76A4FB&chls=1.0&chs=600x300&chxl=0:|24+Mar|25+Mar|26+Mar|27+Mar|28+Mar|29+Mar|30+Mar|31+Mar|
    

    So we've got [noparse]http://chart.apis.google.com/chart?chxt=x,y&chxr=1,0,160,10&chds=0,160 [/noparse]...

    I'll break this down.
    • chxt = this specifies which axis you want to display. x, y in this case.
    • chxr = this is your axis range. I've set this to chxr=1,0,160,10. As follows:
      • 1 = index of the ranges you specified with chxt (in our case 0 = x, 1 = y).
      • 0 = the starting value
      • 160 = the finishing value
      • 10 = the step value 0,10,20 etc. Omit this and it decides its own.
    • chds = 0,160. This is the custom scaling for data. I'm not 100% on why yet but it appears that this has to match the starting and finishing values of the chxr param.

    This all results in the following, which I hope is pretty much what you're asking for:

    chart?chxt=x,y&chxr=1,0,160,10&chds=0,160&cht=bvs&chbh=a&chd=t:10,150,16,2,11,17,8,5&chco=76A4FB&chls=1.0&chs=600x300&chxl=0:|24+Mar|25+Mar|26+Mar|27+Mar|28+Mar|29+Mar|30+Mar|31+Mar|


  • Registered Users Posts: 8,070 ✭✭✭Placebo


    Phil you genius, fairplay and thanks a MILLION.
    I have to say for google, the api/docs for the charts seem all over the place.


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    I find its a bit like the Microsoft/MSDN documentation, it takes a while to get used to the style but then it starts to make sense.


Advertisement