feat(data-vi): allow to set link for statistic chart (#5073)

This commit is contained in:
YANG QIA 2024-08-16 15:50:02 +08:00 committed by GitHub
parent e245da8f29
commit b9d1604eb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 2 deletions

View File

@ -0,0 +1,29 @@
/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import React from 'react';
import { Statistic as AntdStatistic } from 'antd';
export const Statistic: React.FC<any> = (props: any) => {
const { link, ...options } = props;
return (
<div
onClick={() => {
if (link) {
window.open(link, '__blank');
}
}}
style={{
cursor: link ? 'pointer' : 'auto',
}}
>
<AntdStatistic {...options} />
</div>
);
};

View File

@ -8,16 +8,16 @@
*/
import { AntdChart } from './antd';
import { Statistic as AntdStatistic } from 'antd';
import { lang } from '../../locale';
import { ChartType, RenderProps } from '../chart';
import { Statistic as C } from './components/Statistic';
export class Statistic extends AntdChart {
constructor() {
super({
name: 'statistic',
title: 'Statistic',
Component: AntdStatistic,
Component: C,
config: [
{
property: 'field',
@ -33,6 +33,14 @@ export class Statistic extends AntdChart {
'x-component': 'Input',
},
},
{
link: {
title: lang('Link'),
type: 'string',
'x-decorator': 'FormItem',
'x-component': 'Input',
},
},
],
});
}