Christian Benseler
Christian Benseler

Reputation: 8075

Google Chart - first item from continuous horizontal axis not showing

I'm drawing a linechart with Google Chart. The first "column" from is a date, so the horizontal axis is a continuous axis. It works fine, but one problem: I want that the label from the first row is shown. Reading the documentations here all the charts with continuous horizontal axis hide the first row. Does anyone know how to solve it?

Upvotes: 0

Views: 1236

Answers (1)

asgallant
asgallant

Reputation: 26340

You can override the chart's choice of axis labels by using the hAxis.ticks option, which takes an array of values or objects. Values represent the locations to place a tick mark at, and must be of the same type as the domain column (date, datetime, timeofday, or number). Objects have two properties: v, the value to place the label at (mandatory); and f, the label to use at that value (optional). Any elements that do not specify a label will be formatted using the axis formatting.

As an example:

hAxis: {
    format: '#.00',
    ticks: [1, {v: 2, f: 'foo'}, {v: 4, f: '$4'}, {f: 5, f: '5'}, {v: 9.6}]
}

will produce an axis with labels at 1, 2, 4, 5, and 9.6, with the labels "1.00", "foo", "$4", "5", and "9.60". The labels at 1 and 9.6 were formatted according to the hAxis.format option I specified, while the others use the labels I specified in the objects.

Upvotes: 1

Related Questions