@revolist/vue-charts 3.0.3 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -90,7 +90,9 @@ so do not destroy its ref yourself.
90
90
  Creation and updates are asynchronous. Pending work is cancelled on unmount or
91
91
  superseding configuration, and stale results are destroyed. Failures call
92
92
  `options.onError`, or `console.error` when no error handler is supplied. Server
93
- rendering produces an empty host; chart creation starts after client mounting.
93
+ rendering produces an empty host by default. Pass the optional `serverRender`
94
+ result from `renderChartToSVG` to include initial SVG and hydrate it on mounting.
95
+ See the engine's [server rendering guide](../../docs/server-rendering.md).
94
96
 
95
97
  ## Building and distribution
96
98
 
package/dist/index.d.ts CHANGED
@@ -1,12 +1,15 @@
1
1
  import type { PropType } from 'vue';
2
2
  import type { ChartComponentOptions } from '@revolist/charts/framework';
3
- import type { ChartRef } from '@revolist/charts';
3
+ import type { ChartRef, ChartServerRender } from '@revolist/charts';
4
4
  export type { ChartComponentOptions, ChartRef };
5
5
  export declare const RevoChart: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
6
6
  options: {
7
7
  type: PropType<ChartComponentOptions>;
8
8
  required: true;
9
9
  };
10
+ serverRender: {
11
+ type: PropType<ChartServerRender>;
12
+ };
10
13
  }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
11
14
  [key: string]: any;
12
15
  }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
@@ -16,6 +19,9 @@ export declare const RevoChart: import("vue").DefineComponent<import("vue").Extr
16
19
  type: PropType<ChartComponentOptions>;
17
20
  required: true;
18
21
  };
22
+ serverRender: {
23
+ type: PropType<ChartServerRender>;
24
+ };
19
25
  }>> & Readonly<{
20
26
  onReady?: ((_chart: ChartRef) => any) | undefined;
21
27
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
package/dist/index.js CHANGED
@@ -3,17 +3,21 @@ import { createChartComponentController } from '@revolist/charts/framework';
3
3
  export const RevoChart = defineComponent({
4
4
  name: 'RevoChart',
5
5
  inheritAttrs: false,
6
- props: { options: { type: Object, required: true } },
6
+ props: {
7
+ options: { type: Object, required: true },
8
+ serverRender: { type: Object },
9
+ },
7
10
  emits: { ready: (_chart) => true },
8
11
  setup(props, { attrs, emit }) {
12
+ const initial = props.serverRender;
9
13
  const host = ref();
10
14
  let controller;
11
15
  onMounted(() => {
12
- controller = createChartComponentController(host.value, chart => emit('ready', chart));
16
+ controller = createChartComponentController(host.value, chart => emit('ready', chart), !!initial);
13
17
  void controller.setOptions(toRaw(props.options));
14
18
  });
15
19
  watch(() => props.options, options => { void controller?.setOptions(toRaw(options)); });
16
20
  onBeforeUnmount(() => controller?.destroy());
17
- return () => h('div', mergeProps({ style: { width: '100%', height: '300px' } }, attrs, { ref: host }));
21
+ return () => h('div', mergeProps({ style: { width: '100%', height: `${initial?.height ?? 300}px` } }, attrs, { ref: host, ...(initial ? { innerHTML: initial.svg } : {}) }));
18
22
  },
19
23
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revolist/vue-charts",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "Vue components for RevoGrid Charts",
5
5
  "type": "module",
6
6
  "license": "Commercial",
@@ -18,7 +18,7 @@
18
18
  }
19
19
  },
20
20
  "dependencies": {
21
- "@revolist/charts": "3.0.3"
21
+ "@revolist/charts": "3.0.5"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "vue": "^3.5.0"