Re: use chxr parameter with a line chart

99 views
Skip to first unread message

asgallant

unread,
Aug 17, 2012, 4:09:52 PM8/17/12
to google-visua...@googlegroups.com
That option is limited to the Image Charts.  You can't specify exactly which values will appear on the axis when using the Interactive Charts, but you can set the hAxis.gridlines.count option to add more values to the axis:

new google.visualization.LineChart(document.getElementById('visualization')).draw(data{
    curveType"function",
    width500,
    height400,
    hAxis{
        gridlines{
            count10
        }
    },
    vAxis{
        maxValue400
    }
}); 

On Friday, August 17, 2012 3:14:17 PM UTC-4, aurely wrote:
Hi there,

I'm using a line chart and I want to be able to change the x-axis.
For now the API gives me [0,10,20,30] I want to change it to [0,5,10,15,20]

I know there is the chxr parameter which is exactly what i am looking for:  https://developers.google.com/chart/image/docs/chart_params#axis_type

The problem? I'm probably stupid but I'm stuck to find how to use it with the line chart API.

function drawVisualization() {
  // Create and populate the data table.
  var data = google.visualization.arrayToDataTable([
    ['in_rate', 'MeansHDS', 'MeansHDS'],
                [ 23.37,  90.04   ,null ],
                [23.8   ,  159.53 ,null],
                [24.67 ,  97.08   , null],
                [34.82 ,330.77  ,null],
                [36.53 , null       , 66.76],
                [45.39 , null       ,74.29],
                [53.95 , null       ,90.27 ],
                [62.48 , null       ,111.78],
                [70.55 , null       ,132.32]
  ]);

  // Create and draw the visualization.
  new google.visualization.LineChart(document.getElementById('visualization')).
      draw(data, {curveType: "function",
                  width: 500, height: 400,
                  vAxis: {maxValue: 400}};
          );
}

Where I have to code it?

Oe do I need to use ImageChart? I know with this one I can use chxr but this feature seems to be deprecated since April so...

Thanks a lot,

aurely

unread,
Aug 17, 2012, 6:34:51 PM8/17/12
to google-visua...@googlegroups.com

Thank you for the answer!

I already try to use Image Chart but you can't use number on the x-axis right?
And I don't know how to compare tow lines if the x-axis is a label. 

Cheers,









asgallant

unread,
Aug 17, 2012, 10:22:32 PM8/17/12
to google-visua...@googlegroups.com
I don't know what the restrictions on Image charts are, as I've never used them.

If you switched to using strings for the domain column instead of numbers, you could likely get the labels you want on the axis (as the axis labels are derived directly from the domain column), but you lose the advantages of a continuous axis (which is what you get when you use numbers in the domain column).
Reply all
Reply to author
Forward
0 new messages