3 Star 14 Fork 2

谭上彪 / v2-charts

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

v2-charts

基于 Vue2 和 ECharts5 封装的组件。通过组件属性配置试,进一步的解决图表配置繁琐的问题,使代码看起来更加的清晰简洁。

ECharts 官网

简介

在线示例

组件介绍:

  • <charts/> 基础组件,主要用于生成布局和图表。
  • <charts-legend/> 图例组件,主要用于生成图表的图例, 配置项
  • <charts-series/> 图表类型组件,主要用于生成各种不同的图表,配置项
  • <charts-title/> 标题组件,主要用于生成图表标题,配置项
  • <charts-tooltip/> 提示框组件,主要用于生成图表的提示框,配置项
  • <charts-x-axis/> x轴组件,主要用于生成直角坐标系图表的x轴,配置项
  • <charts-y-axis/> y轴组件,主要用于生成直角坐标系图表的y轴,配置项

安装

npm i --save v2-charts

yarn i --save v2-charts

使用

  1. 引用
import V2Charts from 'v2-charts'

Vue.use(V2Charts)
  1. 示例
<template>
  <charts width="500px" height="500px">
    <charts-title text="这是一个饼图示例" left="center"/>
    <charts-legend orient="vertical" left="left"/>
    <charts-tooltip trigger="item" />
    <charts-series
       type="pie"
       name="访问来源"
       radius="50%"
       :data="pieData"
       :label="{
          formatter (item) {
            return `${item.name}\n ${item.value}`
          }
       }"
    />
  </charts>
</template>

<script>
export default {
  name: "charts-demo",
  data() {
    return {
      pieData: [
        { value: 1048, name: "搜索引擎" },
        { value: 735, name: "直接访问" },
        { value: 580, name: "邮件营销" },
        { value: 484, name: "联盟广告" },
        { value: 300, name: "视频广告" },
      ]
    }
  }
}
</script>

image-20210816161312070

属性

Charts 组件Props

参数 说明 类型 默认值
width 图表整体宽度 String 300px
height 图表整体高度 String 300px
loading 加载状态 Boolean false
loadingText 加载状态文本 String 加载中...
empty 空状态 Boolean false
emptyText 空状态文本 String 暂无数据
autoSelect 图表项自动选中 Boolean false
chartExpandAttrs 图表拓展属性,请参考官网 配置项 Object
preventRender 自定义渲染 Boolean false

Charts 组件 Event

名称 说明 回调参数
on-render 获取echarts实例对象 charts
MIT License Copyright (c) 2021 谭上彪 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于 Vue2 和 ECharts5 封装的组件 展开 收起
JavaScript 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/qq1332783374/v2-charts.git
git@gitee.com:qq1332783374/v2-charts.git
qq1332783374
v2-charts
v2-charts
master

搜索帮助