Search code examples
javascriptvictory-charts

Victory charts, how to change axis and label colors


this should be a very simple thing to do, but for the life of me I cannot achieve the effect I want, I have a chart, on a dark background, which means I want to change the color of the labels to white, however I cannot achieve this.

enter image description here

The code I'm using:

<VictoryChart
            width={WIDTH}
          // theme={VictoryTheme.material}
          >
            {/* <VictoryBar data={data} x="quarter" y="earnings" /> */}
            <VictoryArea data={outcome} x="quarter" y="earnings" style={{ data: { fill: '#0074B7', fillOpacity: 0.7, stroke: '#0C7BBB', strokeWidth: 1 } }} />
            {/* <VictoryArea data={income} x="quarter" y="earnings" style={{ data: { fill: '#9BC578', fillOpacity: 0.7, stroke: '#37B875', strokeWidth: 1 } }} /> */}
          </VictoryChart>

Any help is appreciated.


Solution

  • I got my charts numbers to change but I am using the custom theming to do it but I would imagine its similar. I have posted an example below

    const chartTheme = {
      axis: {
        style: {
          tickLabels: {
            // this changed the color of my numbers to white
            fill: 'white',
          },
        },
      },
    };
    
    
          <VictoryChart theme={ chartTheme }>
            <VictoryAxis label="Body Weight" />
            <VictoryAxis dependentAxis label="Time" />
            <VictoryLine
              data={ [
                { x: 1, y: 2 },
                { x: 2, y: 3 },
                { x: 3, y: 5 },
                { x: 4, y: 4 },
                { x: 5, y: 7 },
              ] }
            />
          </VictoryChart>