Skip to content

Commit

Permalink
LineUtils: support decreasing axis ticks
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Nölle committed Aug 23, 2022
1 parent 2598de3 commit a72d5b4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/LineUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ class AxesMgmt {
}

private static _getTicks(valueRange: [number, number], numTicks: number): [Array<number>, number] {
const reverse: boolean = valueRange[0] > valueRange[1];
if (reverse)
valueRange = [valueRange[1], valueRange[0]];
const length: number = Math.abs(valueRange[1] - valueRange[0]);
const l: number = length/(numTicks-1);
const tenBase: number = Math.round(Math.log(l) / AxesMgmt._LOG_10); // log with base 10 of l
Expand All @@ -212,6 +215,8 @@ class AxesMgmt {
start += proposedDistance;
}
const decimals = proposedDistance >= 1 ? 0 : -Math.floor(Math.log(proposedDistance)/AxesMgmt._LOG_10);
if (reverse)
ticks.reverse();
return [ticks, decimals];
}

Expand Down

0 comments on commit a72d5b4

Please sign in to comment.