@leavepulse/ui 0.93.0 → 0.93.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -75,9 +75,9 @@ export interface ChartAnnotation {
|
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Which x labels to print with every `stride`-th one shown. The last point is
|
|
78
|
-
* always labelled (it is usually "now"), and when it lands
|
|
79
|
-
* stride to the previous shown label that one gives way: "20 22 23" read
|
|
80
|
-
* one smudge at the end of an hourly axis.
|
|
78
|
+
* always labelled (it is usually "now"), and when it lands closer than a
|
|
79
|
+
* full stride to the previous shown label that one gives way: "20 22 23" read
|
|
80
|
+
* as one smudge at the end of an hourly axis.
|
|
81
81
|
*/
|
|
82
82
|
export declare function xLabelIndices(count: number, stride: number): number[];
|
|
83
83
|
/** The x index a marker points at, or -1 when it names nothing on the axis. */
|
package/dist/components/chart.js
CHANGED
|
@@ -7,7 +7,7 @@ function xLabelIndices(count, stride) {
|
|
|
7
7
|
for (let i = 0; i < count; i += step) out.push(i);
|
|
8
8
|
const last = count - 1;
|
|
9
9
|
if (out[out.length - 1] !== last) {
|
|
10
|
-
if (out.length > 1 && last - out[out.length - 1]
|
|
10
|
+
if (out.length > 1 && last - out[out.length - 1] < step) out.pop();
|
|
11
11
|
out.push(last);
|
|
12
12
|
}
|
|
13
13
|
return out;
|
package/package.json
CHANGED
package/src/components/chart.ts
CHANGED
|
@@ -91,9 +91,9 @@ export interface ChartAnnotation {
|
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* Which x labels to print with every `stride`-th one shown. The last point is
|
|
94
|
-
* always labelled (it is usually "now"), and when it lands
|
|
95
|
-
* stride to the previous shown label that one gives way: "20 22 23" read
|
|
96
|
-
* one smudge at the end of an hourly axis.
|
|
94
|
+
* always labelled (it is usually "now"), and when it lands closer than a
|
|
95
|
+
* full stride to the previous shown label that one gives way: "20 22 23" read
|
|
96
|
+
* as one smudge at the end of an hourly axis.
|
|
97
97
|
*/
|
|
98
98
|
export function xLabelIndices(count: number, stride: number): number[] {
|
|
99
99
|
if (count <= 0) return []
|
|
@@ -102,7 +102,10 @@ export function xLabelIndices(count: number, stride: number): number[] {
|
|
|
102
102
|
for (let i = 0; i < count; i += step) out.push(i)
|
|
103
103
|
const last = count - 1
|
|
104
104
|
if (out[out.length - 1] !== last) {
|
|
105
|
-
|
|
105
|
+
// The stride is the spacing at which labels fit, so a last label closer
|
|
106
|
+
// than a full step to the one before would print over it ("10:03 PM10:09
|
|
107
|
+
// PM"): the earlier one gives way.
|
|
108
|
+
if (out.length > 1 && last - out[out.length - 1] < step) out.pop()
|
|
106
109
|
out.push(last)
|
|
107
110
|
}
|
|
108
111
|
return out
|