Skip to content

title属性

title标题组件,包含主标题和副标题。

example

vue
<template>
  <div class="about">
    <div ref="main" id="main"></div>
  </div>
</template>
<script setup lang="ts">
import * as echarts from "echarts";
import { onMounted, ref, reactive } from 'vue';
let main = ref<any>(null)
let myChart = reactive<any>(null)
onMounted(() => {
  myChart = echarts.init(main.value);
  myChart.setOption({
    title: {
      show: true, //显示策略,默认值true,可选为:true(显示) | false(隐藏)
      text: "1主标题", //主标题文本,'\n'指定换行
      // link:'http://www.baidu.com', //主标题文本超链接,默认值true
      // target: "self", //指定窗口打开主标题超链接,支持'self' | 'blank',不指定等同为'blank'(新窗口)
      subtext: '副标题', //副标题文本,'\n'指定换行
      // sublink: '', //副标题文本超链接
      // subtarget: null, //指定窗口打开副标题超链接,支持'self' | 'blank',不指定等同为'blank'(新窗口)
      // x:'center', //水平安放位置,默认为'left',可选为:'center' | 'left' |'right' | {number}(x坐标,单位px)
      // y: 'bottom', //垂直安放位置,默认为top,可选为:'top' | 'bottom' | 'center'| {number}(y坐标,单位px)
      // backgroundColor: 'red', //标题背景颜色,默认'rgba(0,0,0,0)'透明
      // borderWidth: 5, //标题边框线宽,单位px,默认为0(无边框)
      // borderColor: '#ccffee', //标题边框颜色,默认'#ccc'
      // padding: 5, //标题内边距,单位px,默认各方向内边距为5,接受数组分别设定上右下左边距
      // itemGap: 10, //主副标题纵向间隔,单位px,默认为10
      // textStyle: { //主标题文本样式{"fontSize": 18,"fontWeight":"bolder","color": "#333"}
      // fontFamily: 'Arial, Verdana, sans...',
      // fontSize: 12,
      // fontStyle: 'normal',
      // fontWeight: 'normal', // },
      // subtextStyle: {//副标题文本样式{"color": "#aaa"}
      // fontFamily: 'Arial, Verdana, sans...',
      // fontSize: 12,
      // fontStyle: 'normal',
      // fontWeight: 'normal',
      // },
      // subtextStyle: {
      // color: "#a1b2c3", // 副标题文字的颜色。
      // fontStyle: "normal", // 副标题文字字体的风格。 'normal' 'italic''oblique'
      // fontWeight: "bold", // 副标题文字字体的粗细。 'normal' 'bold''bolder' 'lighter' 500|600。
      // fontSize: 18, // 字体大小
      // lineHeight: "130", // 行高
      // textBorderColor: "red", // 文字本身的描边颜色        
      //7. 配置项--tooltip
      //提示框组件,用于配置鼠标滑过或点击图表时的显示框
      // textBorderWidth: 5, // 文字本身的描边宽度。
      // textShadowColor: "transparent", // 文字本身的阴影颜色。
      // textShadowBlur: 0, // 文字本身的阴影长度。
      // textShadowOffsetX: 0, // 文字本身的阴影 X 偏移。
      // textShadowOffsetY: 0, // 文字本身的阴影 Y 偏移。
      // },
    },
    tooltip: {},
    legend: {},
    xAxis: {
      data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"],
    },
    yAxis: {},
    series: [
      {
        name: "销量",
        type: "bar",
        data: [5, 20, 36, 10, 10, 20],
      },
    ],
  });
})

</script>
<style>
#main {
  width: 500px;
  height: 500px;
}
</style>