Commit 972c414c by qlintonger xeno

feat: 添加其事件监听

parent 0f71878b
...@@ -10,12 +10,12 @@ const sampleForLineCharts = { ...@@ -10,12 +10,12 @@ const sampleForLineCharts = {
const sampleForRadarCharts = { const sampleForRadarCharts = {
type: ChartCompType.SimpleRadar, type: ChartCompType.SimpleRadar,
indicators: [ indicators: [
{ name: 'Sales', max: 6500 }, { name: 'Sales', max: 6500, min: 0 },
{ name: 'Administration', max: 16000 }, { name: 'Administration', max: 16000, min: 0 },
{ name: 'Information Technology', max: 30000 }, { name: 'Information Technology', max: 30000, min: 0 },
{ name: 'Customer Support', max: 38000 }, { name: 'Customer Support', max: 38000, min: 0 },
{ name: 'Development', max: 52000 }, { name: 'Development', max: 52000, min: 0 },
{ name: 'Marketing', max: 25000 } { name: 'Marketing', max: 25000, min: 0 }
], ],
data: [ data: [
{ {
...@@ -70,6 +70,10 @@ const sampleKLine = { ...@@ -70,6 +70,10 @@ const sampleKLine = {
] ]
} }
] ]
},
onClickGraph(item: any, index: number) {
alert('click-kline')
console.log('item-here', {item, index})
} }
} }
...@@ -122,6 +126,10 @@ const sampleScatter = { ...@@ -122,6 +126,10 @@ const sampleScatter = {
type: 'scatter' type: 'scatter'
} }
] ]
},
onClickGraph(item: any, index: number) {
alert('click-scatter!')
console.log('item-here', {item, index})
} }
} }
...@@ -215,6 +223,10 @@ const indexMapper: Record<string, any> = { ...@@ -215,6 +223,10 @@ const indexMapper: Record<string, any> = {
1: { 1: {
title: "随意设置图", title: "随意设置图",
chartData: [sampleKLine, sampleScatter], chartData: [sampleKLine, sampleScatter],
onClickTitle(item: any) {
alert('click-random')
console.log('item-here', {item})
}
}, },
6: { 6: {
title: "简单混排图", title: "简单混排图",
......
...@@ -47,7 +47,7 @@ import { singleContainerClass } from "./const/staticConsts.ts"; ...@@ -47,7 +47,7 @@ import { singleContainerClass } from "./const/staticConsts.ts";
:style="gridItemStyle(item, props, gridConfig)" :style="gridItemStyle(item, props, gridConfig)"
class="flex flex-col" class="flex flex-col"
> >
<div v-if="!item.renderTitle" class="w-full">{{ item.title }}</div> <div @click="item.onClickTitle ? item.onClickTitle(item) : () => {}" v-if="!item.renderTitle" class="w-full">{{ item.title }}</div>
<component :is="item.renderTitle(item, props.layout)" v-else /> <component :is="item.renderTitle(item, props.layout)" v-else />
<div <div
v-if="isAllMounted" v-if="isAllMounted"
...@@ -68,6 +68,7 @@ import { singleContainerClass } from "./const/staticConsts.ts"; ...@@ -68,6 +68,7 @@ import { singleContainerClass } from "./const/staticConsts.ts";
v-for="(z, x) in item.chartData" v-for="(z, x) in item.chartData"
:key="x" :key="x"
:options="mapToEchartsOptions(z)" :options="mapToEchartsOptions(z)"
@click="z.onClickGraph && z.onClickGraph(z, x)"
/> />
</div> </div>
</div> </div>
......
...@@ -8,6 +8,7 @@ export type BarChartOptions = { ...@@ -8,6 +8,7 @@ export type BarChartOptions = {
chartWidth?: number | string; chartWidth?: number | string;
chartHeight?: number | string; chartHeight?: number | string;
options?: any options?: any
onClickGraph?: Function;
}; };
export type LineChartOptions = BarChartOptions; export type LineChartOptions = BarChartOptions;
...@@ -20,6 +21,7 @@ export type PieChartOptionsBase = { ...@@ -20,6 +21,7 @@ export type PieChartOptionsBase = {
chartHeight?: number | string; chartHeight?: number | string;
legend?: any; legend?: any;
options?: any options?: any
onClickGraph?: Function;
}; };
export type PieCharOptions = PieChartOptionsBase & { export type PieCharOptions = PieChartOptionsBase & {
...@@ -34,6 +36,7 @@ export type ButtonCenterText = { ...@@ -34,6 +36,7 @@ export type ButtonCenterText = {
title: string; title: string;
bottomTex: string; bottomTex: string;
type: ChartCompType; type: ChartCompType;
onClickGraph?: Function;
}; };
export type SimpleTableChart = { export type SimpleTableChart = {
...@@ -41,6 +44,7 @@ export type SimpleTableChart = { ...@@ -41,6 +44,7 @@ export type SimpleTableChart = {
columns: Array<{ title: string; key: string }>; columns: Array<{ title: string; key: string }>;
data: Array<Record<string, any>>; data: Array<Record<string, any>>;
options?: any options?: any
onClickGraph?: Function;
}; };
export type SimpleRadarChart = { export type SimpleRadarChart = {
...@@ -52,6 +56,7 @@ export type SimpleRadarChart = { ...@@ -52,6 +56,7 @@ export type SimpleRadarChart = {
legend?: any; legend?: any;
indicators: Array<{ name: string; max: number }>; indicators: Array<{ name: string; max: number }>;
options?: any options?: any
onClickGraph?: Function;
}; };
export type DIYChart = { export type DIYChart = {
...@@ -59,6 +64,7 @@ export type DIYChart = { ...@@ -59,6 +64,7 @@ export type DIYChart = {
options: any, options: any,
chartWidth?: number | string; chartWidth?: number | string;
chartHeight?: number | string; chartHeight?: number | string;
onClickGraph?: Function;
} }
export type GeneralChartOptions = export type GeneralChartOptions =
...@@ -82,6 +88,7 @@ export type SingleLayoutConf = { ...@@ -82,6 +88,7 @@ export type SingleLayoutConf = {
wrapperClass?: string | Array<string> | Record<string, any>; wrapperClass?: string | Array<string> | Record<string, any>;
wrapperStyle?: Record<string, any> | Function; wrapperStyle?: Record<string, any> | Function;
columns?: number; columns?: number;
onClickTitle?: Function;
}; };
export type LayoutConfig = Array<SingleLayoutConf>; export type LayoutConfig = Array<SingleLayoutConf>;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment