Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using custom axis the timestamps don't get formatted #2902

Closed
2 tasks done
Kalhama opened this issue Sep 22, 2024 · 3 comments
Closed
2 tasks done

When using custom axis the timestamps don't get formatted #2902

Kalhama opened this issue Sep 22, 2024 · 3 comments

Comments

@Kalhama
Copy link

Kalhama commented Sep 22, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Victory version

latest

Code Sandbox link

https://codesandbox.io/p/sandbox/victory-starter-forked-5yzzn2

Bug report

When using custom axes the timestamps don't get formatted. The default axes pick good tick values, and tickformat is very nice with major value changes getting more attention. However in my application I need to adjust the axes a bit (namely offsetY={50}) and thus I lose access to those nice features.

Steps to reproduce

In the sandbox there are two graphs that I except to render same thing.

Expected behavior

I think expected behavior is to render the same axis in both scenarios. Alternatively provide a functions that default exis uses for selecting and formatting ticks, so that I can pass then on.

Actual behavior

Chart using custom axes doesn't format or pick good timestamp values

Environment

- Device: Firefox
- OS: MacOS
- Node: 20
- npm: N/A
@Kalhama Kalhama added the Type: Bug 🐛 Oh no! A bug or unintentional behavior label Sep 22, 2024
@Kalhama
Copy link
Author

Kalhama commented Sep 22, 2024

Screenshot 2024-09-23 at 0 10 48

@Kalhama
Copy link
Author

Kalhama commented Sep 23, 2024

Victory uses d3 in the background for this feature. In custom axis you can use the d3 functionality like this.

// import * as d3 from 'd3'

const domain = {
  x: [Math.min(...data.map(d => d.x)), Math.max(...data.map(d => d.x))] as DomainTuple<Date>
}

var timeScaledomain = d3.scaleTime().domain(domain.x) // or zoomDomain.x, if you're using ZoomContainer
const ticks = timeScaledomain.ticks(5)
const formatter = timeScaledomain.tickFormat()

return (
  <VictoryAxis
    tickValues={ticks}
    tickFormat={formatter}
    offsetY={50}
  />
  <VictoryAxis
    crossAxis={false}
    dependentAxis
  />
 )

i will not close the issue.as I don't know whether requiring this workaround is a intended functionality of Victory

@carbonrobot carbonrobot removed the Type: Bug 🐛 Oh no! A bug or unintentional behavior label Oct 29, 2024
@carbonrobot
Copy link
Contributor

carbonrobot commented Oct 29, 2024

Closing for now, as this is by design, but will add notes to our documentation.

@carbonrobot carbonrobot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants