1 Star 2 Fork 1

huyongjie / CHCharts-wechat

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

在微信小程序中使用 CHCharts

本项目是基于微信小程序开发的图表插件,以及使用的示例。

开发者可以通过微信组件化方式配置 CHCharts,快速开发图表,满足各种可视化需求。

Demo 展示

使用 CHCharts

首先,下载本项目。

其中,ch-canvas 是我们提供的组件,其他文件是如何使用该组件的示例。

引入组件

微信小程序的项目创建可以参见微信公众平台官方文档

在创建项目之后,拷贝 ch-canvas 目录到新建的项目下,然后做相应的调整。

具体可以参考 pages/rose 目录下的几个文件的写法。下面,我们具体地说明。

创建图表

首先,在 pages/rose 目录下新建以下几个文件:rose.jsrose.jsonrose.wxmlrose.wxss。并且在 app.json

pages 中增加 'pages/rose/rose'

rose.json 配置如下:

{
  "usingComponents": {
    "ch-canvas": "../../ch-canvas/ch-canvas"
  }
}

然后,pages/rose/rose.wxml 中使用 <ch-canvas> 组件。

rose.wxml 中:

<view class='container'>
  <ch-canvas canvasId='rose' id='rose'></ch-canvas>
</view>

最后,在 rose.js 中配置相关参数、数据就可以在页面中显示出图表了。

rose.js 配置如下:

var data = [
  { name: '甜甜圈', value: 50, color: '#80e0ed' },
  { name: '冰淇淋', value: 40, color: '#9197ed' },
  { name: '棒棒糖', value: 30, color: '#eddf5c' },
  { name: '奶茶', value: 60, color: '#e4ff99' },
  { name: '抹茶蛋糕', value: 50, color: '#baffad' },
  { name: '蛋挞', value: 20, color: '#afee9d' }
]

Page({
  onLoad: function(options) {
    var options = {
      data: data,
      legend: '{c}',
      chartRatio: 0.95,
      style: 'rose',
      showLegend: true,
      showLabel: true,
      animation: true
    }
    this.roseComp = this.selectComponent('#rose')
    this.roseComp.setOptions(options)
    this.roseComp.initChart(320, 213)
  }
})

最近更新(v2.0.2)

  1. 坐标轴新增 xWordsCnt 和 xRows 参数,开发者可以通过它们调节坐标轴文字显示范围 。
  2. 修复已知 bug。
MIT License Copyright (c) 2018 disciple 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.

简介

A charts component for WeChat mini-app development(一款用于微信小程序开发中的图表组件,使用者可以快速添加并集成到微信小程序开发中). 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/hyjweb/CHCharts-wechat.git
git@gitee.com:hyjweb/CHCharts-wechat.git
hyjweb
CHCharts-wechat
CHCharts-wechat
master

搜索帮助