@openmaic/renderer 0.1.17 → 0.2.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/README.md CHANGED
@@ -34,7 +34,7 @@ Required peers:
34
34
 
35
35
  Optional peers (install only if your slides use the corresponding element type):
36
36
 
37
- - `echarts >= 5` — for chart elements
37
+ - `echarts >= 5.5` — for chart elements (uses endpoint label alignment for compact charts)
38
38
  - `shiki >= 1` — for code elements
39
39
 
40
40
  ## Quickstart
@@ -104,12 +104,7 @@ function SlideCanvas(props) {
104
104
  }, children: [jsx(InlineMathPriorityContext.Provider, { value: props.mathPriority ?? 'normal', children: visibleElements.map((element) => (jsx(SlideElement, { elementInfo: element, elementIndex: elementIndexById.get(element.id) ?? 1, theme: slide.theme, renderImage: renderImage, renderVideo: renderVideo, renderText: renderText, renderShapeLabel: renderShapeLabel, renderTable: renderTable, videoInteractive: videoInteractive, onElementClick: onElementClick, idPrefix: elementIdPrefix, dragOffset: dragOffsets?.get(element.id) }, element.id))) }), highlights.map((highlight) => {
105
105
  const element = visibleElements.find((el) => el.id === highlight.elementId);
106
106
  return element ? (jsx(HighlightOverlay, { element: element, options: highlight }, highlight.elementId)) : null;
107
- })] }), jsx(SpotlightOverlay, { options: effects?.spotlight, elementIdPrefix: elementIdPrefix, measurementKey: visibleElements }), jsx("div", { style: {
108
- position: 'absolute',
109
- inset: 0,
110
- pointerEvents: 'none',
111
- padding: '5%',
112
- }, children: jsx("div", { style: { position: 'relative', width: '100%', height: '100%' }, children: jsx(AnimatePresence, { children: effects?.laser && laserGeometry && (jsx(LaserOverlay, { geometry: laserGeometry, color: effects.laser.color, duration: effects.laser.duration }, `laser-${effects.laser.elementId}`)) }) }) })] })] }));
107
+ })] }), jsx(SpotlightOverlay, { options: effects?.spotlight, elementIdPrefix: elementIdPrefix, measurementKey: visibleElements }), jsx("div", { style: { position: 'absolute', inset: 0, pointerEvents: 'none' }, children: jsx(AnimatePresence, { children: effects?.laser && laserGeometry && (jsx(LaserOverlay, { geometry: laserGeometry, color: effects.laser.color, duration: effects.laser.duration }, `laser-${effects.laser.elementId}`)) }) })] })] }));
113
108
  }
114
109
 
115
110
  export { SlideCanvas };
