@cascivo/charts 0.5.0 → 0.6.0

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +42 -3
  2. package/dist/index.js +1263 -1241
  3. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -887,6 +887,19 @@ declare const PLAIN_MARGINS: {
887
887
  readonly bottom: 2;
888
888
  readonly left: 2;
889
889
  };
890
+ /**
891
+ * Left margin sized to the widest left-axis label so wide ticks (e.g. `40,000`)
892
+ * aren't clipped past the SVG's `0` origin. The default 36px only fits ~4 glyphs;
893
+ * a 6-glyph thousands label needs ~45px. `plain` charts keep their tiny margin.
894
+ */
895
+ declare function leftMarginForLabels(leftAxisLabels: readonly string[], plain: boolean | undefined): number;
896
+ /**
897
+ * Stride for a crowded categorical (band) axis: render every Nth label so they stop
898
+ * colliding (e.g. 14 `Jul 1`…`Jul 14` dates in a narrow chart). Returns `undefined`
899
+ * when every label fits — callers pass that straight to `Axis.labelEvery` (all shown).
900
+ * An explicit `xLabelEvery` from the caller always overrides this.
901
+ */
902
+ declare function autoLabelStride(labels: readonly string[], axisLength: number): number | undefined;
890
903
  /**
891
904
  * Pure index-window math shared by the DataZoom slider and the in-plot wheel/drag
892
905
  * zoom-pan. A "window" is an inclusive `[startIndex, endIndex]` over a series of
@@ -1500,19 +1513,32 @@ declare function ScatterChart({
1500
1513
  visualMap,
1501
1514
  toolbox
1502
1515
  }: ScatterChartProps): import("react").JSX.Element;
1503
- interface SparklineProps {
1516
+ interface SparklineBaseProps {
1504
1517
  data: readonly number[];
1505
1518
  width?: number;
1506
1519
  height?: number;
1507
- label: string;
1508
1520
  color?: string;
1509
1521
  endDot?: boolean;
1510
1522
  }
1523
+ /**
1524
+ * Exactly one of `label` / `ariaLabel` is required — a chart with no accessible name is a
1525
+ * bug, so this stays enforced by the type. `ariaLabel` is the catalog's convention for an
1526
+ * invisible accessible name (here, the SVG `<title>`); `Sparkline` predates it and shipped
1527
+ * `label`, so both work and neither is deprecated.
1528
+ */
1529
+ type SparklineProps = SparklineBaseProps & ({
1530
+ label: string;
1531
+ ariaLabel?: never;
1532
+ } | {
1533
+ ariaLabel: string;
1534
+ label?: never;
1535
+ });
1511
1536
  declare function Sparkline({
1512
1537
  data,
1513
1538
  width,
1514
1539
  height,
1515
1540
  label,
1541
+ ariaLabel,
1516
1542
  color,
1517
1543
  endDot
1518
1544
  }: SparklineProps): import("react").JSX.Element;
