victory icon indicating copy to clipboard operation
victory copied to clipboard

Victory Chart - How to add Axis extra tick

Open melly35 opened this issue 1 year ago • 5 comments

How are the ticks made in the area indicated by the red arrow in the picture?

Data = [0,10,20,30, ..n]

Short description: Adding extra ticks between 0-10 or 10-20 or 20-30

javafx-linechart-1

melly35 avatar Jun 19 '23 13:06 melly35

https://codesandbox.io/s/broken-resonance-qtcw2y?file=/src/App.js

<VictoryAxis crossAxis={false} style={{ ticks: { stroke: "grey", size: ({ tick }) => (tick % 10 ? 5 : 10) } }} tickCount={50} tickFormat={(tick) => (tick % 10 ? null : tick)} />

BeyondThat avatar Jun 20 '23 01:06 BeyondThat

https://codesandbox.io/s/broken-resonance-qtcw2y?file=/src/App.js

<VictoryAxis crossAxis={false} style={{ ticks: { stroke: "grey", size: ({ tick }) => (tick % 10 ? 5 : 10) } }} tickCount={50} tickFormat={(tick) => (tick % 10 ? null : tick)} />

Thank you, but how can this be done in a data like 2021/06/12 10:00:00?

melly35 avatar Jun 20 '23 07:06 melly35

Just update the functions in the proposed solution to match your logic.

For having full control over the ticks you can use tickValues prop

sem4phor avatar Jul 04 '23 09:07 sem4phor

hi @sem4phor how to add background and border radius for ticklabels in victory native charts? i want to highlight specific x axis label

helagoddr avatar Jul 24 '23 16:07 helagoddr

@helagoddr For our financial chart we passed the current price to a custom tick label component:

const YAxisTickLabel = props => {
  const { datum, currentPrice } = props

  const isCurrentPriceTick = datum === currentPrice

  if (!isCurrentPriceTick) return <VictoryLabel {...props} />

  return (
    <VictoryLabel
      animate={false}
      {...props}
      style={{ color: 'black', fontSize: 12 }}
      backgroundStyle={{
        fill: 'green'
      }}
    />
  )
}

sem4phor avatar Jul 25 '23 07:07 sem4phor

This issue is stale because it has been open for 90 days with no activity. If there is no activity in the next 7 days, the issue will be closed.

github-actions[bot] avatar Feb 23 '24 21:02 github-actions[bot]

This issue was closed because it has been inactive for 7 days since being marked as stale. Please open a new issue if you believe you are encountering a related problem.

github-actions[bot] avatar Mar 01 '24 22:03 github-actions[bot]