Chartist-js: Label 'width' issues

Created on 19 Jan 2016  路  5Comments  路  Source: gionkunz/chartist-js

screen shot 2016-01-19 at 9 08 59 am

      axisX: {
        labelInterpolationFnc: function skipLabels(value, index) {
          return index % divider === 0 ? value : null;
        }
      },

So my axis labels are just 12-01 etc.. "strings". And then I use the function to prevent 30 of them from ruining the X-Axis.

But, the 'calculated width' of each label (set directly on the element) is very narrow (despite now there being tons of available room). Thus, they show up as in the screenshot.

Any thoughts on how to fix this?

(and for bonus points, the right side of my chart gets cut off once I use the label interpolation)

Most helpful comment

I ended up with:
.ct-label.ct-horizontal { white-space: nowrap; }

which seems to solve it :)

is there a list of things like the above (or a list of functions like: labelInterpolationFnc?)

I don't mind the github/irc/read the code life heh.. just curious if i'm missing a link in the docs to 'more'

All 5 comments

Maybe the fixed scale axis suits your use case better? http://gionkunz.github.io/chartist-js/getting-started.html#switching-axis-type

I ended up with:
.ct-label.ct-horizontal { white-space: nowrap; }

which seems to solve it :)

is there a list of things like the above (or a list of functions like: labelInterpolationFnc?)

I don't mind the github/irc/read the code life heh.. just curious if i'm missing a link in the docs to 'more'

Yeah there is. However, it's not presented in a very usable way. We have #565 to cover this. Within the current API documentation system, if you go to the specific Chart type and expand the details of the default options using the "show code" button you'll see a list of options: http://gionkunz.github.io/chartist-js/api-documentation.html#chartistbar-declaration-defaultoptions

brilliant! thanks.

I'm having the same problem. For some reason .ct-label.ct-horizontal { white-space: nowrap; } was working for months but recently stopped.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eddr picture eddr  路  3Comments

Globegitter picture Globegitter  路  4Comments

pathtoknowhere picture pathtoknowhere  路  4Comments

denisvolokh picture denisvolokh  路  4Comments

joshiashish23 picture joshiashish23  路  3Comments