Skip to content

Commit

Permalink
add stepSize; fixes #332
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Dec 12, 2023
1 parent 3c50f32 commit f60a915
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/modules/Scales.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ export default class Range {
}
let stepSize = magMsd * magPow

if (w.config.yaxis[index].stepSize) {
stepSize = w.config.yaxis[index].stepSize
}

if (
w.globals.isBarHorizontal &&
w.config.xaxis.stepSize &&
w.config.xaxis.type !== 'datetime'
) {
stepSize = w.config.xaxis.stepSize
}

// build Y label array.
// Lower and upper bounds calculations
let lb = stepSize * Math.floor(yMin / stepSize)
Expand Down
12 changes: 11 additions & 1 deletion src/modules/axes/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,18 @@ class Grid {
if (w.config.xaxis.tickAmount && w.config.xaxis.labels.formatter) {
xCount = w.config.xaxis.tickAmount
}
if (
w.globals.yAxisScale?.[0]?.result?.length > 0 &&
w.config.xaxis.type !== 'datetime'
) {
xCount = w.globals.yAxisScale[0].result.length - 1
}
}
this._drawXYLines({ xCount, tickAmount: yTickAmount })

this._drawXYLines({
xCount,
tickAmount: yTickAmount,
})
} else {
xCount = yTickAmount

Expand Down
2 changes: 2 additions & 0 deletions src/modules/settings/Options.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default class Options {
logarithmic: false,
logBase: 10,
tickAmount: undefined,
stepSize: undefined,
forceNiceScale: false,
max: undefined,
min: undefined,
Expand Down Expand Up @@ -1048,6 +1049,7 @@ export default class Options {
offsetX: 0,
offsetY: 0,
},
stepSize: undefined,
tickAmount: undefined,
tickPlacement: 'on',
min: undefined,
Expand Down
2 changes: 2 additions & 0 deletions types/apexcharts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,7 @@ type ApexXAxis = {
}
tickPlacement?: string
tickAmount?: number | 'dataPoints'
stepSize?: number
min?: number
max?: number
range?: number
Expand Down Expand Up @@ -1120,6 +1121,7 @@ type ApexYAxis = {
logarithmic?: boolean,
logBase?: number,
tickAmount?: number
stepSize?: number
forceNiceScale?: boolean
min?: number | ((min: number) => number)
max?: number | ((max: number) => number)
Expand Down

0 comments on commit f60a915

Please sign in to comment.