最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序圖表插件(wx-charts)實例代碼

 更新時間:2017年01月17日 09:02:49   作者:xiaolin3303  
這篇文章主要介紹了微信小程序圖表插件(wx-charts)實例代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下。

微信小程序圖表工具,charts for WeChat small app

基于canvas繪制,體積小巧

支持圖表類型

  • 餅圖 pie
  • 圓環(huán)圖 ring
  • 線圖 line
  • 柱狀圖 column
  • 區(qū)域圖 area
  • 代碼分析 Here

參數(shù)說明

opts Object

opts.canvasId String required 微信小程序canvas-id

opts.width Number required canvas寬度,單位為px

opts.height Number required canvas高度,單位為px

opts.title Object (only for ring chart)

opts.title.name String 標題內(nèi)容

opts.title.fontSize Number 標題字體大?。蛇x,單位為px)

opts.title.color String 標題顏色(可選)

opts.subtitle Object (only for ring chart)

opts.subtitle.name String 副標題內(nèi)容

opts.subtitle.fontSize Number 副標題字體大小(可選,單位為px)

opts.subtitle.color String 副標題顏色(可選)

opts.animation Boolean default true 是否動畫展示

opts.legend Boolen default true 是否顯示圖表下方各類別的標識

opts.type String required 圖表類型,可選值為pie, line, column, area, ring

opts.categories Array required (餅圖、圓環(huán)圖不需要) 數(shù)據(jù)類別分類

opts.dataLabel Boolean default true 是否在圖表中顯示數(shù)據(jù)內(nèi)容值

opts.dataPointShape Boolean default true 是否在圖表中顯示數(shù)據(jù)點圖形標識

opts.xAxis Object X軸配置

opts.xAxis.disableGrid Boolean default false 不繪制X軸網(wǎng)格

opts.yAxis Object Y軸配置

opts.yAxis.format Function 自定義Y軸文案顯示

opts.yAxis.min Number Y軸起始值

opts.yAxis.max Number Y軸終止值

opts.yAxis.title String Y軸title

opts.yAxis.disabled Boolean default false 不繪制Y軸

opts.series Array required 數(shù)據(jù)列表

數(shù)據(jù)列表每項結(jié)構(gòu)定義

dataItem Object

dataItem.data Array required (餅圖、圓環(huán)圖為Number) 數(shù)據(jù)

dataItem.color String 例如#7cb5ec 不傳入則使用系統(tǒng)默認配色方案

dataItem.name String 數(shù)據(jù)名稱

dateItem.format Function 自定義顯示數(shù)據(jù)內(nèi)容

Example

pie chart

var wxCharts = require('wxcharts.js');
new wxCharts({
 canvasId: 'pieCanvas',
 type: 'pie',
 series: [{
  name: 'cat1',
  data: 50,
 }, {
  name: 'cat2',
  data: 30,
 }, {
  name: 'cat3',
  data: 1,
 }, {
  name: 'cat4',
  data: 1,
 }, {
  name: 'cat5',
  data: 46,
 }],
 width: 360,
 height: 300,
 dataLabel: true
});

pieChart

pieChart

ring chart

new wxCharts({
 canvasId: 'ringCanvas',
 type: 'ring',
 series: [{
  name: '成交量1',
  data: 15,
 }, {
  name: '成交量2',
  data: 35,
 }, {
  name: '成交量3',
  data: 78,
 }, {
  name: '成交量4',
  data: 63,
 }],
 width: 320,
 height: 200,
 dataLabel: false
});

pieChart

pieChart

line chart

new wxCharts({
 canvasId: 'lineCanvas',
 type: 'line',
 categories: ['2012', '2013', '2014', '2015', '2016', '2017'],
 series: [{
  name: '成交量1',
  data: [0.15, 0.2, 0.45, 0.37, 0.4, 0.8],
  format: function (val) {
   return val.toFixed(2) + '萬';
  }
 }, {
  name: '成交量2',
  data: [0.30, 0.37, 0.65, 0.78, 0.69, 0.94],
  format: function (val) {
   return val.toFixed(2) + '萬';
  }
 }],
 yAxis: {
  title: '成交金額 (萬元)',
  format: function (val) {
   return val.toFixed(2);
  },
  min: 0
 },
 width: 320,
 height: 200
});

lineChart

lineChart

columnChart

new wxCharts({
 canvasId: 'columnCanvas',
 type: 'column',
 categories: ['2012', '2013', '2014', '2015', '2016', '2017'],
 series: [{
  name: '成交量1',
  data: [15, 20, 45, 37, 4, 80]
 }, {
  name: '成交量2',
  data: [70, 40, 65, 100, 34, 18]
 }],
 yAxis: {
  format: function (val) {
   return val + '萬';
  }
 },
 width: 320,
 height: 200
});

columnChart

columnChart

areaChart

new wxCharts({
 canvasId: 'areaCanvas',
 type: 'area',
 categories: ['2016-08', '2016-09', '2016-10', '2016-11', '2016-12', '2017'],
 series: [{
  name: '成交量1',
  data: [70, 40, 65, 100, 34, 18],
  format: function (val) {
   return val.toFixed(2) + '萬';
  }
 }, {
  name: '成交量2',
  data: [15, 20, 45, 37, 4, 80],
  format: function (val) {
   return val.toFixed(2) + '萬';
  }
 }],
 yAxis: {
  format: function (val) {
   return val + '萬';
  }
 },
 width: 320,
 height: 200
});

areaChart

areaChart

demo下載地址:demo

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

阳江市| 大姚县| 连州市| 佛教| 上高县| 汕尾市| 临泉县| 鄄城县| 静宁县| 天台县| 佛教| 磴口县| 丹东市| 乌海市| 辽宁省| 济南市| 页游| 元谋县| 塔河县| 绥江县| 永嘉县| 尼勒克县| 宁德市| 屯留县| 莱西市| 新河县| 江孜县| 朝阳市| 德庆县| 廉江市| 南乐县| 宜春市| 兴仁县| 磴口县| 开封市| 扶绥县| 广南县| 望都县| 交城县| 溆浦县| 巨鹿县|