-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
set tick count for y-axis? #560
Comments
It doesn't look like c3 supports setting the count for y axis ticks looking at the library's reference/options, it should be trivial to implement though! |
Good to hear, AnSavvides! |
You'll need to extend // update axis tick values according to options
if (!config.axis_x_tick_values && (config.axis_x_tick_fit || config.axis_x_tick_count)) {
tickValues = $$.generateTickValues($$.mapTargetsToUniqueXs(targetsToShow), config.axis_x_tick_count);
$$.xAxis.tickValues(tickValues);
$$.subXAxis.tickValues(tickValues);
} So you could for example rename |
Ah, great! |
No worries Steph, let me know if you need a hand :) |
Hey, so there is a far easier way to set the number of ticks to use: In the generate() function you can set axis.y.ticks to whatever value you would like. c3 will use this in place of the default 10.
No need to extend or override the base functionality for it, it's already there. |
Hi, I added |
thank you much @masayuki0812 you are awesome |
In the generate() function you can set axis.y.tick to whatever value you would like. c3 will use this in place of the default 10. var chart = c3.generate({ |
I find the Here is a workaround: c3_config.axis.y.tick.count = Math.min(
[
// get unique values.
...new Map(
c3_config.data.columns
// skip x row if present.
.filter((dataset) => dataset[0] !== 'x')
// skip dataset key.
.map((dataset) => dataset.slice(1))
// merge all datasets into one set.
.flat()
// prepare for map constructor.
.map((value) => [value, value])
).values()
].length,
10
); It basically uses either the preferred 10 or, if lower, the amount of unique values. |
Is there any way to set the tick count for the y-axis like there is for x-axis?
I have y-values that do not make sense to be floats, yet when there are only 2 the chart gives me floating values between 0-1, 1-2.
Any suggestions are welcome, thank you.
The text was updated successfully, but these errors were encountered: