Echarts 主标题和副标题属性设置

标题的效果图(这标题样式很糙。。莫怪。。需要自己改吧)
在这里插入图片描述
代码

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>echarts标题</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    #chart_title {
      width: 100vw;
      height: 100vh;
    }
  </style>
</head>

<body>
  <div id="chart_title"></div>
  <script src="https://cdn.bootcss.com/echarts/4.2.1-rc1/echarts.min.js"></script>
  <script>
    var myChart = echarts.init(document.getElementById('chart_title'));
    option = {
      title: {
        text: '百度一下',//主标题
        link: 'http://www.baidu.com',//主标题超链接
        target: 'blank',//副标题的超链接打开方式
        subtext: "中国\n杭州", //副标题 \n 用于换行
        sublink: 'http://www.baidu.com',//副标题超链接
        subtarget: 'blank',//副标题超链接打开方式
        itemGap: 5,//主副标题间距
        left: 'center',//主副标题的水平位置
        top: 'center',//主副标题的垂直位置
        padding: 20,//标题内边距,
        backgroundColor: '#ccc',//背景颜色;
        borderColor: '#000',//边框的颜色
        borderWidth: 5,//标签线框
        borderRadius: 10,//边框切圆角
        shadowBlur: 10,//图形阴影模糊大小.
        shadowColor: 'aqua',//阴影颜色
        shadowOffsetX: '60',//阴影水平方向上的偏移距离
        shadowOffsetY: '70',//阴影垂直方向上的偏移距离
        // textAlign: 'auto',//整体(包括 text 和 subtext)的水平对齐
        // textVerticalAlign: 'auto',//整体(包括 text 和 subtext)的垂直对齐。

        textStyle: {//主标题的属性
          color: '#C28D21',//颜色
          fontSize: 40,//大小
          fontStyle: 'oblique',//斜体
          fontWeight: '700',//粗细
          fontFamily: 'monospace',//字体
          // textBorderColor: "#000",//描边
          // textBorderWidth: '2',//描边的宽度
          textShadowColor: 'red',//阴影颜色
          textShadowBlur: '10',//阴影的宽度
          textShadowOffsetX: '-0',//阴影向X偏移
          textShadowOffsetY: '-70',//阴影向Y偏移
        },
        subtextStyle: {//副标题的属性
          color: '#25664A',
          // 同主标题
        },
      },
    }
    myChart.setOption(option, true);



  </script>
</body>

</html>

这里几乎包含了文档大部分的标题设置(说全部就太过分了还是有遗漏的) 中间的 rich 富文本样式自定义 还搞明白 。。。。

下班了 溜了。。。。。。

猜你喜欢

转载自blog.csdn.net/weixin_42698255/article/details/89249531
今日推荐