How to add axis title in Chartist

firstprayer picture firstprayer · Mar 28, 2015 · Viewed 8.8k times · Source

I'm using Chartist for browser visualization.

The requirement here is that I need to add title to the X and Y axis, so that viewers know what does each axis represent. However I went through the online document of Chartist and found no documentation about this. Did I miss something, or this feature is not supported in Chartist? If it's not supported, is there any way to work this out?

Answer

Luis U. picture Luis U. · Aug 22, 2015

You can download and use the Axis Title Plugin developed by Alex Stanbury. This is the code you must add to your existing chart options.

plugins: [
 Chartist.plugins.ctAxisTitle({
    axisX: {
       axisTitle: 'X title',
       axisClass: 'ct-axis-title',
       offset: {
          x: 0,
          y: 50
       },
       textAnchor: 'middle'
    },
    axisY: {
       axisTitle: 'Y title',
       axisClass: 'ct-axis-title',
       offset: {
          x: 0,
          y: 0
       },
       textAnchor: 'middle',
       flipTitle: false
     }
   })
 ]