@@ -1543,7 +1569,19 @@ declare function Meter({
1543
1569
  interface KpiProps {
1544
1570
  value: string | number;
1545
1571
  label: string;
1572
+ /**
1573
+ * The change to show beside the value, as a **number** — `Kpi` owns the formatting
1574
+ * (sign, arrow, colour, unit). Its sibling `Stat` takes a pre-formatted `string` and
1575
+ * leaves formatting to you; that is the whole difference between the two tiles.
1576
+ */
1546
1577
  delta?: number;
1578
+ /**
1579
+ * How to render `delta`. `'number'` (default) is locale-formatted with a sign.
1580
+ * `'percent'` treats `delta` as already being in percentage points and appends `%`
1581
+ * (`25.6` → `+25.6%`) — it does NOT multiply by 100. Pass a function for anything else;
1582
+ * it receives the raw number and owns the entire string, sign included.
1583
+ */
1584
+ deltaFormat?: 'number' | 'percent' | ((delta: number) => string);
1547
1585
  deltaLabel?: string;
1548
1586
  icon?: ReactNode;
1549
1587
  sparkline?: readonly number[];
@@ -1553,6 +1591,7 @@ declare function Kpi({
1553
1591
  value,
1554
1592
  label,
1555
1593
  delta,
1594
+ deltaFormat,
1556
1595
  deltaLabel,
1557
1596
  icon,
1558
1597
  sparkline,
@@ -2116,4 +2155,4 @@ declare function Gauge({
2116
2155
  className,
2117
2156
  plain
2118
2157
  }: GaugeProps): import("react").JSX.Element;
2119
- export { AggOp, AggregateSpec, AngleBand, Annotation, AnnotationContext, AnnotationScale, AreaChart, AreaChartProps, AreaChartSeries, AreaDecimateOptions, Axis, AxisProps, BandScale, BarChart, BarChartProps, BarChartSeries, Bin, BoundStream, BoxStats, Boxplot, BoxplotProps, BoxplotSeries, Brush, BrushProps, BubbleChart, BubbleChartProps, BubbleDatum, BubbleSeries, Bullet, BulletProps, Calendar, CalendarDatum, CalendarProps, Candlestick, CandlestickDatum, CandlestickProps, CanvasLayer, CanvasLayerProps, CanvasPaint, CanvasSize, CategoryDatum, CategoryMapping, ChartDefs, ChartDefsProps, ChartFrame, ChartFrameProps, ChartSize, ComboChart, ComboChartBar, ComboChartPoint, ComboChartProps, Curve, DEFAULT_MARGINS, DataLabel, DataLabelProps, DataZoom, DataZoomProps, DecimateMethod, DecimateOptions, DefSeries, EncodeMapping, EncodedResult, EncodedSeries, FillKind, Funnel, FunnelProps, FunnelStage, Gauge, GaugeProps, GaugeThreshold, Glyph, GlyphProps, GlyphShape, GridLines, GridLinesProps, Heatmap, HeatmapDatum, HeatmapProps, HierNode, Histogram, HistogramBin, HistogramProps, Kpi, KpiProps, LabelOptions, LaidLink, LaidNode, Legend, LegendProps, LegendSeries, LineChart, LineChartProps, LineChartSeries, LinearScale, LogScale, Meter, MeterProps, MeterThresholds, PLAIN_MARGINS, PartitionedNode, PatternKind, PieChart, PieChartDatum, PieChartProps, Point, Polar, PolarDatum, PolarProps, Pt, Radar, RadarProps, RadarSeries, RadialBar, RadialBarDatum, RadialBarProps, RampKind, Rect, RegressionResult, RegressionType, ResolvedLabelOptions, Row, Sankey, SankeyLayout, SankeyLink, SankeyNode, SankeyOptions, SankeyProps, ScatterChart, ScatterChartProps, ScatterChartSeries, ScatterDatum, Sparkline, SparklineProps, StackedRow, StackedSegment, Stream, StreamDecimate, StreamOffset, StreamProps, StreamSeries, StreamSeriesOptions, StreamSource, Sunburst, SunburstProps, SyncGroup, Text, TextProps, TimeScale, Toolbox, ToolboxOptions, ToolboxProps, Treemap, TreemapDatum, TreemapNode, TreemapProps, TreemapRect, Vec, VisualChannel, VisualMap, VisualMapOptions, VisualMapProps, VisualMode, VisualResult, ZoomConfig, _syncGroupCount, aggregate, angleBand, annotationSummary, arcPath, areaPath, bandScale, bin, binValues, bindStream, boxStats, cellPath, decimate$1 as decimate, divergingRamp, download, encode, encodeCategory, extent, fillFor, filter, getSyncGroup, glyphPath, gradientId, isZoomed, linePath, linearScale, linkPath, logScale, lttb, mapVisual, maxDepth, minmax, nearestIndex, niceTicks, panWindow, partition, patternId, pieceIndex, polarPoint, quantize, radiusScale, rampLightness, rampOf, rampStops, regression, releaseSyncGroup, renderAnnotation, renderAnnotations, resolveColor, resolveLabels, sankeyLayout, sequentialRamp, serializeSvg, sort, splitDefined, sqrtScale, squarify, stackSeries, streamExtent, streamLayout, sumValue, svgToPngBlob, timeScale, toStackedSeries, useChartSize, useStreamSeries, visualVisible, voronoiCells, voronoiFind, wrapText, zoomWindow };
2158
+ export { AggOp, AggregateSpec, AngleBand, Annotation, AnnotationContext, AnnotationScale, AreaChart, AreaChartProps, AreaChartSeries, AreaDecimateOptions, Axis, AxisProps, BandScale, BarChart, BarChartProps, BarChartSeries, Bin, BoundStream, BoxStats, Boxplot, BoxplotProps, BoxplotSeries, Brush, BrushProps, BubbleChart, BubbleChartProps, BubbleDatum, BubbleSeries, Bullet, BulletProps, Calendar, CalendarDatum, CalendarProps, Candlestick, CandlestickDatum, CandlestickProps, CanvasLayer, CanvasLayerProps, CanvasPaint, CanvasSize, CategoryDatum, CategoryMapping, ChartDefs, ChartDefsProps, ChartFrame, ChartFrameProps, ChartSize, ComboChart, ComboChartBar, ComboChartPoint, ComboChartProps, Curve, DEFAULT_MARGINS, DataLabel, DataLabelProps, DataZoom, DataZoomProps, DecimateMethod, DecimateOptions, DefSeries, EncodeMapping, EncodedResult, EncodedSeries, FillKind, Funnel, FunnelProps, FunnelStage, Gauge, GaugeProps, GaugeThreshold, Glyph, GlyphProps, GlyphShape, GridLines, GridLinesProps, Heatmap, HeatmapDatum, HeatmapProps, HierNode, Histogram, HistogramBin, HistogramProps, Kpi, KpiProps, LabelOptions, LaidLink, LaidNode, Legend, LegendProps, LegendSeries, LineChart, LineChartProps, LineChartSeries, LinearScale, LogScale, Meter, MeterProps, MeterThresholds, PLAIN_MARGINS, PartitionedNode, PatternKind, PieChart, PieChartDatum, PieChartProps, Point, Polar, PolarDatum, PolarProps, Pt, Radar, RadarProps, RadarSeries, RadialBar, RadialBarDatum, RadialBarProps, RampKind, Rect, RegressionResult, RegressionType, ResolvedLabelOptions, Row, Sankey, SankeyLayout, SankeyLink, SankeyNode, SankeyOptions, SankeyProps, ScatterChart, ScatterChartProps, ScatterChartSeries, ScatterDatum, Sparkline, SparklineProps, StackedRow, StackedSegment, Stream, StreamDecimate, StreamOffset, StreamProps, StreamSeries, StreamSeriesOptions, StreamSource, Sunburst, SunburstProps, SyncGroup, Text, TextProps, TimeScale, Toolbox, ToolboxOptions, ToolboxProps, Treemap, TreemapDatum, TreemapNode, TreemapProps, TreemapRect, Vec, VisualChannel, VisualMap, VisualMapOptions, VisualMapProps, VisualMode, VisualResult, ZoomConfig, _syncGroupCount, aggregate, angleBand, annotationSummary, arcPath, areaPath, autoLabelStride, bandScale, bin, binValues, bindStream, boxStats, cellPath, decimate$1 as decimate, divergingRamp, download, encode, encodeCategory, extent, fillFor, filter, getSyncGroup, glyphPath, gradientId, isZoomed, leftMarginForLabels, linePath, linearScale, linkPath, logScale, lttb, mapVisual, maxDepth, minmax, nearestIndex, niceTicks, panWindow, partition, patternId, pieceIndex, polarPoint, quantize, radiusScale, rampLightness, rampOf, rampStops, regression, releaseSyncGroup, renderAnnotation, renderAnnotations, resolveColor, resolveLabels, sankeyLayout, sequentialRamp, serializeSvg, sort, splitDefined, sqrtScale, squarify, stackSeries, streamExtent, streamLayout, sumValue, svgToPngBlob, timeScale, toStackedSeries, useChartSize, useStreamSeries, visualVisible, voronoiCells, voronoiFind, wrapText, zoomWindow };