Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/api",
"version": "14.60.5",
"version": "14.60.6",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/dashboard",
"version": "14.60.5",
"version": "14.60.6",
"license": "Apache-2.0",
"repository": {
"url": "https://github.com/merico-dev/table"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ function Chart({ conf, data, width, height, interactionManager, variables, onCha
const echartsRef = React.useRef<EChartsInstance>();
const onRenderFinishedRef = useLatest(onChartRenderFinished);

useEffect(() => {
setTimeout(() => {
onRenderFinishedRef.current?.(echartsRef.current?.getOption());
}, 100);
}, [option]);

const onEvents = useMemo(() => {
return {
click: handleSeriesClick,
Expand All @@ -76,6 +70,12 @@ function Chart({ conf, data, width, height, interactionManager, variables, onCha
return getOption(conf, data, variables);
}, [conf, data]);

useEffect(() => {
setTimeout(() => {
onRenderFinishedRef.current?.(echartsRef.current?.getOption());
}, 100);
}, [option]);

if (!width || !height) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { VizInstance } from '~/types/plugin';
import { IPanelInfo } from '~/components/plugins';
import { VizInstance } from '~/types/plugin';

/**
* Emit viz rendered event
Expand All @@ -20,8 +20,21 @@ export interface IVizRenderedPayload {
* @param callback
*/
export function onVizRendered(instance: VizInstance, callback: (data: unknown) => void) {
instance.messageChannels.getChannel('viz').on('rendered', callback);
const channel = instance.messageChannels.getChannel('viz');
channel.on('rendered', callback);
return () => {
channel.off('rendered', callback);
};
}

export function notifyPanelLoaded(instance: VizInstance, data: unknown) {
instance.messageChannels.getChannel('panel').emit('loaded', data);
}

export function onPanelLoaded(instance: VizInstance, callback: (data: unknown) => void) {
const channel = instance.messageChannels.getChannel('panel');
channel.on('loaded', callback);
return () => {
instance.messageChannels.getChannel('viz').off('rendered', callback);
channel.off('loaded', callback);
};
}
5 changes: 5 additions & 0 deletions dashboard/src/components/plugins/viz-manager/components.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { omit } from 'lodash';
import { useEffect } from 'react';
import { VizConfigContext, VizContext, VizInstance, VizViewContext } from '~/types/plugin';
import { ITemplateVariable } from '~/utils';
import { JsonPluginStorage } from '../json-plugin-storage';
import { IPanelInfo, IVizManager } from './types';
import { notifyPanelLoaded } from '../viz-components/viz-instance-api';

function createCommonContext(
instance: VizInstance,
Expand Down Expand Up @@ -53,6 +55,9 @@ export const VizViewComponent = <T,>(props: IViewComponentProps<T>) => {
...createCommonContext(instance, data, vizManager, variables),
viewport: { width: measure.w, height: measure.h },
};
useEffect(() => {
notifyPanelLoaded(instance, data);
}, [data, instance]);
const Comp = comp.viewRender;
return <Comp context={context} instance={instance} {...omit(props, ['panel', 'vizManager', 'data'])} />;
};
Expand Down
2 changes: 1 addition & 1 deletion settings-form/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/settings-form",
"version": "14.60.5",
"version": "14.60.6",
"license": "Apache-2.0",
"repository": {
"url": "https://github.com/merico-dev/table"
Expand Down