@opendata-ai/openchart-engine 6.1.3 → 6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opendata-ai/openchart-engine",
3
- "version": "6.1.3",
3
+ "version": "6.1.5",
4
4
  "description": "Headless compiler for openchart: spec validation, data compilation, scales, and layout",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Riley Hilliard",
@@ -45,7 +45,7 @@
45
45
  "typecheck": "tsc --noEmit"
46
46
  },
47
47
  "dependencies": {
48
- "@opendata-ai/openchart-core": "6.1.3",
48
+ "@opendata-ai/openchart-core": "6.1.5",
49
49
  "d3-array": "^3.2.0",
50
50
  "d3-format": "^3.1.2",
51
51
  "d3-interpolate": "^3.0.0",
@@ -19,6 +19,7 @@ import type {
19
19
  import {
20
20
  abbreviateNumber,
21
21
  buildD3Formatter,
22
+ buildTemporalFormatter,
22
23
  estimateTextWidth,
23
24
  formatDate,
24
25
  formatNumber,
@@ -252,7 +253,8 @@ function formatTickLabel(value: unknown, resolvedScale: ResolvedScale): string {
252
253
  const formatStr = resolvedScale.channel.axis?.format;
253
254
 
254
255
  if (TEMPORAL_SCALE_TYPES.has(resolvedScale.type)) {
255
- if (formatStr) return String(value); // Custom format not implemented yet
256
+ const temporalFmt = buildTemporalFormatter(formatStr);
257
+ if (temporalFmt) return temporalFmt(value as Date);
256
258
  return formatDate(value as Date);
257
259
  }
258
260
 
@@ -18,7 +18,7 @@ import type {
18
18
  TooltipContent,
19
19
  TooltipField,
20
20
  } from '@opendata-ai/openchart-core';
21
- import { formatDate, formatNumber } from '@opendata-ai/openchart-core';
21
+ import { buildTemporalFormatter, formatDate, formatNumber } from '@opendata-ai/openchart-core';
22
22
  import { format as d3Format } from 'd3-format';
23
23
 
24
24
  import type { NormalizedChartSpec } from '../compiler/types';
@@ -32,6 +32,8 @@ function formatValue(value: unknown, fieldType?: string, format?: string): strin
32
32
  if (value == null) return '';
33
33
 
34
34
  if (fieldType === 'temporal' || value instanceof Date) {
35
+ const temporalFmt = buildTemporalFormatter(format);
36
+ if (temporalFmt) return temporalFmt(value as Date | string | number);
35
37
  return formatDate(value as Date | string | number);
36
38
  }
37
39