Search code examples
jqplot

jqplot: split the xaxis tick text into words


The labels I use on axis for my graph contains text with more than one word. Like this:

enter image description here

and it looks bad. I tried (as you can see on the graph) to replace the wit spaces with brs or with \n in order to render the text in multiple lines. The result is not what I was expected to get.

How to split the ticks text into words and to draw each word on a row?


Solution

  • The <br/> is working will trying to split your text into two lines. See a working example here.

    In order to make it work, don't forget to load some jqplot plugins : CanvasAxisTickRenderer, CategoryAxisRenderer. You then need to apply tickRenderer: $.jqplot.CanvasAxisTickRenderer to your serie(s). You need as weel to apply renderer: $.jqplot.CategoryAxisRenderer onto your yaxis.