@binarysee/widgets
v1.0.5
Published
图表组件
Readme
📦 安装
# 使用 npm
npm install @dash/widgets
# 使用 pnpm
pnpm add @dash/widgets
# 使用 yarn
yarn add @dash/widgets🔨 使用方法
基础使用
import { RenderChart } from '@dash/widgets'
// 必须引入样式文件
import '@dash/widgets/dist/widgets-component.css'
function App() {
const onPaginationChange = (page: number, pageSize: number) => {
const visual = item.answer?.visual
const indicatorModelSql = item.answer?.indicatorModelSql
if (!visual) {
return
}
// 接口URL : `/brain/chatbi/0/widget/page`
chatbiTablePagenationApi({
pageNum: page,
pageSize,
robotId,
...visual,
indicatorModelSql,
}).then((res) => {})
}
return (
<div style={{ width: 300, height: 300 }}>
<RenderChart
onPaginationChange={(page: number, pageSize: number) => {
// 表格组件分页change方法,请求分页接口
onPaginationChange(page: number, pageSize: number)
}}
chartDsl={{
data: {
total: 1,
data: [{total_sales_orders: 57}],
meta: [{field: 'total_sales_orders', name: 'total_sales_orders'}],
pageSize: 10,
fields: {columns: ['total_sales_orders']},
},
widgetID: 81275820918017,
title: '销售签单的数量是多少',
type: 'DATA_TABLE',
}}
/>
</div>
)
}