Skip to content

混合图演示

混合图演示https://yundie.xyz/x-charts-demo/index.html?type=mix

参考配置

柱状图 + 折线图

html
<template>
  <view class="container">
    <t-xcharts
      ref="chart"
      :option="chartOption"
    ></t-xcharts>
  </view>
</template>

<script setup>
import { ref } from 'vue';

const chartOption = ref({
  type: 'mix',
  animation: true,
  dataLabel: true,
  xAxis: {
    disableGrid: true
  },
  yAxis: {
    data: [{
      min: 0,
      max: 100
    }]
  },
  series: [
    {
      type: 'column',
      name: '销量',
      data: [15, 20, 45, 37, 43, 34, 50],
      color: '#2979ff'
    },
    {
      type: 'line',
      name: '趋势',
      data: [25, 30, 35, 27, 33, 44, 40],
      color: '#19be6b'
    }
  ],
  categories: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
});
</script>

配置说明

type

图表类型,设置为 'mix' 表示混合图。

series

数据系列配置,每个系列可以指定不同的 type

  • column: 柱状图
  • line: 折线图
  • area: 区域图
  • bar: 条状图

混合图组合多种图表类型,适合展示不同类型的数据。