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

[Bug]: Tick type does not accept array of objects #578

Open
1 task done
thepolarchimps opened this issue Apr 4, 2022 · 1 comment
Open
1 task done

[Bug]: Tick type does not accept array of objects #578

thepolarchimps opened this issue Apr 4, 2022 · 1 comment
Labels

Comments

@thepolarchimps
Copy link

Would you like to work on a fix?

  • Check this if you would like to implement a PR, we are more than happy to help you go through the process.

Current and expected behavior

Hiya Folks,

Current implementation of GoogleChartTicks does not accept an array of objects.

From documentation:

Replaces the automatically generated X-axis ticks with the specified array. Each element of the array should be either a valid tick value (such as a number, date, datetime, or timeofday), or an object. If it's an object, it should have a v property for the tick value, and an optional f property containing the literal string to be displayed as the label.

The viewWindow will be automatically expanded to include the min and max ticks unless you specify a viewWindow.min or viewWindow.max to override.

Examples:

hAxis: { ticks: [5,10,15,20] }
hAxis: { ticks: [{v:32, f:'thirty two'}, {v:64, f:'sixty four'}] }
hAxis: { ticks: [new Date(2014,3,15), new Date(2013,5,15)] }
hAxis: { ticks: [16, {v:32, f:'thirty two'}, {v:64, f:'sixty four'}, 128] }

This option is only supported for a continuous axis.

Reproduction

https://github.com/thepolarchimps/rgc-ticks

react-google-charts version

v4.0.0

Possible solution

Replace:

export type GoogleChartTicks = (number | Date)[];
with:

export type GoogleChartTicks = { v: (number | Date), f: string }[] | (number | Date)[];

@thepolarchimps
Copy link
Author

Oops, I meant:

export type GoogleChartTicks = ( { v: number | Date; f: string } | number | Date)[];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant