Search code examples
highchartsreact-highcharts

How to change Font and text color, border color in Gantt chart Highcharts?


I want to change font family, font size, font color so that my entire chart should have same font and color. I know using style api i can do that but it only changes in some places Here i want blue border everywhere but I see option to set border color for xAxis, YAxis, and chart](https://i.sstatic.net/llOp9.png)

But this does not look good. Is there way i can set border color, font size, font family, font color all these css styles so that entire chart looks uniform to me.

      [Code Pen](https://codepen.io/manshi44/pen/OJaXOOr)

Tried api https://api.highcharts.com/highstock/chart.style and few other to change styling


Solution

  • To change the font, just set chart.style.fontFamily property:

    chart: {
      style: {
        fontFamily: 'Fasthand'
      }
    }
    

    As for text color, you can set styles for each element, you can do this for title, axis labels, credits and all the rest:

    title: {
      style: {
        color: 'red'
      }
    }
    

    Border color you need to remember about the grid, tick and lines of all axes, there are 2 x-axes in the gant by default, separate for months and separate for years:

    xAxis: [{
      gridLineColor: 'blue',
      tickColor: 'blue',
      lineColor: 'blue'
    }, {
      labels: {
        style: {
          color: 'red'
        }
      },
      tickColor: 'blue',
      lineColor: 'blue'
    }]
    

    Demo: https://jsfiddle.net/BlackLabel/5Lj6xbo8/

    API: https://api.highcharts.com/highstock/chart.style
    https://api.highcharts.com/highcharts/xAxis.labels.style.color
    https://api.highcharts.com/highcharts/title.style.color
    https://api.highcharts.com/highcharts/credits.style.color