Skip to content

基础折线图

示例

基础示例

vue
<script setup>
const data = {
  Taylor: 81,
  Clark: 78,
  Martin: 75,
  Perez: 80,
  Lewis: 86,
  Wilson: 81,
  Jackson: 87,
}
</script>

<template>
  <div v-ec="['lineSimple', data]" style="width: 100%; height: 300px;" />
</template>

配置过的示例

vue
<script setup>
const data = [
  {
    name: 2021,
    data: {
      Taylor: 71,
      Clark: 68,
      Martin: 57,
      Perez: 90,
      Lewis: 68,
    },
  },
  {
    name: 2022,
    data: {
      Taylor: 101,
      Clark: 78,
      Martin: 75,
      Perez: 80,
      Lewis: 86,
    },
  },
  {
    name: 2023,
    data: {
      Taylor: 88,
      Clark: 98,
      Martin: 57,
      Perez: 50,
      Lewis: 76,
    },
  },
]
</script>

<template>
  <div
    v-ec="[
      'lineSimple',
      data,
      {
        itemColor: ['#DC3545', '#FFC107', '#0D6EFD'],
      },
    ]"
    style="width: 100%; height: 300px; padding-top: 15px;"
  />
</template>

参数说明

索引类型必填默认值说明
0lineSimple--
1Data-数据
2OptionsdefaultOptions配置参数
3EcOptions-ECharts 配置参数

参数默认值

options

ts
const defaultOptions: Options = {
  itemColor: 'auto',
}

参数类型

Data

ts
export type NameData = { name: string, data: NumberObject | NumberKeyValuePairArray }[]

export type Data =
  NumberObject |
  NumberKeyValuePairArray |
  NameData

Options

ts
export interface Options {
  /**
   * The color of the bar. If `data` passes in an array,
   * different colors can also be defined here by passing in an array.
   *
   * @see https://echarts.apache.org/option.html#series-line.itemStyle.color
   */
  itemColor?: string | string[]
}

EcOptions

ts
export type EcOptions = Partial<EChartsOption>

基于 MIT 许可发布