tachybase_todo/packages/plugins/@nocobase/plugin-data-visualization/src/client/DataVisualization.tsx
YANG QIA ae988d00b0
refactor(bi): improve chart frontend api (#2721)
* refactor: improve chart frontend api

* chore: remove redundant import

* fix: rename chartType

* chore: add migration check

* fix: add migration

* fix: change version

* chore: update
2023-09-27 15:50:04 +08:00

25 lines
876 B
TypeScript

import { SchemaInitializerContext, SchemaInitializerProvider } from '@nocobase/client';
import React, { useContext } from 'react';
import { ChartInitializers } from './block';
import { useChartsTranslation } from './locale';
export const DataVisualization: React.FC = (props) => {
const { t } = useChartsTranslation();
const initializers = useContext<any>(SchemaInitializerContext);
const children = initializers.BlockInitializers.items[0].children;
const has = children.some((initializer) => initializer.component === 'ChartV2BlockInitializer');
if (!has) {
children.push({
key: 'chart-v2',
type: 'item',
title: t('Charts'),
component: 'ChartV2BlockInitializer',
});
}
return (
<SchemaInitializerProvider initializers={{ ...initializers, ChartInitializers }}>
{props.children}
</SchemaInitializerProvider>
);
};