xgqfrms / uni-app-in-action

uni-app 实战
MIT License
0 stars 0 forks source link

uniapp echarts & clickData OK #13

Open xgqfrms opened 3 years ago

xgqfrms commented 3 years ago

uniapp echarts & clickData OK

https://github.com/xgqfrms/uni-app-in-action/blob/main/uniapp-echarts/pages/index.vue

https://github.com/xgqfrms/uni-app-in-action/blob/main/uniapp-echarts/components/echarts/echarts.vue

xgqfrms commented 3 years ago

https://www.cnblogs.com/xgqfrms/p/14668075.html

xgqfrms commented 3 years ago

echarts

    // this.$dayjs(this.content.startTime).format('YYYY年MM月DD日')
    onClick(event, ownerInstance) {
        // 调用 service 层的方法
        console.log('this.clickData', this.clickData);
        const {
            componentIndex,
            componentSubType,
            componentType,
            data,
            dataIndex,
            //
            // $vars: (3) ["seriesName", "name", "value"]
            // borderColor: undefined
            // color: "#F99963"
            // componentIndex: 0
            // componentSubType: "bar"
            // componentType: "series"
            // data: 90114
            // dataIndex: 3
            // dataType: undefined
            // dimensionNames: (2) ["x", "y"]
            // encode: {x: Array(1), y: Array(1)}
            // event: {type: "click", event: PointerEvent, target: Sub, topTarget: Sub, cancelBubble: false, …}
            // marker: "<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:#F99963;"></span>"
            // name: "4/15"
            // seriesId: "新增安装0"
            // seriesIndex: 0
            // seriesName: "新增安装"
            // seriesType: "bar"
            // type: "click"
            // value: 90114
        } = this.clickData;
        if(data) {
            this.$ownerInstance.callMethod('viewClick', {
                data,
                dataIndex,
            });
            // ownerInstance.callMethod('viewClick', {
            //     data,
            //     dataIndex,
            // });
        }
        // 上次点击数据置空
        this.clickData = null;
    },