@@ -1 +1 @@
1
- {"version":3,"file":"SlideCanvas.js","sources":["../src/SlideCanvas.tsx"],"sourcesContent":["'use client';\n\nimport { useMemo, useRef, type CSSProperties, type ReactNode } from 'react';\nimport { AnimatePresence } from 'motion/react';\n\nimport type {\n PPTElement,\n PPTImageElement,\n PPTShapeElement,\n PPTTableElement,\n PPTTextElement,\n PPTVideoElement,\n Slide,\n SlideBackground,\n} from '@openmaic/dsl';\nimport type { SlideEffects } from './types/effects';\nimport { findElementGeometry, type PercentageGeometry } from './utils/geometry';\nimport { useSlideBackgroundStyle } from './hooks/useSlideBackgroundStyle';\nimport { useViewportSize } from './hooks/useViewportSize';\nimport { SlideElement } from './SlideElement';\nimport { HighlightOverlay } from './effects/HighlightOverlay';\nimport { SpotlightOverlay } from './effects/SpotlightOverlay';\nimport { LaserOverlay } from './effects/LaserOverlay';\nimport { useOptionalSlideContext } from './context';\nimport { SLIDE_RENDERER_STYLES } from './styles';\nimport { InlineMathPriorityContext } from './utils/inlineMath';\n\nexport interface SlideCanvasProps {\n /**\n * Single slide data (PPTist-style). May be omitted when this component is\n * rendered inside a `<SlideRendererProvider>` that supplies it.\n */\n slide?: Slide;\n /**\n * Canvas scale. When omitted, the canvas auto-fits the container using\n * `slide.viewportSize` and `slide.viewportRatio`. Set to a fixed number\n * (e.g. 1) to skip auto-fit and render at slide-native dimensions.\n */\n scale?: number;\n /** Percent of the container to use when auto-fitting the slide. */\n canvasPercentage?: number;\n /** Called with the computed fit scale when `scale` is omitted. */\n onScaleChange?: (scale: number) => void;\n /** Override `slide.background`. */\n background?: SlideBackground;\n /** Optional play-time effects, all default off. */\n effects?: SlideEffects;\n /** Replace default <img> rendering for image elements. */\n renderImage?: (\n element: PPTImageElement,\n resolvedSrc: string,\n defaultContent: ReactNode,\n ) => ReactNode;\n /** Replace default <video> rendering for video elements. */\n renderVideo?: (element: PPTVideoElement) => ReactNode;\n /** Replace the content node inside the shared text paint wrapper. */\n renderText?: (element: PPTTextElement, defaultContent: ReactNode) => ReactNode;\n /** Replace the static label node inside a Shape element. */\n renderShapeLabel?: (element: PPTShapeElement, defaultContent: ReactNode) => ReactNode;\n /** Replace the static content node inside a Table element. */\n renderTable?: (element: PPTTableElement, defaultContent: ReactNode) => ReactNode;\n /** Enable pointer interaction for video controls or custom video UI. */\n videoInteractive?: boolean;\n /**\n * Background canvases use the frame allowance left by foreground layout\n * effects, then finish in idle time at lower priority. Defaults to normal.\n */\n mathPriority?: 'normal' | 'background';\n /** Click handler invoked on any element. */\n onElementClick?: (element: PPTElement, event: React.MouseEvent) => void;\n /**\n * Prefix used for each element root DOM id. Hosts that layer DOM-measured\n * overlays on top of the canvas can keep their existing id contract.\n */\n elementIdPrefix?: string;\n /** Class on the outer container. */\n className?: string;\n /** Compositor-only offsets used by the editing surface during a move gesture. */\n dragOffsets?: ReadonlyMap<string, { x: number; y: number }>;\n /** Element ids omitted from rendering and effect targeting. */\n hiddenElementIds?: readonly string[];\n /** Inline style on the outer container. */\n style?: CSSProperties;\n /**\n * Card-style chrome on the inner slide container (drop shadow + rounded\n * corners). Defaults to `true` for on-screen previews. Snapshot pipelines\n * pass `false` so the captured PNG matches the source PPT's edges exactly\n * — html2canvas would otherwise bake the 1px shadow outline and the\n * 0.5rem corner radius into the output and the comparator reads them as\n * a thin border + rounded corners that the original PPT does not have.\n */\n chrome?: boolean;\n}\n\nexport function SlideCanvas(props: SlideCanvasProps) {\n const ctx = useOptionalSlideContext();\n const slide = props.slide ?? ctx?.slide;\n if (!slide) {\n throw new Error(\n '<SlideCanvas> requires `slide` either as a prop or via <SlideRendererProvider>.',\n );\n }\n\n const scale = props.scale ?? ctx?.scale;\n const background = props.background ?? ctx?.background;\n const effects = props.effects ?? ctx?.effects;\n const renderImage = props.renderImage ?? ctx?.renderImage;\n const renderVideo = props.renderVideo ?? ctx?.renderVideo;\n const renderText = props.renderText;\n const renderShapeLabel = props.renderShapeLabel;\n const renderTable = props.renderTable;\n const videoInteractive = props.videoInteractive ?? ctx?.videoInteractive;\n const onElementClick = props.onElementClick ?? ctx?.onElementClick;\n const elementIdPrefix = props.elementIdPrefix ?? 'slide-element-';\n const { className, dragOffsets, style } = props;\n const chrome = props.chrome ?? true;\n\n const canvasRef = useRef<HTMLDivElement>(null);\n const elements = slide.elements;\n const visibleElements = useMemo(() => {\n if (!props.hiddenElementIds?.length) return elements;\n const hidden = new Set(props.hiddenElementIds);\n return elements.filter((element) => !hidden.has(element.id));\n }, [elements, props.hiddenElementIds]);\n const elementIndexById = useMemo(\n () => new Map(elements.map((element, index) => [element.id, index + 1])),\n [elements],\n );\n\n const { viewportStyles, fitScale } = useViewportSize(canvasRef, {\n viewportSize: slide.viewportSize,\n viewportRatio: slide.viewportRatio,\n canvasPercentage: props.canvasPercentage,\n onScaleChange: scale === undefined ? props.onScaleChange : undefined,\n });\n const canvasScale = scale ?? fitScale;\n\n const resolvedBackground = background ?? slide.background;\n const { backgroundStyle } = useSlideBackgroundStyle(resolvedBackground);\n\n // Plain derivations: when this package is consumed in a React Compiler build\n // these are auto-memoized; otherwise the cost (O(elements) lookups) is trivial.\n const laserGeometry: PercentageGeometry | null = effects?.laser\n ? findElementGeometry(\n visibleElements,\n effects.laser.elementId,\n slide.viewportSize,\n slide.viewportRatio,\n )\n : null;\n\n const zoomGeometry: PercentageGeometry | null = effects?.zoom\n ? findElementGeometry(\n visibleElements,\n effects.zoom.elementId,\n slide.viewportSize,\n slide.viewportRatio,\n )\n : null;\n\n const highlights = effects?.highlights ?? (effects?.highlight ? [effects.highlight] : []);\n\n return (\n <div\n ref={canvasRef}\n className={className}\n style={{\n position: 'relative',\n width: '100%',\n height: '100%',\n overflow: 'hidden',\n userSelect: 'none',\n ...style,\n }}\n >\n <style dangerouslySetInnerHTML={{ __html: SLIDE_RENDERER_STYLES }} />\n <div\n style={{\n position: 'absolute',\n ...(chrome\n ? {\n boxShadow: '0 0 0 1px rgba(0, 0, 0, 0.01), 0 0 12px 0 rgba(0, 0, 0, 0.1)',\n borderRadius: '0.5rem',\n }\n : {}),\n overflow: 'hidden',\n transitionProperty: 'transform',\n transitionDuration: '700ms',\n width: `${viewportStyles.width * canvasScale}px`,\n height: `${viewportStyles.height * canvasScale}px`,\n left: `${viewportStyles.left}px`,\n top: `${viewportStyles.top}px`,\n ...(effects?.zoom && zoomGeometry\n ? {\n transform: `scale(${effects.zoom.scale})`,\n transformOrigin: `${zoomGeometry.centerX}% ${zoomGeometry.centerY}%`,\n }\n : {}),\n }}\n >\n <div\n style={{\n width: '100%',\n height: '100%',\n backgroundPosition: 'center',\n ...(chrome ? { borderRadius: '0.5rem' } : {}),\n ...backgroundStyle,\n }}\n />\n\n <div\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n transformOrigin: 'top left',\n width: `${viewportStyles.width}px`,\n height: `${viewportStyles.height}px`,\n transform: `scale(${canvasScale})`,\n }}\n >\n <InlineMathPriorityContext.Provider value={props.mathPriority ?? 'normal'}>\n {visibleElements.map((element) => (\n <SlideElement\n key={element.id}\n elementInfo={element}\n elementIndex={elementIndexById.get(element.id) ?? 1}\n theme={slide.theme}\n renderImage={renderImage}\n renderVideo={renderVideo}\n renderText={renderText}\n renderShapeLabel={renderShapeLabel}\n renderTable={renderTable}\n videoInteractive={videoInteractive}\n onElementClick={onElementClick}\n idPrefix={elementIdPrefix}\n dragOffset={dragOffsets?.get(element.id)}\n />\n ))}\n </InlineMathPriorityContext.Provider>\n\n {highlights.map((highlight) => {\n const element = visibleElements.find((el) => el.id === highlight.elementId);\n return element ? (\n <HighlightOverlay key={highlight.elementId} element={element} options={highlight} />\n ) : null;\n })}\n </div>\n\n <SpotlightOverlay\n options={effects?.spotlight}\n elementIdPrefix={elementIdPrefix}\n measurementKey={visibleElements}\n />\n\n <div\n style={{\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n padding: '5%',\n }}\n >\n <div style={{ position: 'relative', width: '100%', height: '100%' }}>\n <AnimatePresence>\n {effects?.laser && laserGeometry && (\n <LaserOverlay\n key={`laser-${effects.laser.elementId}`}\n geometry={laserGeometry}\n color={effects.laser.color}\n duration={effects.laser.duration}\n />\n )}\n </AnimatePresence>\n </div>\n </div>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA8FM;AACJ;;;AAGE;;;;;;;AAUF;AACA;AACA;;;AAGA;;AAEA;AAEA;AACA;AACA;AACE;AAAqC;;AAErC;;AAEF;;;;;AASE;AACD;AACD;AAEA;;;;AAKA;AACE;;AAQF;AACE;;;;AAeI;AACA;AACA;AACA;AACA;AACA;AACD;AAKG;AACA;AACE;AACI;AACA;AACD;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE;AACI;;AAED;;;AAMH;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;;AAyBA;;;AAeA;AACA;AACA;AACA;AACD;AAkBX;;"}
1
+ {"version":3,"file":"SlideCanvas.js","sources":["../src/SlideCanvas.tsx"],"sourcesContent":["'use client';\n\nimport { useMemo, useRef, type CSSProperties, type ReactNode } from 'react';\nimport { AnimatePresence } from 'motion/react';\n\nimport type {\n PPTElement,\n PPTImageElement,\n PPTShapeElement,\n PPTTableElement,\n PPTTextElement,\n PPTVideoElement,\n Slide,\n SlideBackground,\n} from '@openmaic/dsl';\nimport type { SlideEffects } from './types/effects';\nimport { findElementGeometry, type PercentageGeometry } from './utils/geometry';\nimport { useSlideBackgroundStyle } from './hooks/useSlideBackgroundStyle';\nimport { useViewportSize } from './hooks/useViewportSize';\nimport { SlideElement } from './SlideElement';\nimport { HighlightOverlay } from './effects/HighlightOverlay';\nimport { SpotlightOverlay } from './effects/SpotlightOverlay';\nimport { LaserOverlay } from './effects/LaserOverlay';\nimport { useOptionalSlideContext } from './context';\nimport { SLIDE_RENDERER_STYLES } from './styles';\nimport { InlineMathPriorityContext } from './utils/inlineMath';\n\nexport interface SlideCanvasProps {\n /**\n * Single slide data (PPTist-style). May be omitted when this component is\n * rendered inside a `<SlideRendererProvider>` that supplies it.\n */\n slide?: Slide;\n /**\n * Canvas scale. When omitted, the canvas auto-fits the container using\n * `slide.viewportSize` and `slide.viewportRatio`. Set to a fixed number\n * (e.g. 1) to skip auto-fit and render at slide-native dimensions.\n */\n scale?: number;\n /** Percent of the container to use when auto-fitting the slide. */\n canvasPercentage?: number;\n /** Called with the computed fit scale when `scale` is omitted. */\n onScaleChange?: (scale: number) => void;\n /** Override `slide.background`. */\n background?: SlideBackground;\n /** Optional play-time effects, all default off. */\n effects?: SlideEffects;\n /** Replace default <img> rendering for image elements. */\n renderImage?: (\n element: PPTImageElement,\n resolvedSrc: string,\n defaultContent: ReactNode,\n ) => ReactNode;\n /** Replace default <video> rendering for video elements. */\n renderVideo?: (element: PPTVideoElement) => ReactNode;\n /** Replace the content node inside the shared text paint wrapper. */\n renderText?: (element: PPTTextElement, defaultContent: ReactNode) => ReactNode;\n /** Replace the static label node inside a Shape element. */\n renderShapeLabel?: (element: PPTShapeElement, defaultContent: ReactNode) => ReactNode;\n /** Replace the static content node inside a Table element. */\n renderTable?: (element: PPTTableElement, defaultContent: ReactNode) => ReactNode;\n /** Enable pointer interaction for video controls or custom video UI. */\n videoInteractive?: boolean;\n /**\n * Background canvases use the frame allowance left by foreground layout\n * effects, then finish in idle time at lower priority. Defaults to normal.\n */\n mathPriority?: 'normal' | 'background';\n /** Click handler invoked on any element. */\n onElementClick?: (element: PPTElement, event: React.MouseEvent) => void;\n /**\n * Prefix used for each element root DOM id. Hosts that layer DOM-measured\n * overlays on top of the canvas can keep their existing id contract.\n */\n elementIdPrefix?: string;\n /** Class on the outer container. */\n className?: string;\n /** Compositor-only offsets used by the editing surface during a move gesture. */\n dragOffsets?: ReadonlyMap<string, { x: number; y: number }>;\n /** Element ids omitted from rendering and effect targeting. */\n hiddenElementIds?: readonly string[];\n /** Inline style on the outer container. */\n style?: CSSProperties;\n /**\n * Card-style chrome on the inner slide container (drop shadow + rounded\n * corners). Defaults to `true` for on-screen previews. Snapshot pipelines\n * pass `false` so the captured PNG matches the source PPT's edges exactly\n * — html2canvas would otherwise bake the 1px shadow outline and the\n * 0.5rem corner radius into the output and the comparator reads them as\n * a thin border + rounded corners that the original PPT does not have.\n */\n chrome?: boolean;\n}\n\nexport function SlideCanvas(props: SlideCanvasProps) {\n const ctx = useOptionalSlideContext();\n const slide = props.slide ?? ctx?.slide;\n if (!slide) {\n throw new Error(\n '<SlideCanvas> requires `slide` either as a prop or via <SlideRendererProvider>.',\n );\n }\n\n const scale = props.scale ?? ctx?.scale;\n const background = props.background ?? ctx?.background;\n const effects = props.effects ?? ctx?.effects;\n const renderImage = props.renderImage ?? ctx?.renderImage;\n const renderVideo = props.renderVideo ?? ctx?.renderVideo;\n const renderText = props.renderText;\n const renderShapeLabel = props.renderShapeLabel;\n const renderTable = props.renderTable;\n const videoInteractive = props.videoInteractive ?? ctx?.videoInteractive;\n const onElementClick = props.onElementClick ?? ctx?.onElementClick;\n const elementIdPrefix = props.elementIdPrefix ?? 'slide-element-';\n const { className, dragOffsets, style } = props;\n const chrome = props.chrome ?? true;\n\n const canvasRef = useRef<HTMLDivElement>(null);\n const elements = slide.elements;\n const visibleElements = useMemo(() => {\n if (!props.hiddenElementIds?.length) return elements;\n const hidden = new Set(props.hiddenElementIds);\n return elements.filter((element) => !hidden.has(element.id));\n }, [elements, props.hiddenElementIds]);\n const elementIndexById = useMemo(\n () => new Map(elements.map((element, index) => [element.id, index + 1])),\n [elements],\n );\n\n const { viewportStyles, fitScale } = useViewportSize(canvasRef, {\n viewportSize: slide.viewportSize,\n viewportRatio: slide.viewportRatio,\n canvasPercentage: props.canvasPercentage,\n onScaleChange: scale === undefined ? props.onScaleChange : undefined,\n });\n const canvasScale = scale ?? fitScale;\n\n const resolvedBackground = background ?? slide.background;\n const { backgroundStyle } = useSlideBackgroundStyle(resolvedBackground);\n\n // Plain derivations: when this package is consumed in a React Compiler build\n // these are auto-memoized; otherwise the cost (O(elements) lookups) is trivial.\n const laserGeometry: PercentageGeometry | null = effects?.laser\n ? findElementGeometry(\n visibleElements,\n effects.laser.elementId,\n slide.viewportSize,\n slide.viewportRatio,\n )\n : null;\n\n const zoomGeometry: PercentageGeometry | null = effects?.zoom\n ? findElementGeometry(\n visibleElements,\n effects.zoom.elementId,\n slide.viewportSize,\n slide.viewportRatio,\n )\n : null;\n\n const highlights = effects?.highlights ?? (effects?.highlight ? [effects.highlight] : []);\n\n return (\n <div\n ref={canvasRef}\n className={className}\n style={{\n position: 'relative',\n width: '100%',\n height: '100%',\n overflow: 'hidden',\n userSelect: 'none',\n ...style,\n }}\n >\n <style dangerouslySetInnerHTML={{ __html: SLIDE_RENDERER_STYLES }} />\n <div\n style={{\n position: 'absolute',\n ...(chrome\n ? {\n boxShadow: '0 0 0 1px rgba(0, 0, 0, 0.01), 0 0 12px 0 rgba(0, 0, 0, 0.1)',\n borderRadius: '0.5rem',\n }\n : {}),\n overflow: 'hidden',\n transitionProperty: 'transform',\n transitionDuration: '700ms',\n width: `${viewportStyles.width * canvasScale}px`,\n height: `${viewportStyles.height * canvasScale}px`,\n left: `${viewportStyles.left}px`,\n top: `${viewportStyles.top}px`,\n ...(effects?.zoom && zoomGeometry\n ? {\n transform: `scale(${effects.zoom.scale})`,\n transformOrigin: `${zoomGeometry.centerX}% ${zoomGeometry.centerY}%`,\n }\n : {}),\n }}\n >\n <div\n style={{\n width: '100%',\n height: '100%',\n backgroundPosition: 'center',\n ...(chrome ? { borderRadius: '0.5rem' } : {}),\n ...backgroundStyle,\n }}\n />\n\n <div\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n transformOrigin: 'top left',\n width: `${viewportStyles.width}px`,\n height: `${viewportStyles.height}px`,\n transform: `scale(${canvasScale})`,\n }}\n >\n <InlineMathPriorityContext.Provider value={props.mathPriority ?? 'normal'}>\n {visibleElements.map((element) => (\n <SlideElement\n key={element.id}\n elementInfo={element}\n elementIndex={elementIndexById.get(element.id) ?? 1}\n theme={slide.theme}\n renderImage={renderImage}\n renderVideo={renderVideo}\n renderText={renderText}\n renderShapeLabel={renderShapeLabel}\n renderTable={renderTable}\n videoInteractive={videoInteractive}\n onElementClick={onElementClick}\n idPrefix={elementIdPrefix}\n dragOffset={dragOffsets?.get(element.id)}\n />\n ))}\n </InlineMathPriorityContext.Provider>\n\n {highlights.map((highlight) => {\n const element = visibleElements.find((el) => el.id === highlight.elementId);\n return element ? (\n <HighlightOverlay key={highlight.elementId} element={element} options={highlight} />\n ) : null;\n })}\n </div>\n\n <SpotlightOverlay\n options={effects?.spotlight}\n elementIdPrefix={elementIdPrefix}\n measurementKey={visibleElements}\n />\n\n {/* Laser coords are percentages of the full slide frame, like zoom. */}\n <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>\n <AnimatePresence>\n {effects?.laser && laserGeometry && (\n <LaserOverlay\n key={`laser-${effects.laser.elementId}`}\n geometry={laserGeometry}\n color={effects.laser.color}\n duration={effects.laser.duration}\n />\n )}\n </AnimatePresence>\n </div>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA8FM;AACJ;;;AAGE;;;;;;;AAUF;AACA;AACA;;;AAGA;;AAEA;AAEA;AACA;AACA;AACE;AAAqC;;AAErC;;AAEF;;;;;AASE;AACD;AACD;AAEA;;;;AAKA;AACE;;AAQF;AACE;;;;AAeI;AACA;AACA;AACA;AACA;AACA;AACD;AAKG;AACA;AACE;AACI;AACA;AACD;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE;AACI;;AAED;;;AAMH;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;;AAyBA;;AAIF;AAyBV;;"}
@@ -1,7 +1,8 @@
1
1
  import type { ComposeOption } from 'echarts/core';
2
+ import type { GridComponentOption } from 'echarts/components';
2
3
  import type { BarSeriesOption, PictorialBarSeriesOption, LineSeriesOption, PieSeriesOption, ScatterSeriesOption, RadarSeriesOption } from 'echarts/charts';
3
4
  import type { ChartData, ChartType, ImportedChartStyle } from '@openmaic/dsl';
4
- type EChartOption = ComposeOption<PictorialBarSeriesOption | BarSeriesOption | LineSeriesOption | PieSeriesOption | ScatterSeriesOption | RadarSeriesOption>;
5
+ type EChartOption = ComposeOption<PictorialBarSeriesOption | BarSeriesOption | LineSeriesOption | PieSeriesOption | ScatterSeriesOption | RadarSeriesOption | GridComponentOption>;
5
6
  export interface ChartOptionPayload {
6
7
  type: ChartType;
7
8
  data: ChartData;
@@ -24,12 +24,39 @@ const getChartOption = ({ type, data, themeColors, textColor, lineColor, lineSmo
24
24
  : {};
25
25
  const axisLine = textColor ? { lineStyle: { color: textColor } } : undefined;
26
26
  const axisLabel = { show: true, color: textColor ?? '#333333' };
27
+ // Preserve explicit imported layouts; ordinary endpoints face into the plot.
28
+ const horizontalEndpointAlignment = importedStyle?.plotArea
29
+ ? {}
30
+ : { alignMinLabel: 'left', alignMaxLabel: 'right' };
27
31
  const splitLine = lineColor ? { lineStyle: { color: lineColor } } : {};
28
32
  const categoryAxisLabel = {
29
33
  ...axisLabel,
30
34
  interval: data.labels.length <= 8 ? 0 : 'auto',
31
35
  };
32
36
  const legend = data.series.length > 1 ? { top: 'bottom', textStyle } : undefined;
37
+ const cartesianLegend = legend
38
+ ? { type: 'scroll', bottom: 0, left: '4%', right: '4%', textStyle }
39
+ : undefined;
40
+ const plot = importedStyle?.plotArea;
41
+ // Preserve an imported plot rectangle exactly; ordinary charts reflow with
42
+ // the container and keep axis labels and the legend out of the plot. Text
43
+ // headroom and a single legend row need fixed pixels, not percent heights.
44
+ const grid = plot
45
+ ? {
46
+ left: `${plot.x * 100}%`,
47
+ top: `${plot.y * 100}%`,
48
+ width: `${plot.w * 100}%`,
49
+ height: `${plot.h * 100}%`,
50
+ containLabel: false,
51
+ outerBoundsMode: 'none',
52
+ }
53
+ : {
54
+ left: '4%',
55
+ right: '4%',
56
+ top: type === 'line' || type === 'area' ? 22 : '8%',
57
+ bottom: cartesianLegend && type !== 'scatter' ? 26 : '12%',
58
+ containLabel: true,
59
+ };
33
60
  if (type === 'bar' || type === 'column') {
34
61
  const importedSeries = importedStyle?.series ?? [];
35
62
  const hasPicture = !stack && importedSeries.some((s) => Object.keys(s.pointImages ?? {}).length > 0);
@@ -45,7 +72,7 @@ const getChartOption = ({ type, data, themeColors, textColor, lineColor, lineSmo
45
72
  ...(category ? categoryAxisLabel : axisLabel),
46
73
  ...(!category && /^0(?:\.0+)?%$/.test(style?.numberFormat ?? '')
47
74
  ? {
48
- formatter: (value) => `${(value * 100).toFixed((style?.numberFormat?.split('.')[1]?.split('%')[0] ?? '').length)}%`,
75
+ formatter: (value) => `${(Number(value) * 100).toFixed((style?.numberFormat?.split('.')[1]?.split('%')[0] ?? '').length)}%`,
49
76
  }
50
77
  : {}),
51
78
  ...(style?.labelVisible !== undefined ? { show: style.labelVisible } : {}),
@@ -94,23 +121,14 @@ const getChartOption = ({ type, data, themeColors, textColor, lineColor, lineSmo
94
121
  return (Math.floor(max / unit + 1e-9) + 1) * unit;
95
122
  };
96
123
  }
97
- const plot = importedStyle?.plotArea;
98
124
  return {
99
125
  color: themeColors,
100
126
  textStyle,
101
- legend,
102
- ...(plot
103
- ? {
104
- grid: {
105
- left: `${plot.x * 100}%`,
106
- top: `${plot.y * 100}%`,
107
- width: `${plot.w * 100}%`,
108
- height: `${plot.h * 100}%`,
109
- containLabel: false,
110
- },
111
- }
112
- : {}),
113
- xAxis: type === 'bar' ? category : value,
127
+ legend: cartesianLegend,
128
+ grid,
129
+ xAxis: type === 'bar'
130
+ ? category
131
+ : { ...value, axisLabel: { ...value.axisLabel, ...horizontalEndpointAlignment } },
114
132
  yAxis: type === 'bar' ? value : category,
115
133
  series: plotSeries.map((item, index) => {
116
134
  const style = importedSeries[index];
@@ -169,8 +187,14 @@ const getChartOption = ({ type, data, themeColors, textColor, lineColor, lineSmo
169
187
  return {
170
188
  color: themeColors,
171
189
  textStyle,
172
- legend,
173
- xAxis: { type: 'category', data: data.labels, axisLine, axisLabel: categoryAxisLabel },
190
+ legend: cartesianLegend,
191
+ grid,
192
+ xAxis: {
193
+ type: 'category',
194
+ data: data.labels,
195
+ axisLine,
196
+ axisLabel: categoryAxisLabel,
197
+ },
174
198
  yAxis: { type: 'value', axisLine, axisLabel, splitLine },
175
199
  series: plotSeries.map((item, index) => {
176
200
  const seriesItem = {
@@ -234,18 +258,27 @@ const getChartOption = ({ type, data, themeColors, textColor, lineColor, lineSmo
234
258
  return {
235
259
  color: themeColors,
236
260
  textStyle,
237
- legend,
261
+ legend: cartesianLegend,
262
+ grid,
238
263
  xAxis: {
239
264
  type: 'category',
240
265
  boundaryGap: false,
241
266
  data: data.labels,
242
267
  axisLine,
243
- axisLabel: categoryAxisLabel,
268
+ axisLabel: { ...categoryAxisLabel, ...horizontalEndpointAlignment },
244
269
  },
245
270
  yAxis: { type: 'value', axisLine, axisLabel, splitLine },
246
271
  series: plotSeries.map((item, index) => {
247
272
  const seriesItem = {
248
- data: item,
273
+ // Area points sit on the plot edges; turn endpoint values inward.
274
+ data: plot
275
+ ? item
276
+ : item.map((value, dataIndex) => ({
277
+ value,
278
+ label: {
279
+ align: dataIndex === 0 ? 'left' : dataIndex === item.length - 1 ? 'right' : 'center',
280
+ },
281
+ })),
249
282
  name: data.legends[index],
250
283
  type: 'line',
251
284
  areaStyle: {},
@@ -288,7 +321,8 @@ const getChartOption = ({ type, data, themeColors, textColor, lineColor, lineSmo
288
321
  return {
289
322
  color: themeColors,
290
323
  textStyle,
291
- xAxis: { axisLine, axisLabel, splitLine },
324
+ grid,
325
+ xAxis: { axisLine, axisLabel: { ...axisLabel, ...horizontalEndpointAlignment }, splitLine },
292
326
  yAxis: { axisLine, axisLabel, splitLine },
293
327
  series: [{ symbolSize: 12, data: formatedData, type: 'scatter' }],
294
328
  };
@@ -1 +1 @@
1
- {"version":3,"file":"chartOption.js","sources":["../../../src/elements/chart/chartOption.ts"],"sourcesContent":["import type { ComposeOption } from 'echarts/core';\nimport type {\n BarSeriesOption,\n PictorialBarSeriesOption,\n LineSeriesOption,\n PieSeriesOption,\n ScatterSeriesOption,\n RadarSeriesOption,\n} from 'echarts/charts';\nimport type { ChartData, ChartType, ImportedChartStyle, ImportedChartAxis } from '@openmaic/dsl';\n\ntype EChartOption = ComposeOption<\n | PictorialBarSeriesOption\n | BarSeriesOption\n | LineSeriesOption\n | PieSeriesOption\n | ScatterSeriesOption\n | RadarSeriesOption\n>;\n\nexport interface ChartOptionPayload {\n type: ChartType;\n data: ChartData;\n themeColors: string[];\n textColor?: string;\n lineColor?: string;\n lineSmooth?: boolean;\n stack?: boolean;\n percentStack?: boolean;\n importedStyle?: ImportedChartStyle;\n}\n\n// ECharts paints pictorial symbols in a square SVG image box. A square wrapper\n// with an explicitly stretched inner image preserves Office's stretch fill.\nfunction stretchedPictureSymbol(src: string): string {\n const escaped = src.replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;');\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"400\" height=\"400\" viewBox=\"0 0 400 400\"><image href=\"${escaped}\" x=\"0\" y=\"0\" width=\"400\" height=\"400\" preserveAspectRatio=\"none\"/></svg>`;\n return `image://data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;\n}\n\nexport const getChartOption = ({\n type,\n data,\n themeColors,\n textColor,\n lineColor,\n lineSmooth,\n stack,\n percentStack,\n importedStyle,\n}: ChartOptionPayload): EChartOption | null => {\n if (!Array.isArray(data?.series) || data.series.length === 0 || !Array.isArray(data.labels)) {\n return null;\n }\n const textStyle = textColor ? { color: textColor } : {};\n const normalize = stack && percentStack && ['bar', 'column', 'line', 'area'].includes(type);\n const totals = normalize\n ? Array.from({ length: Math.max(0, ...data.series.map((values) => values.length)) }, (_, i) =>\n data.series.reduce((sum, values) => sum + Math.abs(values[i] ?? 0), 0),\n )\n : [];\n const plotSeries = normalize\n ? data.series.map((values) => values.map((value, i) => (totals[i] ? value / totals[i] : 0)))\n : data.series;\n const originalValueLabel = (seriesIndex: number) =>\n normalize\n ? {\n formatter: ({ dataIndex }: { dataIndex: number }) =>\n String(data.series[seriesIndex][dataIndex]),\n }\n : {};\n\n const axisLine = textColor ? { lineStyle: { color: textColor } } : undefined;\n const axisLabel = { show: true, color: textColor ?? '#333333' };\n const splitLine = lineColor ? { lineStyle: { color: lineColor } } : {};\n\n const categoryAxisLabel = {\n ...axisLabel,\n interval: data.labels.length <= 8 ? 0 : ('auto' as const),\n };\n\n const legend = data.series.length > 1 ? { top: 'bottom' as const, textStyle } : undefined;\n\n if (type === 'bar' || type === 'column') {\n const importedSeries = importedStyle?.series ?? [];\n const hasPicture =\n !stack && importedSeries.some((s) => Object.keys(s.pointImages ?? {}).length > 0);\n const axisOptions = (style: ImportedChartAxis | undefined, category: boolean) => ({\n ...(style?.show !== undefined ? { show: style.show } : {}),\n axisLine: style\n ? {\n show: style.lineVisible ?? true,\n lineStyle: { color: style.lineColor ?? textColor ?? '#333333' },\n }\n : axisLine,\n axisLabel: {\n ...(category ? categoryAxisLabel : axisLabel),\n ...(!category && /^0(?:\\.0+)?%$/.test(style?.numberFormat ?? '')\n ? {\n formatter: (value: number) =>\n `${(value * 100).toFixed((style?.numberFormat?.split('.')[1]?.split('%')[0] ?? '').length)}%`,\n }\n : {}),\n ...(style?.labelVisible !== undefined ? { show: style.labelVisible } : {}),\n ...(style?.labelColor ? { color: style.labelColor } : {}),\n ...(style?.labelFontSize !== undefined ? { fontSize: style.labelFontSize } : {}),\n ...(style?.labelBold !== undefined\n ? { fontWeight: style.labelBold ? ('bold' as const) : ('normal' as const) }\n : {}),\n },\n splitLine:\n style?.gridlines !== undefined\n ? { show: style.gridlines, lineStyle: { color: style.gridlineColor ?? '#e0e6f1' } }\n : category\n ? undefined\n : splitLine,\n ...(category\n ? {}\n : {\n min:\n style?.min ??\n (style?.majorUnit && style.majorUnit > 0\n ? ({ min }: { min: number }) =>\n Math.floor(Math.min(0, min) / style.majorUnit!) * style.majorUnit!\n : undefined),\n max:\n style?.max ??\n (style?.majorUnit && style.majorUnit > 0\n ? ({ max }: { max: number }) =>\n Math.ceil(Math.max(0, max) / style.majorUnit!) * style.majorUnit!\n : undefined),\n interval: style?.majorUnit,\n }),\n });\n const category = {\n type: 'category' as const,\n data: data.labels,\n ...axisOptions(importedStyle?.categoryAxis, true),\n };\n const value = { type: 'value' as const, ...axisOptions(importedStyle?.valueAxis, false) };\n // Picture-filled percent columns use an extra automatic tick above the peak,\n // matching Office's automatic range while honoring explicit scale settings.\n if (\n hasPicture &&\n value.max === undefined &&\n !importedStyle?.valueAxis?.majorUnit &&\n /^0(?:\\.0+)?%$/.test(importedStyle?.valueAxis?.numberFormat ?? '')\n ) {\n value.max = ({ max }: { max: number }) => {\n if (max <= 0) return 0;\n const magnitude = 10 ** Math.floor(Math.log10(max / 6));\n const unit = [1, 2, 5, 10].find((n) => n * magnitude >= max / 6)! * magnitude;\n return (Math.floor(max / unit + 1e-9) + 1) * unit;\n };\n }\n const plot = importedStyle?.plotArea;\n return {\n color: themeColors,\n textStyle,\n legend,\n ...(plot\n ? {\n grid: {\n left: `${plot.x * 100}%`,\n top: `${plot.y * 100}%`,\n width: `${plot.w * 100}%`,\n height: `${plot.h * 100}%`,\n containLabel: false,\n },\n }\n : {}),\n xAxis: type === 'bar' ? category : value,\n yAxis: type === 'bar' ? value : category,\n series: plotSeries.map((item, index) => {\n const style = importedSeries[index];\n // ECharts lays out bar and pictorialBar independently. Keep every\n // unstacked series in the same layout when any point uses a picture;\n // points without images retain a rectangular symbol.\n const picture = !!hasPicture;\n const seriesItem: BarSeriesOption | PictorialBarSeriesOption = {\n data:\n style || picture\n ? item.map((n, i) => ({\n value: n,\n ...(picture\n ? {\n symbol: style?.pointImages?.[String(i)]\n ? stretchedPictureSymbol(style.pointImages[String(i)])\n : 'rect',\n }\n : {}),\n itemStyle: {\n color:\n style?.pointFills?.[String(i)] ??\n style?.fill ??\n themeColors[index % themeColors.length],\n },\n }))\n : item,\n name: data.legends[index],\n type: picture ? 'pictorialBar' : 'bar',\n ...(picture\n ? {\n symbolSize: ['100%', '100%'],\n symbolRepeat: false,\n symbolClip: false,\n // Override pictorialBar's overlapping/unclipped defaults.\n barGap: '20%',\n clip: true,\n }\n : {}),\n label: { show: style?.showValue ?? true, ...originalValueLabel(index) },\n itemStyle: {\n borderRadius: importedStyle ? 0 : type === 'bar' ? [2, 2, 0, 0] : [0, 2, 2, 0],\n },\n };\n // OOXML gapWidth is the gap as a percentage of a bar's width.\n // For a single/stacked series, convert to percentage of a category band.\n if (importedStyle?.gapWidth !== undefined && (data.series.length === 1 || stack)) {\n const gap = Math.max(0, importedStyle.gapWidth);\n seriesItem.barCategoryGap = `${(gap / (100 + gap)) * 100}%`;\n }\n if (stack) seriesItem.stack = 'A';\n return seriesItem;\n }),\n };\n }\n if (type === 'line') {\n return {\n color: themeColors,\n textStyle,\n legend,\n xAxis: { type: 'category', data: data.labels, axisLine, axisLabel: categoryAxisLabel },\n yAxis: { type: 'value', axisLine, axisLabel, splitLine },\n series: plotSeries.map((item, index) => {\n const seriesItem: LineSeriesOption = {\n data: item,\n name: data.legends[index],\n type: 'line',\n smooth: lineSmooth,\n label: { show: true, ...originalValueLabel(index) },\n };\n if (stack) seriesItem.stack = 'A';\n return seriesItem;\n }),\n };\n }\n if (type === 'pie') {\n const series0 = data.series[0];\n if (!Array.isArray(series0)) return null;\n return {\n color: themeColors,\n textStyle,\n legend: { top: 'bottom' as const, textStyle },\n series: [\n {\n data: series0.map((item, index) => ({ value: item, name: data.labels[index] })),\n label: textColor ? { color: textColor } : {},\n type: 'pie',\n radius: '70%',\n emphasis: {\n itemStyle: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: 'rgba(0, 0, 0, 0.5)' },\n label: { show: true, fontSize: 14, fontWeight: 'bold' },\n },\n },\n ],\n };\n }\n if (type === 'ring') {\n const series0 = data.series[0];\n if (!Array.isArray(series0)) return null;\n return {\n color: themeColors,\n textStyle,\n legend: { top: 'bottom' as const, textStyle },\n series: [\n {\n data: series0.map((item, index) => ({ value: item, name: data.labels[index] })),\n label: textColor ? { color: textColor } : {},\n type: 'pie',\n radius: ['40%', '70%'],\n padAngle: 1,\n avoidLabelOverlap: false,\n itemStyle: { borderRadius: 4 },\n emphasis: { label: { show: true, fontSize: 14, fontWeight: 'bold' } },\n },\n ],\n };\n }\n if (type === 'area') {\n return {\n color: themeColors,\n textStyle,\n legend,\n xAxis: {\n type: 'category',\n boundaryGap: false,\n data: data.labels,\n axisLine,\n axisLabel: categoryAxisLabel,\n },\n yAxis: { type: 'value', axisLine, axisLabel, splitLine },\n series: plotSeries.map((item, index) => {\n const seriesItem: LineSeriesOption = {\n data: item,\n name: data.legends[index],\n type: 'line',\n areaStyle: {},\n label: { show: true, ...originalValueLabel(index) },\n };\n if (stack) seriesItem.stack = 'A';\n return seriesItem;\n }),\n };\n }\n if (type === 'radar') {\n return {\n color: themeColors,\n textStyle,\n legend,\n radar: {\n indicator: data.labels.map((item) => ({ name: item })),\n splitLine,\n axisLine: lineColor ? { lineStyle: { color: lineColor } } : undefined,\n },\n series: [\n {\n data: data.series.map((item, index) => ({ value: item, name: data.legends[index] })),\n type: 'radar',\n },\n ],\n };\n }\n if (type === 'scatter') {\n const series0 = data.series[0];\n if (!Array.isArray(series0)) return null;\n const formatedData: number[][] = [];\n for (let i = 0; i < series0.length; i++) {\n const x = series0[i];\n const y = data.series[1]?.[i] ?? x;\n formatedData.push([x, y]);\n }\n\n return {\n color: themeColors,\n textStyle,\n xAxis: { axisLine, axisLabel, splitLine },\n yAxis: { axisLine, axisLabel, splitLine },\n series: [{ symbolSize: 12, data: formatedData, type: 'scatter' }],\n };\n }\n\n return null;\n};\n"],"names":[],"mappings":"AAgCA;AACA;AACA,SAAS,sBAAsB,CAAC,GAAW,EAAA;IACzC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE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E;IACH;AAEA,IAAA,OAAO,IAAI;AACb;;;;"}
1
+ {"version":3,"file":"chartOption.js","sources":["../../../src/elements/chart/chartOption.ts"],"sourcesContent":["import type { ComposeOption } from 'echarts/core';\nimport type { GridComponentOption } from 'echarts/components';\nimport type {\n BarSeriesOption,\n PictorialBarSeriesOption,\n LineSeriesOption,\n PieSeriesOption,\n ScatterSeriesOption,\n RadarSeriesOption,\n} from 'echarts/charts';\nimport type { ChartData, ChartType, ImportedChartStyle, ImportedChartAxis } from '@openmaic/dsl';\n\ntype EChartOption = ComposeOption<\n | PictorialBarSeriesOption\n | BarSeriesOption\n | LineSeriesOption\n | PieSeriesOption\n | ScatterSeriesOption\n | RadarSeriesOption\n | GridComponentOption\n>;\n\nexport interface ChartOptionPayload {\n type: ChartType;\n data: ChartData;\n themeColors: string[];\n textColor?: string;\n lineColor?: string;\n lineSmooth?: boolean;\n stack?: boolean;\n percentStack?: boolean;\n importedStyle?: ImportedChartStyle;\n}\n\n// ECharts paints pictorial symbols in a square SVG image box. A square wrapper\n// with an explicitly stretched inner image preserves Office's stretch fill.\nfunction stretchedPictureSymbol(src: string): string {\n const escaped = src.replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;');\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"400\" height=\"400\" viewBox=\"0 0 400 400\"><image href=\"${escaped}\" x=\"0\" y=\"0\" width=\"400\" height=\"400\" preserveAspectRatio=\"none\"/></svg>`;\n return `image://data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;\n}\n\nexport const getChartOption = ({\n type,\n data,\n themeColors,\n textColor,\n lineColor,\n lineSmooth,\n stack,\n percentStack,\n importedStyle,\n}: ChartOptionPayload): EChartOption | null => {\n if (!Array.isArray(data?.series) || data.series.length === 0 || !Array.isArray(data.labels)) {\n return null;\n }\n const textStyle = textColor ? { color: textColor } : {};\n const normalize = stack && percentStack && ['bar', 'column', 'line', 'area'].includes(type);\n const totals = normalize\n ? Array.from({ length: Math.max(0, ...data.series.map((values) => values.length)) }, (_, i) =>\n data.series.reduce((sum, values) => sum + Math.abs(values[i] ?? 0), 0),\n )\n : [];\n const plotSeries = normalize\n ? data.series.map((values) => values.map((value, i) => (totals[i] ? value / totals[i] : 0)))\n : data.series;\n const originalValueLabel = (seriesIndex: number) =>\n normalize\n ? {\n formatter: ({ dataIndex }: { dataIndex: number }) =>\n String(data.series[seriesIndex][dataIndex]),\n }\n : {};\n\n const axisLine = textColor ? { lineStyle: { color: textColor } } : undefined;\n const axisLabel = { show: true, color: textColor ?? '#333333' };\n // Preserve explicit imported layouts; ordinary endpoints face into the plot.\n const horizontalEndpointAlignment = importedStyle?.plotArea\n ? {}\n : { alignMinLabel: 'left' as const, alignMaxLabel: 'right' as const };\n const splitLine = lineColor ? { lineStyle: { color: lineColor } } : {};\n\n const categoryAxisLabel = {\n ...axisLabel,\n interval: data.labels.length <= 8 ? 0 : ('auto' as const),\n };\n\n const legend = data.series.length > 1 ? { top: 'bottom' as const, textStyle } : undefined;\n\n const cartesianLegend = legend\n ? { type: 'scroll' as const, bottom: 0, left: '4%', right: '4%', textStyle }\n : undefined;\n const plot = importedStyle?.plotArea;\n // Preserve an imported plot rectangle exactly; ordinary charts reflow with\n // the container and keep axis labels and the legend out of the plot. Text\n // headroom and a single legend row need fixed pixels, not percent heights.\n const grid: GridComponentOption = plot\n ? {\n left: `${plot.x * 100}%`,\n top: `${plot.y * 100}%`,\n width: `${plot.w * 100}%`,\n height: `${plot.h * 100}%`,\n containLabel: false,\n outerBoundsMode: 'none',\n }\n : {\n left: '4%',\n right: '4%',\n top: type === 'line' || type === 'area' ? 22 : '8%',\n bottom: cartesianLegend && type !== 'scatter' ? 26 : '12%',\n containLabel: true,\n };\n\n if (type === 'bar' || type === 'column') {\n const importedSeries = importedStyle?.series ?? [];\n const hasPicture =\n !stack && importedSeries.some((s) => Object.keys(s.pointImages ?? {}).length > 0);\n const axisOptions = (style: ImportedChartAxis | undefined, category: boolean) => ({\n ...(style?.show !== undefined ? { show: style.show } : {}),\n axisLine: style\n ? {\n show: style.lineVisible ?? true,\n lineStyle: { color: style.lineColor ?? textColor ?? '#333333' },\n }\n : axisLine,\n axisLabel: {\n ...(category ? categoryAxisLabel : axisLabel),\n ...(!category && /^0(?:\\.0+)?%$/.test(style?.numberFormat ?? '')\n ? {\n formatter: (value: number | string) =>\n `${(Number(value) * 100).toFixed((style?.numberFormat?.split('.')[1]?.split('%')[0] ?? '').length)}%`,\n }\n : {}),\n ...(style?.labelVisible !== undefined ? { show: style.labelVisible } : {}),\n ...(style?.labelColor ? { color: style.labelColor } : {}),\n ...(style?.labelFontSize !== undefined ? { fontSize: style.labelFontSize } : {}),\n ...(style?.labelBold !== undefined\n ? { fontWeight: style.labelBold ? ('bold' as const) : ('normal' as const) }\n : {}),\n },\n splitLine:\n style?.gridlines !== undefined\n ? { show: style.gridlines, lineStyle: { color: style.gridlineColor ?? '#e0e6f1' } }\n : category\n ? undefined\n : splitLine,\n ...(category\n ? {}\n : {\n min:\n style?.min ??\n (style?.majorUnit && style.majorUnit > 0\n ? ({ min }: { min: number }) =>\n Math.floor(Math.min(0, min) / style.majorUnit!) * style.majorUnit!\n : undefined),\n max:\n style?.max ??\n (style?.majorUnit && style.majorUnit > 0\n ? ({ max }: { max: number }) =>\n Math.ceil(Math.max(0, max) / style.majorUnit!) * style.majorUnit!\n : undefined),\n interval: style?.majorUnit,\n }),\n });\n const category = {\n type: 'category' as const,\n data: data.labels,\n ...axisOptions(importedStyle?.categoryAxis, true),\n };\n const value = { type: 'value' as const, ...axisOptions(importedStyle?.valueAxis, false) };\n // Picture-filled percent columns use an extra automatic tick above the peak,\n // matching Office's automatic range while honoring explicit scale settings.\n if (\n hasPicture &&\n value.max === undefined &&\n !importedStyle?.valueAxis?.majorUnit &&\n /^0(?:\\.0+)?%$/.test(importedStyle?.valueAxis?.numberFormat ?? '')\n ) {\n value.max = ({ max }: { max: number }) => {\n if (max <= 0) return 0;\n const magnitude = 10 ** Math.floor(Math.log10(max / 6));\n const unit = [1, 2, 5, 10].find((n) => n * magnitude >= max / 6)! * magnitude;\n return (Math.floor(max / unit + 1e-9) + 1) * unit;\n };\n }\n return {\n color: themeColors,\n textStyle,\n legend: cartesianLegend,\n grid,\n xAxis:\n type === 'bar'\n ? category\n : { ...value, axisLabel: { ...value.axisLabel, ...horizontalEndpointAlignment } },\n yAxis: type === 'bar' ? value : category,\n series: plotSeries.map((item, index) => {\n const style = importedSeries[index];\n // ECharts lays out bar and pictorialBar independently. Keep every\n // unstacked series in the same layout when any point uses a picture;\n // points without images retain a rectangular symbol.\n const picture = !!hasPicture;\n const seriesItem: BarSeriesOption | PictorialBarSeriesOption = {\n data:\n style || picture\n ? item.map((n, i) => ({\n value: n,\n ...(picture\n ? {\n symbol: style?.pointImages?.[String(i)]\n ? stretchedPictureSymbol(style.pointImages[String(i)])\n : 'rect',\n }\n : {}),\n itemStyle: {\n color:\n style?.pointFills?.[String(i)] ??\n style?.fill ??\n themeColors[index % themeColors.length],\n },\n }))\n : item,\n name: data.legends[index],\n type: picture ? 'pictorialBar' : 'bar',\n ...(picture\n ? {\n symbolSize: ['100%', '100%'],\n symbolRepeat: false,\n symbolClip: false,\n // Override pictorialBar's overlapping/unclipped defaults.\n barGap: '20%',\n clip: true,\n }\n : {}),\n label: { show: style?.showValue ?? true, ...originalValueLabel(index) },\n itemStyle: {\n borderRadius: importedStyle ? 0 : type === 'bar' ? [2, 2, 0, 0] : [0, 2, 2, 0],\n },\n };\n // OOXML gapWidth is the gap as a percentage of a bar's width.\n // For a single/stacked series, convert to percentage of a category band.\n if (importedStyle?.gapWidth !== undefined && (data.series.length === 1 || stack)) {\n const gap = Math.max(0, importedStyle.gapWidth);\n seriesItem.barCategoryGap = `${(gap / (100 + gap)) * 100}%`;\n }\n if (stack) seriesItem.stack = 'A';\n return seriesItem;\n }),\n };\n }\n if (type === 'line') {\n return {\n color: themeColors,\n textStyle,\n legend: cartesianLegend,\n grid,\n xAxis: {\n type: 'category',\n data: data.labels,\n axisLine,\n axisLabel: categoryAxisLabel,\n },\n yAxis: { type: 'value', axisLine, axisLabel, splitLine },\n series: plotSeries.map((item, index) => {\n const seriesItem: LineSeriesOption = {\n data: item,\n name: data.legends[index],\n type: 'line',\n smooth: lineSmooth,\n label: { show: true, ...originalValueLabel(index) },\n };\n if (stack) seriesItem.stack = 'A';\n return seriesItem;\n }),\n };\n }\n if (type === 'pie') {\n const series0 = data.series[0];\n if (!Array.isArray(series0)) return null;\n return {\n color: themeColors,\n textStyle,\n legend: { top: 'bottom' as const, textStyle },\n series: [\n {\n data: series0.map((item, index) => ({ value: item, name: data.labels[index] })),\n label: textColor ? { color: textColor } : {},\n type: 'pie',\n radius: '70%',\n emphasis: {\n itemStyle: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: 'rgba(0, 0, 0, 0.5)' },\n label: { show: true, fontSize: 14, fontWeight: 'bold' },\n },\n },\n ],\n };\n }\n if (type === 'ring') {\n const series0 = data.series[0];\n if (!Array.isArray(series0)) return null;\n return {\n color: themeColors,\n textStyle,\n legend: { top: 'bottom' as const, textStyle },\n series: [\n {\n data: series0.map((item, index) => ({ value: item, name: data.labels[index] })),\n label: textColor ? { color: textColor } : {},\n type: 'pie',\n radius: ['40%', '70%'],\n padAngle: 1,\n avoidLabelOverlap: false,\n itemStyle: { borderRadius: 4 },\n emphasis: { label: { show: true, fontSize: 14, fontWeight: 'bold' } },\n },\n ],\n };\n }\n if (type === 'area') {\n return {\n color: themeColors,\n textStyle,\n legend: cartesianLegend,\n grid,\n xAxis: {\n type: 'category',\n boundaryGap: false,\n data: data.labels,\n axisLine,\n axisLabel: { ...categoryAxisLabel, ...horizontalEndpointAlignment },\n },\n yAxis: { type: 'value', axisLine, axisLabel, splitLine },\n series: plotSeries.map((item, index) => {\n const seriesItem: LineSeriesOption = {\n // Area points sit on the plot edges; turn endpoint values inward.\n data: plot\n ? item\n : item.map((value, dataIndex) => ({\n value,\n label: {\n align:\n dataIndex === 0 ? 'left' : dataIndex === item.length - 1 ? 'right' : 'center',\n },\n })),\n name: data.legends[index],\n type: 'line',\n areaStyle: {},\n label: { show: true, ...originalValueLabel(index) },\n };\n if (stack) seriesItem.stack = 'A';\n return seriesItem;\n }),\n };\n }\n if (type === 'radar') {\n return {\n color: themeColors,\n textStyle,\n legend,\n radar: {\n indicator: data.labels.map((item) => ({ name: item })),\n splitLine,\n axisLine: lineColor ? { lineStyle: { color: lineColor } } : undefined,\n },\n series: [\n {\n data: data.series.map((item, index) => ({ value: item, name: data.legends[index] })),\n type: 'radar',\n },\n ],\n };\n }\n if (type === 'scatter') {\n const series0 = data.series[0];\n if (!Array.isArray(series0)) return null;\n const formatedData: number[][] = [];\n for (let i = 0; i < series0.length; i++) {\n const x = series0[i];\n const y = data.series[1]?.[i] ?? x;\n formatedData.push([x, y]);\n }\n\n return {\n color: themeColors,\n textStyle,\n grid,\n xAxis: { axisLine, axisLabel: { ...axisLabel, ...horizontalEndpointAlignment }, splitLine },\n yAxis: { axisLine, axisLabel, splitLine },\n series: [{ symbolSize: 12, data: formatedData, type: 'scatter' }],\n };\n }\n\n return null;\n};\n"],"names":[],"mappings":"AAkCA;AACA;AACA,SAAS,sBAAsB,CAAC,GAAW,EAAA;IACzC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;AACxF,IAAA,MAAM,GAAG,GAAG,CAAA,oGAAA,EAAuG,OAAO,2EAA2E;AACrM,IAAA,OAAO,4CAA4C,kBAAkB,CAAC,GAAG,CAAC,EAAE;AAC9E;AAEO,MAAM,cAAc,GAAG,CAAC,EAC7B,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,SAAS,EACT,SAAS,EACT,UAAU,EACV,KAAK,EACL,YAAY,EACZ,aAAa,GACM,KAAyB;AAC5C,IAAA,IAAI,CAAC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I;QACxC,MAAM,YAAY,GAAe,EAAE;AACnC,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACvC,YAAA,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;AACpB,YAAA,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YAClC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3B;QAEA,OAAO;AACL,YAAA,KAAK,EAAE,WAAW;YAClB,SAAS;YACT,IAAI;AACJ,YAAA,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,GAAG,SAAS,EAAE,GAAG,2BAA2B,EAAE,EAAE,SAAS,EAAE;AAC3F,YAAA,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE;AACzC,YAAA,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;SAClE;IACH;AAEA,IAAA,OAAO,IAAI;AACb;;;;"}
@@ -12,7 +12,8 @@ function loadChartRuntime() {
12
12
  import('echarts/charts'),
13
13
  import('echarts/components'),
14
14
  import('echarts/renderers'),
15
- ]).then(([echarts, charts, components, renderers]) => {
15
+ import('echarts/features'),
16
+ ]).then(([echarts, charts, components, renderers, features]) => {
16
17
  echarts.use([
17
18
  charts.BarChart,
18
19
  charts.PictorialBarChart,
@@ -23,6 +24,9 @@ function loadChartRuntime() {
23
24
  components.LegendComponent,
24
25
  renderers.SVGRenderer,
25
26
  ]);
27
+ // ECharts 5 includes containLabel; ECharts 6 exposes it as an opt-in.
28
+ if (features.LegacyGridContainLabel)
29
+ echarts.use(features.LegacyGridContainLabel);
26
30
  return echarts;
27
31
  });
28
32
  return runtimePromise;
@@ -1 +1 @@
1
- {"version":3,"file":"chartRuntime.js","sources":["../../../src/elements/chart/chartRuntime.ts"],"sourcesContent":["import type * as echartsCore from 'echarts/core';\n\ntype EChartsRuntime = typeof echartsCore;\n\nlet runtimePromise: Promise<EChartsRuntime> | undefined;\n\n/**\n * Load and register the small ECharts surface used by chart elements.\n *\n * Keeping this behind a shared promise is important for two reasons: charts\n * remain optional for consumers that only render text/images, and multiple\n * charts on one slide do not race to register the same ECharts extensions.\n */\nexport function loadChartRuntime(): Promise<EChartsRuntime> {\n runtimePromise ??= Promise.all([\n import('echarts/core'),\n import('echarts/charts'),\n import('echarts/components'),\n import('echarts/renderers'),\n ]).then(([echarts, charts, components, renderers]) => {\n echarts.use([\n charts.BarChart,\n charts.PictorialBarChart,\n charts.LineChart,\n charts.PieChart,\n charts.ScatterChart,\n charts.RadarChart,\n components.LegendComponent,\n renderers.SVGRenderer,\n ]);\n return echarts;\n });\n\n return runtimePromise;\n}\n"],"names":[],"mappings":"AAIA,IAAI,cAAmD;AAEvD;;;;;;AAMG;SACa,gBAAgB,GAAA;AAC9B,IAAA,cAAc,KAAK,OAAO,CAAC,GAAG,CAAC;QAC7B,OAAO,cAAc,CAAC;QACtB,OAAO,gBAAgB,CAAC;QACxB,OAAO,oBAAoB,CAAC;QAC5B,OAAO,mBAAmB,CAAC;AAC5B,KAAA,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC,KAAI;QACnD,OAAO,CAAC,GAAG,CAAC;AACV,YAAA,MAAM,CAAC,QAAQ;AACf,YAAA,MAAM,CAAC,iBAAiB;AACxB,YAAA,MAAM,CAAC,SAAS;AAChB,YAAA,MAAM,CAAC,QAAQ;AACf,YAAA,MAAM,CAAC,YAAY;AACnB,YAAA,MAAM,CAAC,UAAU;AACjB,YAAA,UAAU,CAAC,eAAe;AAC1B,YAAA,SAAS,CAAC,WAAW;AACtB,SAAA,CAAC;AACF,QAAA,OAAO,OAAO;AAChB,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,cAAc;AACvB;;;;"}
1
+ {"version":3,"file":"chartRuntime.js","sources":["../../../src/elements/chart/chartRuntime.ts"],"sourcesContent":["import type * as echartsCore from 'echarts/core';\n\ntype EChartsRuntime = typeof echartsCore;\n\nlet runtimePromise: Promise<EChartsRuntime> | undefined;\n\n/**\n * Load and register the small ECharts surface used by chart elements.\n *\n * Keeping this behind a shared promise is important for two reasons: charts\n * remain optional for consumers that only render text/images, and multiple\n * charts on one slide do not race to register the same ECharts extensions.\n */\nexport function loadChartRuntime(): Promise<EChartsRuntime> {\n runtimePromise ??= Promise.all([\n import('echarts/core'),\n import('echarts/charts'),\n import('echarts/components'),\n import('echarts/renderers'),\n import('echarts/features'),\n ]).then(([echarts, charts, components, renderers, features]) => {\n echarts.use([\n charts.BarChart,\n charts.PictorialBarChart,\n charts.LineChart,\n charts.PieChart,\n charts.ScatterChart,\n charts.RadarChart,\n components.LegendComponent,\n renderers.SVGRenderer,\n ]);\n // ECharts 5 includes containLabel; ECharts 6 exposes it as an opt-in.\n if (features.LegacyGridContainLabel) echarts.use(features.LegacyGridContainLabel);\n return echarts;\n });\n\n return runtimePromise;\n}\n"],"names":[],"mappings":"AAIA,IAAI,cAAmD;AAEvD;;;;;;AAMG;SACa,gBAAgB,GAAA;AAC9B,IAAA,cAAc,KAAK,OAAO,CAAC,GAAG,CAAC;QAC7B,OAAO,cAAc,CAAC;QACtB,OAAO,gBAAgB,CAAC;QACxB,OAAO,oBAAoB,CAAC;QAC5B,OAAO,mBAAmB,CAAC;QAC3B,OAAO,kBAAkB,CAAC;AAC3B,KAAA,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,CAAC,KAAI;QAC7D,OAAO,CAAC,GAAG,CAAC;AACV,YAAA,MAAM,CAAC,QAAQ;AACf,YAAA,MAAM,CAAC,iBAAiB;AACxB,YAAA,MAAM,CAAC,SAAS;AAChB,YAAA,MAAM,CAAC,QAAQ;AACf,YAAA,MAAM,CAAC,YAAY;AACnB,YAAA,MAAM,CAAC,UAAU;AACjB,YAAA,UAAU,CAAC,eAAe;AAC1B,YAAA,SAAS,CAAC,WAAW;AACtB,SAAA,CAAC;;QAEF,IAAI,QAAQ,CAAC,sBAAsB;AAAE,YAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,sBAAsB,CAAC;AACjF,QAAA,OAAO,OAAO;AAChB,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,cAAc;AACvB;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmaic/renderer",
3
- "version": "0.1.17",
3
+ "version": "0.2.1",
4
4
  "description": "React component for rendering PPTist-style Slide JSON, extracted from OpenMAIC.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -56,7 +56,7 @@
56
56
  "access": "public"
57
57
  },
58
58
  "peerDependencies": {
59
- "echarts": ">=5",
59
+ "echarts": ">=5.5",
60
60
  "motion": ">=11",
61
61
  "react": ">=18",
62
62
  "react-dom": ">=18",
@@ -80,7 +80,7 @@
80
80
  "tailwind-merge": "^3.4.0",
81
81
  "tinycolor2": "^1.6.0",
82
82
  "@openmaic/geometry": "^0.1.0",
83
- "@openmaic/dsl": "^0.12.0"
83
+ "@openmaic/dsl": "^0.13.0"
84
84
  },
85
85
  "devDependencies": {
86
86
  "@rollup/plugin-commonjs": "^28.0.1",