更新记录

1.2.1(2024-04-25)

组件优化

1.2.0(2024-04-25)

组件优化

1.2(2024-04-25)

组件优化

查看更多

平台兼容性

Vue2 Vue3
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
HBuilderX 3.8.0 app-vue app-nvue
钉钉小程序 快手小程序 飞书小程序 京东小程序
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari

cc-treeChart

使用方法


<!-- 引入lime-echart组件 -->    
import LEchart from '@/uni_modules/lime-echart/components/l-echart/l-echart.vue';
import * as echartsLime from '@/uni_modules/lime-echart/static/echarts.min'

    export default {
        components: {
            LEchart
        },  
    }

<l-echart ref="chart" @finished="init"></l-echart>

    <!-- 在method实现init方法 -->
    async init() {

                //  颜色设定 不同颜色寓意不同权重
                var fatherColor = 'green';
                var midColor = 'rgb(193, 92, 31)';
                var smallColor = 'rgb(247, 203, 174)';

                // 新能源汽车
                let swyyQ = {
                    "name": "新能源汽车",
                    itemStyle: {
                        color: midColor
                    },
                    "children": [{
                            "name": "大型企业",
                            itemStyle: {
                                color: fatherColor
                            },

                        },
                        {
                            "name": "中型企业",
                            itemStyle: {
                                color: midColor
                            },

                        },
                        {
                            "name": "小型企业",
                            itemStyle: {
                                color: smallColor
                            },

                        },
                        {
                            "name": "其他规模企业",
                            itemStyle: {
                                color: fatherColor
                            },
                        }
                    ]
                };

                // 新材料行业
                let xclkQ = {
                    "name": "生物与新医药",
                    itemStyle: {
                        color: fatherColor
                    },
                    "children": [{
                            "name": "大型企业",
                            itemStyle: {
                                color: fatherColor
                            },

                        },
                        {
                            "name": "中型企业",
                            itemStyle: {
                                color: midColor
                            },

                        },
                        {
                            "name": "小型企业",
                            itemStyle: {
                                color: smallColor
                            },

                        },
                        {
                            "name": "其他规模企业",
                            itemStyle: {
                                color: fatherColor
                            },
                        }
                    ]
                };;

                let data = {
                    "name": "行业分类",
                    itemStyle: {
                        color: fatherColor
                    },
                    "children": [swyyQ, xclkQ]

                }
                // 获取网页宽度 设置树形条目实体宽高度
                let width = 360;
                let widthSize = 0.039 * width;
                if (widthSize > 36) {
                    widthSize = 36;
                }
                let heightSize = widthSize * 2.6;

                this.option = {
                    tooltip: {
                        trigger: 'item',
                        triggerOn: 'mousemove'
                    },
                    series: [{
                        type: 'tree',
                        data: [data],
                        left: '20%',
                        right: '20%',
                        top: '16%',
                        bottom: '32%',
                        symbol: 'square',
                        symbolSize: [widthSize, heightSize],
                        orient: 'vertical',
                        expandAndCollapse: true,
                        initialTreeDepth: 2,

                        label: {
                            position: 'top',
                            rotate: 0,
                            verticalAlign: 'middle',
                            align: 'center',
                            fontSize: 12
                        },
                        leaves: {
                            label: {
                                position: 'bottom',
                                rotate: -90,
                                verticalAlign: 'middle',
                                align: 'left'
                            }
                        },
                        animationDurationUpdate: 150
                    }]
                };

                // chart 图表实例不能存在data里
                const chart = await this.$refs.chart.init(echartsLime);
                chart.setOption(this.option)
            }

HTML代码实现部分


<template>
    <view class="content">

        <view class="mui-content" style="margin-top: 16px;">

            <l-echart ref="chart" @finished="init"></l-echart>

        </view>

    </view>
</template>

<script>
    import LEchart from '@/uni_modules/lime-echart/components/l-echart/l-echart.vue';
    import * as echartsLime from '@/uni_modules/lime-echart/static/echarts.min'

    export default {
        components: {
            LEchart
        },
        data() {
            return {
                option: {},
            }
        },

        mounted() {

        },

        methods: {

            async init() {

                //  颜色设定 不同颜色寓意不同权重
                var fatherColor = 'green';
                var midColor = 'rgb(193, 92, 31)';
                var smallColor = 'rgb(247, 203, 174)';

                // 新能源汽车
                let swyyQ = {
                    "name": "新能源汽车",
                    itemStyle: {
                        color: midColor
                    },
                    "children": [{
                            "name": "大型企业",
                            itemStyle: {
                                color: fatherColor
                            },

                        },
                        {
                            "name": "中型企业",
                            itemStyle: {
                                color: midColor
                            },

                        },
                        {
                            "name": "小型企业",
                            itemStyle: {
                                color: smallColor
                            },

                        },
                        {
                            "name": "其他规模企业",
                            itemStyle: {
                                color: fatherColor
                            },
                        }
                    ]
                };

                // 新材料行业
                let xclkQ = {
                    "name": "生物与新医药",
                    itemStyle: {
                        color: fatherColor
                    },
                    "children": [{
                            "name": "大型企业",
                            itemStyle: {
                                color: fatherColor
                            },

                        },
                        {
                            "name": "中型企业",
                            itemStyle: {
                                color: midColor
                            },

                        },
                        {
                            "name": "小型企业",
                            itemStyle: {
                                color: smallColor
                            },

                        },
                        {
                            "name": "其他规模企业",
                            itemStyle: {
                                color: fatherColor
                            },
                        }
                    ]
                };;

                let data = {
                    "name": "行业分类",
                    itemStyle: {
                        color: fatherColor
                    },
                    "children": [swyyQ, xclkQ]

                }
                // 获取网页宽度 设置树形条目实体宽高度
                let width = 360;
                let widthSize = 0.039 * width;
                if (widthSize > 36) {
                    widthSize = 36;
                }
                let heightSize = widthSize * 2.6;

                this.option = {
                    tooltip: {
                        trigger: 'item',
                        triggerOn: 'mousemove'
                    },
                    series: [{
                        type: 'tree',
                        data: [data],
                        left: '20%',
                        right: '20%',
                        top: '16%',
                        bottom: '32%',
                        symbol: 'square',
                        symbolSize: [widthSize, heightSize],
                        orient: 'vertical',
                        expandAndCollapse: true,
                        initialTreeDepth: 2,

                        label: {
                            position: 'top',
                            rotate: 0,
                            verticalAlign: 'middle',
                            align: 'center',
                            fontSize: 12
                        },
                        leaves: {
                            label: {
                                position: 'bottom',
                                rotate: -90,
                                verticalAlign: 'middle',
                                align: 'left'
                            }
                        },
                        animationDurationUpdate: 150
                    }]
                };

                // chart 图表实例不能存在data里
                const chart = await this.$refs.chart.init(echartsLime);
                chart.setOption(this.option)
            }

        }

    }
</script>

<style>
    .content {
        display: flex;
        flex-direction: column;

    }
</style>

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问