码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • vue3 中使用echarts图表——柱状图


     柱状图是比较常用的图形结构,所以我先收集一些精美的柱状图

    一、柱状图:设置圆角和颜色

     

    1. <template>
    2. <div class="box" ref="chartDom">div>
    3. template>
    4. <script setup>
    5. import { ref, onMounted } from "vue";
    6. import * as echarts from "echarts";
    7. let chartDom = ref(null); //注意变量名 和 ref名字要对应
    8. onMounted(() => {
    9. initChart();
    10. });
    11. const initChart = () => {
    12. var myChart = echarts.init(chartDom.value);
    13. var option = {
    14. tooltip: {
    15. // 鼠标悬浮提示数据
    16. trigger: "axis",
    17. backgroundColor: "rgba(32, 33, 36,.7)",
    18. borderColor: "rgba(32, 33, 36,0.20)",
    19. borderWidth: 15,
    20. textStyle: {
    21. // 文字提示样式
    22. color: "#fff",
    23. fontSize: "12",
    24. },
    25. axisPointer: {
    26. // 坐标轴虚线
    27. type: "cross",
    28. label: {
    29. backgroundColor: "#6a7985",
    30. },
    31. },
    32. },
    33. // },
    34. grid: {
    35. // 控制图表的位置
    36. left: "5%",
    37. right: "5%",
    38. top: "18%",
    39. bottom: "5%",
    40. containLabel: true,
    41. },
    42. xAxis: {
    43. axisLabel: {
    44. // X轴线 标签修改
    45. textStyle: {
    46. color: "white", //坐标值得具体的颜色
    47. fontSize: "10",
    48. },
    49. },
    50. data: ["A", "B", "C", "D", "E", "F"],
    51. },
    52. yAxis: {
    53. axisLabel: {
    54. // y轴线 标签修改
    55. textStyle: {
    56. color: "white", //坐标值得具体的颜色
    57. },
    58. },
    59. },
    60. series: [
    61. {
    62. data: [2549, 12421, 2637, 3146, 15189, 9562],
    63. type: "bar",
    64. barWidth: "48%", //调整柱状图宽度
    65. itemStyle: {
    66. normal: {
    67. /*--------设置柱形图圆角 [左上角,右上角,右下角,左下角]-------------*/
    68. borderRadius: [12, 12, 0, 0],
    69. /*--------设置柱形图渐变色 -------------*/
    70. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
    71. {
    72. offset: 0,
    73. color: "rgba(0,244,255,1)",
    74. },
    75. {
    76. offset: 1,
    77. color: "rgba(0,77,167,1)",
    78. },
    79. ]),
    80. },
    81. },
    82. },
    83. ],
    84. };
    85. option && myChart.setOption(option);
    86. };
    87. script>
    88. <style scoped>
    89. .box {
    90. width: 24vw;
    91. height: 60vh;
    92. background-color: #031a67;
    93. }
    94. style>

  • 相关阅读:
    几道ctf 命令注入题目的解法
    使用 Presto 和 Alluxio 在 AWS 上搭建高性能平台来支持实时游戏服务
    [架构之路-243]:目标系统 - 纵向分层 - 架构是表面轮廓、内部骨架、未来蓝图,企业组织架构、信息系统架构、软件架构、应用程序就架构
    JavaScript单线程模型
    Thymeleaf页面布局
    大学生游戏静态HTML网页设计 (HTML+CSS+JS仿英雄联盟网站15页)
    Visual Studio Code安装C#开发工具包并编写ASP.NET Core Web应用
    数据结构和算法(13):优先级队列
    Kylin ext3/4 xfs手动扩容根分区
    字节跳动软件测试岗,前两面过了,第三面HR天坑,结局透心凉...
  • 原文地址:https://blog.csdn.net/tengyuxin/article/details/133607412
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号