为了账号安全,请及时绑定邮箱和手机立即绑定
  • #479AD3

    HorizontalBar.vue

    <template>
    <div>
    <div>【大区数据信息】</div>
    <div ref="target" class="w-full h-full"></div>
    </div>
    </template>
    <script setup>
    import { ref, onMounted, watch } from "vue";
    import * as echarts from "echarts";
    const props = defineProps({
    data: {
    type: Object,
    required: true
    }
    });
    console.log("横向柱状图", props.data);
    
    // 1. 初始化echarts实例
    let mChart = null;
    const target = ref(null);
    
    onMounted(() => {
    mChart = echarts.init(target.value);
    
    renderChart();
    });
    
    // 2. 构建option配置对象
    const renderChart = () => {
    console.log("renderChart---");
    const options = {
    // X轴展示数据
    xAxis: {
    show: false,
    type: "value",
    max: function(value) {
    return parseInt(value.max * 1.2);
    }
    },
    // Y轴展示数据
    yAxis: {
    type: "category",
    data: props.data.regions.map(item => item.name),
    inverse: true,
    axisLine: {
    show: false
    },
    axisTick: {
    show: false
    },
    axisLabel: {
    //y轴文字的配置
    color: "#88f1ff",
    textStyle: {
    color: "white" //Y轴内容文字颜色
    }
    }
    },
    // 图表绘制的位置,对应 上下左右
    grid: {
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    containLabel: true
    },
    //核心配置
    series: [
    {
    type: "bar",
    data: props.data.regions.map(item => ({
    name: item.name,
    value: item.value
    })),
    showBackground: true,
    backgroundStyle: {
    color: "rgba(180,180,180,0.2)"
    },
    itemStyle: {
    color: "#479AD3",
    barBorderRadius: 5,
    shadowColor: "rgba(0,0,0,0.3)",
    shadowBlur: 5
    },
    barWidth: 12,
    label: {
    show: true,
    position: "right",
    textStyle: {
    color: "#fff"
    }
    }
    }
    ]
    };
    
    // 3.通过实例.setOptions(option)
    if (mChart != null) {
    mChart.setOption(options);
    }
    };
    watch(
    () => props.data,
    () => {
    renderChart();
    }
    );
    </script>
    
    <style lang="scss" scoped>
    </style>
    查看全部
  • 学习拉,学习拉,抓紧学习哦

    查看全部
  •  使用tailwindcss都不用自己写css样式了啊,熟悉已有的类名就行。不过这应该是针对小型项目,练手项目,没有自己组件库的情况使用吧

    查看全部
  • 我的一天https://img1.sycdn.imooc.com//64ef0a75000105e019200212.jpg

    查看全部
  • 这是一段问题描述,这是一段问题描述这是一段问题描述这是一段问题描述这是一段问题描述这是一段问题描述这是一段问题描述这是一段问题描述这是一段问题描述这是一段问题描述这是一段问题描述这是一段问题描述这是一段问题描述

    查看全部
    0 采集 收起 来源:导入 echarts 与 axios ,获取大屏动态数据

    笔记审核中笔记正在审核中,仅自己可见 2023-08-30

  • 我的问题

    查看全部

举报

0/150
提交
取消
课程须知
你是否有以下困惑: 1、问题太多,不知道如何解决 ? 2、想要看书,却看不下去? 3、求职、升级屡屡碰壁? 4、想晋升,却不知如何规划? 5、单打独斗,难以坚持? 6、找不到适合自己的学习资源?
老师告诉你能学到什么?
1、共学会为你全新录制《前端综合解决方案》 2、共学会为你精选5本书籍,只解读核心干货内容 3、共学会为每一位学员提供简历优化、模拟面试服务 4、共学会为你规划职业发展与技能学习路径 5、共学会连接数万开发者,共学共创学习型社群 6、为你提供优质编程学习资源

微信扫码,参与3人拼团

意见反馈 帮助中心 APP下载
官方微信
友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!