15

I'm using victory-native and have a VictoryChart with a VictoryLine and VictoryArea as children and want to remove the axis of the chart. Is there any way to access it through props? Probably the color can be set to transparent then.

Here is some code:

 <VictoryChart
  containerComponent={
    <VictoryContainer />
  }
 > 
  <VictoryArea
    interpolation={interpolation}
    data={this.state.data}
  />
  <VictoryLine
    interpolation={interpolation}
    data={this.state.data}
  />
</VictoryChart>
student96
  • 345
  • 1
  • 4
  • 14

3 Answers3

18

Add VictoryAxis with transparent stroke and fill:

<VictoryAxis style={{ 
    axis: {stroke: "transparent"}, 
    ticks: {stroke: "transparent"},
    tickLabels: { fill:"transparent"} 
}} />

Then the result becomes:

 <VictoryChart
  containerComponent={
    <VictoryContainer />
  }
 > 
  <VictoryArea
    interpolation={interpolation}
    data={this.state.data}
  />
  <VictoryLine
    interpolation={interpolation}
    data={this.state.data}
  />
  <VictoryAxis style={{ 
    axis: {stroke: "transparent"}, 
    ticks: {stroke: "transparent"},
    tickLabels: { fill:"transparent"} 
  }} />
</VictoryChart>
Faisal Mulya
  • 653
  • 7
  • 7
10

VictoryChart uses default axes. If you want to plot data without using any axes, use VictoryGroup instead.

See the FAQ

timbo
  • 13,244
  • 8
  • 51
  • 71
9

Maybe you can try to add VictoryAxis with axis stroke none to after your chart

<VictoryChart
  containerComponent={
    <VictoryContainer />
  }
 > 
  <VictoryArea
    interpolation={interpolation}
    data={this.state.data}
  />
  <VictoryLine
    interpolation={interpolation}
    data={this.state.data}
  />
  <VictoryAxis style={{ axis: {stroke: "none"} }} />
</VictoryChart>
QuảngPB
  • 121
  • 6
  • Thanks, this worked for removing the axis lines, but the tick labels are still there. I found some ways to remove (move out of rendered view) them, maybe you can update you answers with those and probably better ones: - add tickLabelComponent with empty View component -> tickLabelComponent={} - add tickValues={[x, y]}, where x and y are values out of rendered view, for example min(data.x) - 1 and max(data.x) + 1 – student96 Nov 28 '17 at 13:15
  • I downvoted because this is not the correct answer. – quinn Oct 10 '19 at 01:33
  • 1
    @student96 i hid the tick labels by adding `tickFormat={() => ""}` to `VictoryAxis` – Tekeste Kidanu Feb 20 '21 at 17:26