hyperprop-charting-library 0.1.4 → 0.1.5

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.
package/dist/index.cjs CHANGED
@@ -100,6 +100,7 @@ var DEFAULT_OPTIONS = {
100
100
  backgroundColor: "#101114",
101
101
  axisColor: "#7f8289",
102
102
  axis: DEFAULT_AXIS_OPTIONS,
103
+ priceDecimals: 2,
103
104
  upColor: "#2fb171",
104
105
  downColor: "#d35a5a",
105
106
  gridColor: "#252932",
@@ -266,13 +267,8 @@ function createChart(element, options = {}) {
266
267
  return { min: nextMin, max: nextMax };
267
268
  };
268
269
  const formatPrice = (price) => {
269
- if (price >= 1e3) {
270
- return price.toFixed(0);
271
- }
272
- if (price >= 100) {
273
- return price.toFixed(1);
274
- }
275
- return price.toFixed(2);
270
+ const decimals = clamp(Math.round(mergedOptions.priceDecimals), 0, 8);
271
+ return price.toFixed(decimals);
276
272
  };
277
273
  const parseData = (nextData) => {
278
274
  return nextData.map((point) => ({
package/dist/index.d.cts CHANGED
@@ -4,6 +4,7 @@ interface ChartOptions {
4
4
  backgroundColor?: string;
5
5
  axisColor?: string;
6
6
  axis?: AxisOptions;
7
+ priceDecimals?: number;
7
8
  upColor?: string;
8
9
  downColor?: string;
9
10
  gridColor?: string;
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ interface ChartOptions {
4
4
  backgroundColor?: string;
5
5
  axisColor?: string;
6
6
  axis?: AxisOptions;
7
+ priceDecimals?: number;
7
8
  upColor?: string;
8
9
  downColor?: string;
9
10
  gridColor?: string;
package/dist/index.js CHANGED
@@ -76,6 +76,7 @@ var DEFAULT_OPTIONS = {
76
76
  backgroundColor: "#101114",
77
77
  axisColor: "#7f8289",
78
78
  axis: DEFAULT_AXIS_OPTIONS,
79
+ priceDecimals: 2,
79
80
  upColor: "#2fb171",
80
81
  downColor: "#d35a5a",
81
82
  gridColor: "#252932",
@@ -242,13 +243,8 @@ function createChart(element, options = {}) {
242
243
  return { min: nextMin, max: nextMax };
243
244
  };
244
245
  const formatPrice = (price) => {
245
- if (price >= 1e3) {
246
- return price.toFixed(0);
247
- }
248
- if (price >= 100) {
249
- return price.toFixed(1);
250
- }
251
- return price.toFixed(2);
246
+ const decimals = clamp(Math.round(mergedOptions.priceDecimals), 0, 8);
247
+ return price.toFixed(decimals);
252
248
  };
253
249
  const parseData = (nextData) => {
254
250
  return nextData.map((point) => ({
package/docs/API.md CHANGED
@@ -32,6 +32,7 @@ Top-level options:
32
32
  - `backgroundColor` (default `#ffffff`)
33
33
  - `axisColor` (legacy shorthand for axis line/text color)
34
34
  - `axis?: AxisOptions`
35
+ - `priceDecimals` (default `2`, used for axis/ticker/line price labels)
35
36
  - `upColor` (default `#16a34a`)
36
37
  - `downColor` (default `#dc2626`)
37
38
  - `gridColor` (default `#e2e8f0`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperprop-charting-library",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Lightweight TypeScript charting core",
5
5
  "type": "module",
6
6
  "main": "./dist/hyperprop-charting-library.cjs",