knightsky
knightsky

Reputation: 67

How to add font awesome icons on x-axis in highcharts

I have created multiple charts for dynamic data . I want to add font awesome icons on x-axis instead of displaying names. Please help on how can I add icon on x-axis instead of category, thank you.

Upvotes: 0

Views: 864

Answers (1)

Barbara Laird
Barbara Laird

Reputation: 12717

You need to enable useHTML for the xAxis labels.

xAxis: {
    type:"category",
    crosshair: true,
    labels: {
        useHTML: true
    }
  },

and then you can use fontAwesome icons in the category names or replace the category names by icons.

  data: [
    ['<i class="fa fa-car"></i>  car', 10],
    ['<i class="fa fa-bus"></i>  bus', 63],
    ['<i class="fa fa-truck"></i>  truck', 50],
    ['<i class="fa fa-train"></i>  train', 54],
  ]

https://jsfiddle.net/r7b0123s/1/

Upvotes: 1

Related Questions