graphein 0.15.0 → 0.16.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.
- package/dist/index.d.ts +17 -1
- package/dist/index.js +44 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -354,6 +354,14 @@ declare class RoughPen {
|
|
|
354
354
|
private readonly rng;
|
|
355
355
|
constructor(ctx: RoughContext, style?: Partial<RoughStyle>);
|
|
356
356
|
private resolve;
|
|
357
|
+
/**
|
|
358
|
+
* Run `draw` with `factor` folded into the *ambient* `globalAlpha`, then restore
|
|
359
|
+
* it. Callers honoring a cross-highlight set `ctx.globalAlpha` below 1 to dim a
|
|
360
|
+
* non-selected mark; composing (rather than overwriting and resetting to 1) keeps
|
|
361
|
+
* that dim while still applying the pen's own fill/stroke translucency, so sketch
|
|
362
|
+
* marks dim during a highlight exactly like their solid-rendered counterparts.
|
|
363
|
+
*/
|
|
364
|
+
private withAlpha;
|
|
357
365
|
/** A symmetric random offset in [-x, x], scaled by a length-based gain. */
|
|
358
366
|
private off;
|
|
359
367
|
/**
|
|
@@ -2969,6 +2977,14 @@ declare function prettyDate(value: Date | number): string;
|
|
|
2969
2977
|
* `"2024-05-02"` renders `May 2, 2024` rather than the raw string.
|
|
2970
2978
|
*/
|
|
2971
2979
|
declare function formatValue(value: unknown, hint?: string): string;
|
|
2980
|
+
/**
|
|
2981
|
+
* Format one frame of a count-up / value tween so it never shows finer precision
|
|
2982
|
+
* than the final value. With an explicit format the decimals are already pinned,
|
|
2983
|
+
* so this defers to {@link formatValue}. With the smart default it mirrors the
|
|
2984
|
+
* final value's own precision (a whole-number target stays whole) — otherwise a
|
|
2985
|
+
* tween between integers would flash up to 6 decimals mid-animation.
|
|
2986
|
+
*/
|
|
2987
|
+
declare function formatCountUp(displayValue: number, finalValue: number, hint?: string): string;
|
|
2972
2988
|
|
|
2973
2989
|
/**
|
|
2974
2990
|
* Layout engine.
|
|
@@ -4088,4 +4104,4 @@ declare function renderDashboard(target: HTMLElement | string, spec: DashboardSp
|
|
|
4088
4104
|
*/
|
|
4089
4105
|
declare const VERSION = "0.1.0";
|
|
4090
4106
|
|
|
4091
|
-
export { type AggOp, type AggregateOp, type AggregateTransform, type AnimateOptions, type AnimationConfig, type AnimationHandle, type Annotation, type AnySpec, type ArcOptions, type AreaOptions, type AreaPoint, type AreaSpec, type AxesConfig, type AxisConfig, type AxisInput, type BackingSize, type BandScale, type BandScaleOptions, type BarSpec, type BaseSlicerSpec, type BaseSpec, type BinLayout, type BinTransform, type BoxSpec, type BuildOptions, type BulletSpec, CARTESIAN_TYPES, CHART_TYPES, type CalculateTransform, type CalendarHeatmapSpec, CanvasLayer, type CanvasPillStyle, type CanvasTextCmd, type CartesianChartSpec, type CartesianInteractionBuilder, type CartesianModel, type CartesianRenderer, type CategoryInsights, type ChartInsights, type ChartInstance, type ChartSpec, type ChartSummary, type ChartType, type ChoroplethSpec, type ColorScale, type ColumnProfile, type ComboAxisModel, type ComboLayer, type ComboLayerModel, type ComboMark, type ComboModel, type ComboSide, type ComboSpec, type Comparable, type ConditionalFormat, type ContinuousScale, type ControllerSelect, type Curve, type CurveType, type CustomRenderer, DEFAULT_ENTRANCE_DURATION, DEFAULT_ROUGH_STYLE, DEFAULT_UPDATE_DURATION, DIM_ALPHA, type DashboardCell, type DashboardInstance, type DashboardLayout, type DashboardResponsiveSpan, type DashboardSection, type DashboardSpec, type DashboardView, type DateRangeSlicerSpec, type Datum, type DecimateOptions, type Dimensions, type DropdownSlicerSpec, type DumbbellSpec, type EasingFunction, type Emphasis, type Encoding, type EntranceContext, ExpressionError, type Extent, FACETABLE_TYPES, FUNCTION_NAMES, type FacetConfig, type FacetLayout, type FacetPanel, type FieldDef, type FieldType, type FieldValue, type FillStyle, type FilterClause, type FilterPredicate, type FilterTransform, type FoldTransform, type Frame, type FrameInput, type FunnelSpec, type GaugeSpec, type GeoFeature, type GeoFeatureCollection, type GeoGeometry, type GeoMultiPolygon, type GeoPolygon, type GeoPosition, type GroupedMap, type HachureSegment, type HeadlessTarget, type HeatmapSpec, type HighlightConfig, type HistogramBin, type HistogramBinDatum, type HistogramModel, type HistogramSpec, type Hover, type IconRule, type Insets, type InsightFamily, type InsightOptions, type Inspector, type InspectorOptions, InteractionController, type InteractionLink, type InteractionModel, type Interpolator, type JsonPatchOp, type KpiComparison, type KpiSpec, type LegendConfig, type LegendHitRegion, type LegendItem, type LegendPosition, type LegendSymbol, type LineOptions, type LineSpec, type LinearScaleOptions, type LintFinding, type ListSlicerSpec, type LiteralPredicate, type LogScaleOptions, type MapProjection, type MarkOptions, type MatrixSpec, type MatrixValueDef, NO_PADDING, type NumberFormatSpec, type OKLCH, type OKLab, type OverlayTextOpts, type PathSink, type PieLabels, type PieSpec, type PivotCell, type PivotFlatRow, type PivotHeaderNode, type PivotOptions, type PivotResult, type PivotValueDef, type Point, type PointRef, type PointScale, type PointScaleOptions, type PointSelection, type PositionedLegendItem, type RGBA, type RangeSelection, type RangeSlicerSpec, type RecommendOptions, type RecommendedChart, type Rect, type RegressionFit, type RenderContext, type RenderDashboardOptions, type RenderDiagnostic, type RenderOptions, type RenderReport, type RepairResult, type ReportInput, type ReportSeverity, type ResolvedEntrance, type ResolvedSeries, type ResolvedSketch, type Rng, type RoughContext, RoughPen, type RoughStyle, SKETCH_FONT_FAMILY, SKETCH_FONT_NAME, SLICER_TYPES, SPEC_ATTR, SR_ONLY_STYLE, type SankeySpec, type ScaleConfig, type ScaleType, type ScatterInsights, type ScatterSpec, type SearchSlicerSpec, type SelectConfig, type SelectionChangeListener, type SelectionDef, type SelectionListener, type SelectionParam, type SelectionStore, type SelectionValue, type SeriesInsights, type SetSelection, type SharedScales, type Size, type SketchConfig, type SlicerSpec, type SlicerType, type SlopeSpec, Surface, TICK_SIZE, TIME_UNITS, TRANSFORM_KINDS, TYPE_ATTR, type TableColumn, type TableSpec, type TextMetricsLite, type TextSelection, type ThemeColors, type ThemeFont, type ThemeInput, type ThemeTokens, type Tick, type TimeScaleOptions, type TimeUnit, type TimeUnitTransform, type TitleConfig, type TitleInput, Tooltip, type TooltipConfig, type TooltipContent, type TooltipRow, type Transform, type TreemapSpec, type TrendlineConfig, type UpdateContext, VERSION, type ValidationError, type ValidationResult, type ValueInsights, type ValueRef, type ValueRule, type WaterfallSpec, type WiredView, type XKind, type XModel, type YModel, aggregateValues, analyzeChart, animate, applyA11y, applyAggregate, applyBin, applyCalculate, applyFilter, applyFold, applyPatch, applyPick, applyTimeUnit, applyTransform, applyTransforms, arc, area, assertValidSpec, autoInsightAnnotations, backOut, bandScale, bounceOut, buildCartesianInteraction, buildCartesianModel, buildComboModel, buildDataTableFallback, buildFacetModels, buildHistogramModel, buildRenderReport, cartesianInteractionBuilders, cartesianRenderers, categorical, categoricalSchemes, chartTitleText, chartTypeLabel, checkExpression, clamp01, clamp255, compileExpression, compilePredicate, computeBackingSize, computeBins, computeFrame, computeSeriesInsights, contrastRatio, createDiv, createInspector, createRoughPen, createSelectionStore, cubicIn, cubicInOut, cubicOut, curveCatmullRom, curveLinear, curveMonotoneX, curveStep, curveStepAfter, curveStepBefore, customRenderers, darkTheme, decimate, defaultSpan, dependentParams, diverging, divergingColorScale, divergingSchemes, drawAnnotationLabels, drawAnnotations, drawAxesUnderlay, drawFacet, drawLegend, drawOverlay, drawTitle, drawTrendlineLabels, drawTrendlines, easings, elasticOut, ellipsize, ensureSketchFont, expoInOut, expoOut, facetReport, fillParentStyle, filterRows, fontString, formatDate, formatNumber, formatValue, getDevicePixelRatio, groupBy, hashString, inferFieldType, inferFieldTypes, inferValueType, inheritInto, interpolateArray, interpolateNumber, interpolateNumberArray, interpolateObject, interpolateOklab, interpolateRgb, isBrowser, isEmptyValue, isFaceted, isParamClause, isSlicerType, keyFields, legendSwatchWidth, lightTheme, line, linear, linearRegression, linearScale, linearToSrgb, lintSpec, literalToValue, logScale, lttbRun, makeMatcher, matchesValue, measureText, monotoneXTangents, mulberry32, niceDomain, oklabToOklch, oklabToRgb, oklchToOklab, ordinalColorScale, overlayTextToCanvasCmd, paintCanvasText, paintLegendSwatch, parseColor, parseNumberFormat, pivot, placeViews, pointScale, polygonHachureLines, prefersReducedMotion, prettyDate, profileColumns, quadIn, quadInOut, quadOut, rampFromStops, readableTextColor, recommendChart, relativeLuminance, render, renderDashboard, renderToContext, repairReport, repairSpec, resolveCurve, resolveDashboardLayout, resolveDashboardSections, resolveEmphasis, resolveEntrance, resolveFilterValues, resolveInsightOptions, resolveSketch, resolveTheme, resolveUpdate, resolveValueRef, rgbToOklab, rgbaToCss, rotatePoint, roundedRect, sampleArc, sequential, sequentialColorScale, sequentialSchemes, serializeSpec, setMeasureContext, setStyle, sinInOut, slicerParamName, smartDate, specFields, srgbToLinear, stripData, summarize, summarizeChart, themes, tickIncrement, tickStep, ticks, timeScale, timeTickFormat, timeTicks, toHex, toPointer, tooltipEnabled, truncateTo, validateDashboard, validateSpec, wireViews, withAlpha, withSketchFont };
|
|
4107
|
+
export { type AggOp, type AggregateOp, type AggregateTransform, type AnimateOptions, type AnimationConfig, type AnimationHandle, type Annotation, type AnySpec, type ArcOptions, type AreaOptions, type AreaPoint, type AreaSpec, type AxesConfig, type AxisConfig, type AxisInput, type BackingSize, type BandScale, type BandScaleOptions, type BarSpec, type BaseSlicerSpec, type BaseSpec, type BinLayout, type BinTransform, type BoxSpec, type BuildOptions, type BulletSpec, CARTESIAN_TYPES, CHART_TYPES, type CalculateTransform, type CalendarHeatmapSpec, CanvasLayer, type CanvasPillStyle, type CanvasTextCmd, type CartesianChartSpec, type CartesianInteractionBuilder, type CartesianModel, type CartesianRenderer, type CategoryInsights, type ChartInsights, type ChartInstance, type ChartSpec, type ChartSummary, type ChartType, type ChoroplethSpec, type ColorScale, type ColumnProfile, type ComboAxisModel, type ComboLayer, type ComboLayerModel, type ComboMark, type ComboModel, type ComboSide, type ComboSpec, type Comparable, type ConditionalFormat, type ContinuousScale, type ControllerSelect, type Curve, type CurveType, type CustomRenderer, DEFAULT_ENTRANCE_DURATION, DEFAULT_ROUGH_STYLE, DEFAULT_UPDATE_DURATION, DIM_ALPHA, type DashboardCell, type DashboardInstance, type DashboardLayout, type DashboardResponsiveSpan, type DashboardSection, type DashboardSpec, type DashboardView, type DateRangeSlicerSpec, type Datum, type DecimateOptions, type Dimensions, type DropdownSlicerSpec, type DumbbellSpec, type EasingFunction, type Emphasis, type Encoding, type EntranceContext, ExpressionError, type Extent, FACETABLE_TYPES, FUNCTION_NAMES, type FacetConfig, type FacetLayout, type FacetPanel, type FieldDef, type FieldType, type FieldValue, type FillStyle, type FilterClause, type FilterPredicate, type FilterTransform, type FoldTransform, type Frame, type FrameInput, type FunnelSpec, type GaugeSpec, type GeoFeature, type GeoFeatureCollection, type GeoGeometry, type GeoMultiPolygon, type GeoPolygon, type GeoPosition, type GroupedMap, type HachureSegment, type HeadlessTarget, type HeatmapSpec, type HighlightConfig, type HistogramBin, type HistogramBinDatum, type HistogramModel, type HistogramSpec, type Hover, type IconRule, type Insets, type InsightFamily, type InsightOptions, type Inspector, type InspectorOptions, InteractionController, type InteractionLink, type InteractionModel, type Interpolator, type JsonPatchOp, type KpiComparison, type KpiSpec, type LegendConfig, type LegendHitRegion, type LegendItem, type LegendPosition, type LegendSymbol, type LineOptions, type LineSpec, type LinearScaleOptions, type LintFinding, type ListSlicerSpec, type LiteralPredicate, type LogScaleOptions, type MapProjection, type MarkOptions, type MatrixSpec, type MatrixValueDef, NO_PADDING, type NumberFormatSpec, type OKLCH, type OKLab, type OverlayTextOpts, type PathSink, type PieLabels, type PieSpec, type PivotCell, type PivotFlatRow, type PivotHeaderNode, type PivotOptions, type PivotResult, type PivotValueDef, type Point, type PointRef, type PointScale, type PointScaleOptions, type PointSelection, type PositionedLegendItem, type RGBA, type RangeSelection, type RangeSlicerSpec, type RecommendOptions, type RecommendedChart, type Rect, type RegressionFit, type RenderContext, type RenderDashboardOptions, type RenderDiagnostic, type RenderOptions, type RenderReport, type RepairResult, type ReportInput, type ReportSeverity, type ResolvedEntrance, type ResolvedSeries, type ResolvedSketch, type Rng, type RoughContext, RoughPen, type RoughStyle, SKETCH_FONT_FAMILY, SKETCH_FONT_NAME, SLICER_TYPES, SPEC_ATTR, SR_ONLY_STYLE, type SankeySpec, type ScaleConfig, type ScaleType, type ScatterInsights, type ScatterSpec, type SearchSlicerSpec, type SelectConfig, type SelectionChangeListener, type SelectionDef, type SelectionListener, type SelectionParam, type SelectionStore, type SelectionValue, type SeriesInsights, type SetSelection, type SharedScales, type Size, type SketchConfig, type SlicerSpec, type SlicerType, type SlopeSpec, Surface, TICK_SIZE, TIME_UNITS, TRANSFORM_KINDS, TYPE_ATTR, type TableColumn, type TableSpec, type TextMetricsLite, type TextSelection, type ThemeColors, type ThemeFont, type ThemeInput, type ThemeTokens, type Tick, type TimeScaleOptions, type TimeUnit, type TimeUnitTransform, type TitleConfig, type TitleInput, Tooltip, type TooltipConfig, type TooltipContent, type TooltipRow, type Transform, type TreemapSpec, type TrendlineConfig, type UpdateContext, VERSION, type ValidationError, type ValidationResult, type ValueInsights, type ValueRef, type ValueRule, type WaterfallSpec, type WiredView, type XKind, type XModel, type YModel, aggregateValues, analyzeChart, animate, applyA11y, applyAggregate, applyBin, applyCalculate, applyFilter, applyFold, applyPatch, applyPick, applyTimeUnit, applyTransform, applyTransforms, arc, area, assertValidSpec, autoInsightAnnotations, backOut, bandScale, bounceOut, buildCartesianInteraction, buildCartesianModel, buildComboModel, buildDataTableFallback, buildFacetModels, buildHistogramModel, buildRenderReport, cartesianInteractionBuilders, cartesianRenderers, categorical, categoricalSchemes, chartTitleText, chartTypeLabel, checkExpression, clamp01, clamp255, compileExpression, compilePredicate, computeBackingSize, computeBins, computeFrame, computeSeriesInsights, contrastRatio, createDiv, createInspector, createRoughPen, createSelectionStore, cubicIn, cubicInOut, cubicOut, curveCatmullRom, curveLinear, curveMonotoneX, curveStep, curveStepAfter, curveStepBefore, customRenderers, darkTheme, decimate, defaultSpan, dependentParams, diverging, divergingColorScale, divergingSchemes, drawAnnotationLabels, drawAnnotations, drawAxesUnderlay, drawFacet, drawLegend, drawOverlay, drawTitle, drawTrendlineLabels, drawTrendlines, easings, elasticOut, ellipsize, ensureSketchFont, expoInOut, expoOut, facetReport, fillParentStyle, filterRows, fontString, formatCountUp, formatDate, formatNumber, formatValue, getDevicePixelRatio, groupBy, hashString, inferFieldType, inferFieldTypes, inferValueType, inheritInto, interpolateArray, interpolateNumber, interpolateNumberArray, interpolateObject, interpolateOklab, interpolateRgb, isBrowser, isEmptyValue, isFaceted, isParamClause, isSlicerType, keyFields, legendSwatchWidth, lightTheme, line, linear, linearRegression, linearScale, linearToSrgb, lintSpec, literalToValue, logScale, lttbRun, makeMatcher, matchesValue, measureText, monotoneXTangents, mulberry32, niceDomain, oklabToOklch, oklabToRgb, oklchToOklab, ordinalColorScale, overlayTextToCanvasCmd, paintCanvasText, paintLegendSwatch, parseColor, parseNumberFormat, pivot, placeViews, pointScale, polygonHachureLines, prefersReducedMotion, prettyDate, profileColumns, quadIn, quadInOut, quadOut, rampFromStops, readableTextColor, recommendChart, relativeLuminance, render, renderDashboard, renderToContext, repairReport, repairSpec, resolveCurve, resolveDashboardLayout, resolveDashboardSections, resolveEmphasis, resolveEntrance, resolveFilterValues, resolveInsightOptions, resolveSketch, resolveTheme, resolveUpdate, resolveValueRef, rgbToOklab, rgbaToCss, rotatePoint, roundedRect, sampleArc, sequential, sequentialColorScale, sequentialSchemes, serializeSpec, setMeasureContext, setStyle, sinInOut, slicerParamName, smartDate, specFields, srgbToLinear, stripData, summarize, summarizeChart, themes, tickIncrement, tickStep, ticks, timeScale, timeTickFormat, timeTicks, toHex, toPointer, tooltipEnabled, truncateTo, validateDashboard, validateSpec, wireViews, withAlpha, withSketchFont };
|
package/dist/index.js
CHANGED
|
@@ -1291,6 +1291,20 @@ var RoughPen = class {
|
|
|
1291
1291
|
resolve(opts) {
|
|
1292
1292
|
return { ...this.base, ...opts };
|
|
1293
1293
|
}
|
|
1294
|
+
/**
|
|
1295
|
+
* Run `draw` with `factor` folded into the *ambient* `globalAlpha`, then restore
|
|
1296
|
+
* it. Callers honoring a cross-highlight set `ctx.globalAlpha` below 1 to dim a
|
|
1297
|
+
* non-selected mark; composing (rather than overwriting and resetting to 1) keeps
|
|
1298
|
+
* that dim while still applying the pen's own fill/stroke translucency, so sketch
|
|
1299
|
+
* marks dim during a highlight exactly like their solid-rendered counterparts.
|
|
1300
|
+
*/
|
|
1301
|
+
withAlpha(factor, draw) {
|
|
1302
|
+
const ctx = this.ctx;
|
|
1303
|
+
const prev = ctx.globalAlpha;
|
|
1304
|
+
ctx.globalAlpha = prev * factor;
|
|
1305
|
+
draw();
|
|
1306
|
+
ctx.globalAlpha = prev;
|
|
1307
|
+
}
|
|
1294
1308
|
/** A symmetric random offset in [-x, x], scaled by a length-based gain. */
|
|
1295
1309
|
off(x, gain) {
|
|
1296
1310
|
return gain * (this.rng() * 2 * x - x);
|
|
@@ -1375,9 +1389,7 @@ var RoughPen = class {
|
|
|
1375
1389
|
ctx.lineCap = "round";
|
|
1376
1390
|
ctx.lineJoin = "round";
|
|
1377
1391
|
ctx.strokeStyle = m.stroke ?? "#000";
|
|
1378
|
-
|
|
1379
|
-
ctx.stroke();
|
|
1380
|
-
ctx.globalAlpha = 1;
|
|
1392
|
+
this.withAlpha(m.strokeAlpha ?? 1, () => ctx.stroke());
|
|
1381
1393
|
}
|
|
1382
1394
|
/** Fill a closed polygon with hachure / cross-hatch / solid. */
|
|
1383
1395
|
fillPolygon(points, m) {
|
|
@@ -1388,9 +1400,7 @@ var RoughPen = class {
|
|
|
1388
1400
|
this.tracePolyline(points, { ...m, roughness: m.roughness * 0.6 }, true);
|
|
1389
1401
|
ctx.closePath();
|
|
1390
1402
|
ctx.fillStyle = m.fill;
|
|
1391
|
-
|
|
1392
|
-
ctx.fill();
|
|
1393
|
-
ctx.globalAlpha = 1;
|
|
1403
|
+
this.withAlpha(m.fillAlpha ?? 1, () => ctx.fill());
|
|
1394
1404
|
return;
|
|
1395
1405
|
}
|
|
1396
1406
|
const gap = m.hachureGap > 0 ? m.hachureGap : Math.max(3, m.strokeWidth * 3.2);
|
|
@@ -1406,9 +1416,7 @@ var RoughPen = class {
|
|
|
1406
1416
|
ctx.lineWidth = weight;
|
|
1407
1417
|
ctx.lineCap = "round";
|
|
1408
1418
|
ctx.strokeStyle = m.fill;
|
|
1409
|
-
|
|
1410
|
-
ctx.stroke();
|
|
1411
|
-
ctx.globalAlpha = 1;
|
|
1419
|
+
this.withAlpha(m.fillAlpha ?? 0.85, () => ctx.stroke());
|
|
1412
1420
|
}
|
|
1413
1421
|
/** Hand-drawn open polyline (axis rules, box-plot whiskers, short features). */
|
|
1414
1422
|
polyline(points, opts = {}) {
|
|
@@ -1482,9 +1490,7 @@ var RoughPen = class {
|
|
|
1482
1490
|
ctx.beginPath();
|
|
1483
1491
|
this.traceSmoothClosed(pts);
|
|
1484
1492
|
ctx.fillStyle = m.fill;
|
|
1485
|
-
|
|
1486
|
-
ctx.fill();
|
|
1487
|
-
ctx.globalAlpha = 1;
|
|
1493
|
+
this.withAlpha(m.fillAlpha ?? 1, () => ctx.fill());
|
|
1488
1494
|
}
|
|
1489
1495
|
if (m.stroke) {
|
|
1490
1496
|
ctx.beginPath();
|
|
@@ -2300,6 +2306,19 @@ function formatValue(value, hint) {
|
|
|
2300
2306
|
}
|
|
2301
2307
|
return String(value);
|
|
2302
2308
|
}
|
|
2309
|
+
function decimalPlaces2(n) {
|
|
2310
|
+
if (!Number.isFinite(n) || Number.isInteger(n)) return 0;
|
|
2311
|
+
const s = Math.abs(n).toString();
|
|
2312
|
+
if (s.indexOf("e") !== -1 || s.indexOf("E") !== -1) return 6;
|
|
2313
|
+
const dot = s.indexOf(".");
|
|
2314
|
+
return dot === -1 ? 0 : s.length - dot - 1;
|
|
2315
|
+
}
|
|
2316
|
+
function formatCountUp(displayValue, finalValue, hint) {
|
|
2317
|
+
if (hint) return formatValue(displayValue, hint);
|
|
2318
|
+
const dp = decimalPlaces2(finalValue);
|
|
2319
|
+
const q = dp === 0 ? Math.round(displayValue) : Number(displayValue.toFixed(dp));
|
|
2320
|
+
return formatValue(q, hint);
|
|
2321
|
+
}
|
|
2303
2322
|
|
|
2304
2323
|
// src/pivot/pivot.ts
|
|
2305
2324
|
var GRAND_TOTAL_LABEL = "Grand Total";
|
|
@@ -9611,7 +9630,7 @@ function drawKpi(surface, spec, tokens, size, context) {
|
|
|
9611
9630
|
const displayValue = value != null && progress != null && progress < 1 ? from + (value - from) * progress : value;
|
|
9612
9631
|
const displaySparkValues = morphSparkline(sparkValues, context?.sparklineFrom, progress);
|
|
9613
9632
|
const valueText = value == null ? "\u2014" : formatValue(value, kpi.format);
|
|
9614
|
-
const displayText = displayValue == null ? "\u2014" :
|
|
9633
|
+
const displayText = displayValue == null ? "\u2014" : formatCountUp(displayValue, value, kpi.format);
|
|
9615
9634
|
const fromText = context?.valueFrom != null && value != null ? formatValue(context.valueFrom, kpi.format) : valueText;
|
|
9616
9635
|
const sizingText = fromText.length > valueText.length ? fromText : valueText;
|
|
9617
9636
|
const pad3 = framed ? 0 : tokens.spacing.lg;
|
|
@@ -14627,7 +14646,7 @@ function drawGauge(surface, spec, tokens, size, context) {
|
|
|
14627
14646
|
const sweepT = context?.sweepProgress ?? 1;
|
|
14628
14647
|
const from = context?.valueFrom ?? min;
|
|
14629
14648
|
const displayValue = from + (value - from) * sweepT;
|
|
14630
|
-
const shownText =
|
|
14649
|
+
const shownText = formatCountUp(displayValue, value, gauge.format);
|
|
14631
14650
|
const valueAngle = toAngle(displayValue);
|
|
14632
14651
|
strokePoints(ctx, pen, arcPoints(cx, cy, radius, Math.PI, 0), track, trackWidth);
|
|
14633
14652
|
if (valueAngle < Math.PI) {
|
|
@@ -17508,7 +17527,16 @@ var CANVAS_MARK_TYPES = /* @__PURE__ */ new Set([
|
|
|
17508
17527
|
"pie",
|
|
17509
17528
|
"heatmap",
|
|
17510
17529
|
"sankey",
|
|
17511
|
-
"choropleth"
|
|
17530
|
+
"choropleth",
|
|
17531
|
+
"combo",
|
|
17532
|
+
"histogram",
|
|
17533
|
+
"funnel",
|
|
17534
|
+
"treemap",
|
|
17535
|
+
"waterfall",
|
|
17536
|
+
"calendarHeatmap",
|
|
17537
|
+
"slope",
|
|
17538
|
+
"dumbbell",
|
|
17539
|
+
"bullet"
|
|
17512
17540
|
]);
|
|
17513
17541
|
var COUNT_UP_TYPES = /* @__PURE__ */ new Set(["kpi"]);
|
|
17514
17542
|
var SWEEP_TYPES = /* @__PURE__ */ new Set(["pie", "gauge"]);
|
|
@@ -19025,6 +19053,6 @@ function renderToContext(target, spec) {
|
|
|
19025
19053
|
// src/index.ts
|
|
19026
19054
|
var VERSION = "0.1.0";
|
|
19027
19055
|
|
|
19028
|
-
export { CARTESIAN_TYPES, CHART_TYPES, CanvasLayer, DEFAULT_ENTRANCE_DURATION, DEFAULT_ROUGH_STYLE, DEFAULT_UPDATE_DURATION, DIM_ALPHA, ExpressionError, FACETABLE_TYPES2 as FACETABLE_TYPES, FUNCTION_NAMES, InteractionController, NO_PADDING, RoughPen, SKETCH_FONT_FAMILY, SKETCH_FONT_NAME, SLICER_TYPES, SPEC_ATTR, SR_ONLY_STYLE, Surface, TICK_SIZE, TIME_UNITS, TRANSFORM_KINDS, TYPE_ATTR, Tooltip, VERSION, aggregateValues, analyzeChart, animate, applyA11y, applyAggregate, applyBin, applyCalculate, applyFilter, applyFold, applyPatch, applyPick, applyTimeUnit, applyTransform, applyTransforms, arc, area, assertValidSpec, autoInsightAnnotations, backOut, bandScale, bounceOut, buildCartesianInteraction, buildCartesianModel, buildComboModel, buildDataTableFallback, buildFacetModels, buildHistogramModel, buildRenderReport, cartesianInteractionBuilders, cartesianRenderers, categorical, categoricalSchemes, chartTitleText, chartTypeLabel, checkExpression, clamp012 as clamp01, clamp255, compileExpression, compilePredicate, computeBackingSize, computeBins, computeFrame, computeSeriesInsights, contrastRatio, createDiv, createInspector, createRoughPen, createSelectionStore, cubicIn, cubicInOut, cubicOut, curveCatmullRom, curveLinear, curveMonotoneX, curveStep, curveStepAfter, curveStepBefore, customRenderers, darkTheme, decimate, defaultSpan, dependentParams, diverging, divergingColorScale, divergingSchemes, drawAnnotationLabels, drawAnnotations, drawAxesUnderlay, drawFacet, drawLegend, drawOverlay, drawTitle, drawTrendlineLabels, drawTrendlines, easings, elasticOut, ellipsize, ensureSketchFont, expoInOut, expoOut, facetReport, fillParentStyle, filterRows, fontString, formatDate, formatNumber2 as formatNumber, formatValue, getDevicePixelRatio, groupBy, hashString, inferFieldType, inferFieldTypes, inferValueType, inheritInto, interpolateArray, interpolateNumber, interpolateNumberArray, interpolateObject, interpolateOklab, interpolateRgb, isBrowser, isEmptyValue, isFaceted, isParamClause, isSlicerType, keyFields, legendSwatchWidth, lightTheme, line, linear, linearRegression, linearScale, linearToSrgb, lintSpec, literalToValue, logScale, lttbRun, makeMatcher, matchesValue, measureText, monotoneXTangents, mulberry32, niceDomain, oklabToOklch, oklabToRgb, oklchToOklab, ordinalColorScale, overlayTextToCanvasCmd, paintCanvasText, paintLegendSwatch, parseColor, parseNumberFormat, pivot, placeViews, pointScale, polygonHachureLines, prefersReducedMotion, prettyDate, profileColumns, quadIn, quadInOut, quadOut, rampFromStops, readableTextColor, recommendChart, relativeLuminance, render, renderDashboard, renderToContext, repairReport, repairSpec, resolveCurve, resolveDashboardLayout, resolveDashboardSections, resolveEmphasis, resolveEntrance, resolveFilterValues, resolveInsightOptions, resolveSketch, resolveTheme, resolveUpdate, resolveValueRef, rgbToOklab, rgbaToCss, rotatePoint, roundedRect, sampleArc, sequential, sequentialColorScale, sequentialSchemes, serializeSpec, setMeasureContext, setStyle, sinInOut, slicerParamName, smartDate, specFields, srgbToLinear, stripData, summarize, summarizeChart, themes, tickIncrement, tickStep, ticks, timeScale, timeTickFormat, timeTicks, toHex, toPointer, tooltipEnabled, truncateTo, validateDashboard, validateSpec, wireViews, withAlpha, withSketchFont };
|
|
19056
|
+
export { CARTESIAN_TYPES, CHART_TYPES, CanvasLayer, DEFAULT_ENTRANCE_DURATION, DEFAULT_ROUGH_STYLE, DEFAULT_UPDATE_DURATION, DIM_ALPHA, ExpressionError, FACETABLE_TYPES2 as FACETABLE_TYPES, FUNCTION_NAMES, InteractionController, NO_PADDING, RoughPen, SKETCH_FONT_FAMILY, SKETCH_FONT_NAME, SLICER_TYPES, SPEC_ATTR, SR_ONLY_STYLE, Surface, TICK_SIZE, TIME_UNITS, TRANSFORM_KINDS, TYPE_ATTR, Tooltip, VERSION, aggregateValues, analyzeChart, animate, applyA11y, applyAggregate, applyBin, applyCalculate, applyFilter, applyFold, applyPatch, applyPick, applyTimeUnit, applyTransform, applyTransforms, arc, area, assertValidSpec, autoInsightAnnotations, backOut, bandScale, bounceOut, buildCartesianInteraction, buildCartesianModel, buildComboModel, buildDataTableFallback, buildFacetModels, buildHistogramModel, buildRenderReport, cartesianInteractionBuilders, cartesianRenderers, categorical, categoricalSchemes, chartTitleText, chartTypeLabel, checkExpression, clamp012 as clamp01, clamp255, compileExpression, compilePredicate, computeBackingSize, computeBins, computeFrame, computeSeriesInsights, contrastRatio, createDiv, createInspector, createRoughPen, createSelectionStore, cubicIn, cubicInOut, cubicOut, curveCatmullRom, curveLinear, curveMonotoneX, curveStep, curveStepAfter, curveStepBefore, customRenderers, darkTheme, decimate, defaultSpan, dependentParams, diverging, divergingColorScale, divergingSchemes, drawAnnotationLabels, drawAnnotations, drawAxesUnderlay, drawFacet, drawLegend, drawOverlay, drawTitle, drawTrendlineLabels, drawTrendlines, easings, elasticOut, ellipsize, ensureSketchFont, expoInOut, expoOut, facetReport, fillParentStyle, filterRows, fontString, formatCountUp, formatDate, formatNumber2 as formatNumber, formatValue, getDevicePixelRatio, groupBy, hashString, inferFieldType, inferFieldTypes, inferValueType, inheritInto, interpolateArray, interpolateNumber, interpolateNumberArray, interpolateObject, interpolateOklab, interpolateRgb, isBrowser, isEmptyValue, isFaceted, isParamClause, isSlicerType, keyFields, legendSwatchWidth, lightTheme, line, linear, linearRegression, linearScale, linearToSrgb, lintSpec, literalToValue, logScale, lttbRun, makeMatcher, matchesValue, measureText, monotoneXTangents, mulberry32, niceDomain, oklabToOklch, oklabToRgb, oklchToOklab, ordinalColorScale, overlayTextToCanvasCmd, paintCanvasText, paintLegendSwatch, parseColor, parseNumberFormat, pivot, placeViews, pointScale, polygonHachureLines, prefersReducedMotion, prettyDate, profileColumns, quadIn, quadInOut, quadOut, rampFromStops, readableTextColor, recommendChart, relativeLuminance, render, renderDashboard, renderToContext, repairReport, repairSpec, resolveCurve, resolveDashboardLayout, resolveDashboardSections, resolveEmphasis, resolveEntrance, resolveFilterValues, resolveInsightOptions, resolveSketch, resolveTheme, resolveUpdate, resolveValueRef, rgbToOklab, rgbaToCss, rotatePoint, roundedRect, sampleArc, sequential, sequentialColorScale, sequentialSchemes, serializeSpec, setMeasureContext, setStyle, sinInOut, slicerParamName, smartDate, specFields, srgbToLinear, stripData, summarize, summarizeChart, themes, tickIncrement, tickStep, ticks, timeScale, timeTickFormat, timeTicks, toHex, toPointer, tooltipEnabled, truncateTo, validateDashboard, validateSpec, wireViews, withAlpha, withSketchFont };
|
|
19029
19057
|
//# sourceMappingURL=index.js.map
|
|
19030
19058
|
//# sourceMappingURL=index.js.map
|