@blueprint-chart/lib 0.3.0 → 0.4.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.
- package/README.md +19 -0
- package/dist/charts/value-label-fit.d.ts +11 -0
- package/dist/dsl/serializer.d.ts +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3402 -3178
- package/dist/node-backend/browser.js +7 -0
- package/dist/node-backend/errors-poq5BHAK.js +8 -0
- package/dist/node-backend/fonts/DejaVuSans-Bold.ttf +0 -0
- package/dist/node-backend/fonts/DejaVuSans.ttf +0 -0
- package/dist/node-backend/index.js +5372 -0
- package/dist/render/backends/dom-backend.d.ts +2 -0
- package/dist/render/backends/jsdom-env.d.ts +13 -0
- package/dist/render/backends/node-backend.browser.d.ts +5 -0
- package/dist/render/backends/node-backend.d.ts +2 -0
- package/dist/render/backends/rasterize.d.ts +5 -0
- package/dist/render/backends/text-shim.d.ts +12 -0
- package/dist/render/backends/types.d.ts +30 -0
- package/dist/render/errors.d.ts +12 -0
- package/dist/render/index.d.ts +3 -0
- package/dist/render/public-render.d.ts +23 -0
- package/package.json +13 -3
package/README.md
CHANGED
|
@@ -10,6 +10,25 @@ npm install @blueprint-chart/lib
|
|
|
10
10
|
|
|
11
11
|
## Quick start
|
|
12
12
|
|
|
13
|
+
### Node — write SVG and PNG to disk
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { render } from '@blueprint-chart/lib'
|
|
17
|
+
import { writeFile } from 'node:fs/promises'
|
|
18
|
+
|
|
19
|
+
const chart = await render(bpc)
|
|
20
|
+
await writeFile('chart.svg', await chart.toSvg())
|
|
21
|
+
await writeFile('chart.png', await chart.toPng({ width: 1200 }))
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Browser — mount and step scenes
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
const { mount, scene } = await render(bpc)
|
|
28
|
+
mount('#chart') // element or selector
|
|
29
|
+
scene(2) // advance to scene index 2
|
|
30
|
+
```
|
|
31
|
+
|
|
13
32
|
The simplest way to render a chart is the IIFE runtime, which auto-scans the document for embedded chart definitions and renders each one inline (inside a sandboxed iframe inserted before the script tag):
|
|
14
33
|
|
|
15
34
|
```html
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ValueLabelFitInput {
|
|
2
|
+
text: string;
|
|
3
|
+
placement: 'inside' | 'outside';
|
|
4
|
+
orientation: 'vertical' | 'horizontal';
|
|
5
|
+
/** px extent along x (vertical bar: thickness; horizontal bar: length) */
|
|
6
|
+
barWidth: number;
|
|
7
|
+
/** px extent along y (vertical bar: length; horizontal bar: thickness) */
|
|
8
|
+
barHeight: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function estimateLabelWidth(text: string): number;
|
|
11
|
+
export declare function shouldRenderValueLabel(input: ValueLabelFitInput): boolean;
|
package/dist/dsl/serializer.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -25,14 +25,15 @@ export { getCachedChart } from './charts/transition-cache';
|
|
|
25
25
|
export { getCvdFilterId, createCvdSvgFilter, simulateCvdColor, checkCvdColors } from './charts/colorblind';
|
|
26
26
|
export type { CvdType, CvdIssue } from './charts/colorblind';
|
|
27
27
|
export { parse } from './dsl/parser';
|
|
28
|
-
export { serialize, compactSerialize } from './dsl/serializer';
|
|
28
|
+
export { serialize, compactSerialize, compactSerializeDeep } from './dsl/serializer';
|
|
29
29
|
export { propertyMap, extractChartTypeOptions, dataEntriesToString, extractSceneOverrides, convertColorizes, convertHighlights, convertAreaFills, convertAnnotations, convertSeriesOverrides } from './dsl/converter';
|
|
30
30
|
export type { AnnotationNode, AnnotationVisibilityNode, PointAnnotationNode, RangeAnnotationNode, FreeAnnotationNode, AreaFillNode, ChartNode, DataNode, ColorizeNode, HighlightNode, PropertyNode, SceneNode, SeriesNode, TransformNode } from './dsl/types';
|
|
31
31
|
export { validateChart } from './dsl/validate';
|
|
32
32
|
export type { ValidationIssue, ValidationResult } from './dsl/validate';
|
|
33
33
|
export { samples } from './samples';
|
|
34
34
|
export type { ChartSample } from './samples';
|
|
35
|
-
export { renderBpc, renderChart, astToDefinition, resolveScene } from './render';
|
|
36
|
-
export type { ChartDefinition, RenderOptions, ResolvedChartState } from './render';
|
|
35
|
+
export { renderBpc, renderChart, astToDefinition, resolveScene, render } from './render';
|
|
36
|
+
export type { ChartDefinition, RenderOptions, ResolvedChartState, ChartHandle, RenderApiOptions, OutputOptions } from './render';
|
|
37
|
+
export { ChartParseError, PngBrowserUnsupportedError, MissingNodeRenderDepsError } from './render';
|
|
37
38
|
export { SceneTransition, getSceneTransition, featureJoin, snapshotLiveAttrs, BC_TRANSITION_NAME, } from './transitions';
|
|
38
39
|
export type { CommitOptions, TransitionMode, SceneTransitionState, FeatureRole, FeatureJoinConfig, AttrMap, AttrValue, } from './transitions';
|