国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 課堂 > 小程序 > 正文

wx-charts 微信小程序圖表插件的具體使用

2020-03-21 15:15:51
字體:
供稿:網(wǎng)友

微信小程序圖表插件(wx-charts)基于canvas繪制,體積小巧,支持圖表類型餅圖、線圖、柱狀圖 、區(qū)域圖等圖表圖形繪制,目前wx-charts是微信小程序圖表插件中比較強大好使的一個

支持圖標類型

  • 餅圖 pie
  • 圓環(huán)圖 ring
  • 線圖 line
  • 柱狀圖 column
  • 區(qū)域圖 area
  • 雷達圖 radar

如何使用?

直接引用編譯好的文件 dist/charts.js(js下載地址) 

.wxml中定義

<canvas canvas-id="lineCanvas" disable-scroll="true" class="canvas"></canvas>

canvas-id與new wxCharts({canvasId:”})中canvasId一致

2. 命令行

git clone github.com/xiaolin3303/wx-charts.gitnpm install rollup -gnpm installrollup -c 或者 rollup --config rollup.config.prod.js

參數(shù)說明

opts             Objectopts.canvasId        String required          微信小程序canvas-idopts.width          Number required        canvas寬度,單位為pxopts.height         Number required        canvas高度,單位為pxopts.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     副標題字體大?。蛇x,單位為px)opts.subtitle.color     String     副標題顏色(可選)opts.animation        Boolean default true     是否動畫展示opts.legend         Boolen default true    是否顯示圖表下方各類別的標識opts.type          String required 圖表類型,可選值為pie, line, column, area……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軸titleopts.yAxis.disabled     Boolean default false    不繪制Y軸opts.series         Array required    數(shù)據(jù)列表

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

dataItem           ObjectdataItem.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)容

詳見demo(具體demo git地址)

1.pie

new wxCharts({  animation: true, //是否有動畫  canvasId: 'pieCanvas',  type: 'pie',  series: [{    name: '成交量1',    data: 15,  }, {    name: '成交量2',    data: 35,  }, {    name: '成交量3',    data: 78,  }],  width: windowWidth,  height: 300,  dataLabel: true, });}

wx-charts,微信小程序,圖表插件

2. ring

new wxCharts({  animation: true,  canvasId: 'ringCanvas',  type: 'ring',  extra: {    ringWidth: 25,    pie: {      offsetAngle: -45    }  },  title: {    name: '70%',    color: '#7cb5ec',    fontSize: 25  },  subtitle: {    name: '收益率',    color: '#666666',    fontSize: 15  },  series: [{    name: '成交量1',    data: 15,    stroke: false  }, {    name: '成交量2',    data: 35,     stroke: false  }, {    name: '成交量3',    data: 78,    stroke: false  }, {    name: '成交量4',    data: 63,     stroke: false  }],  disablePieStroke: true,  width: windowWidth,  height: 200,  dataLabel: false,  legend: false,  padding: 0});

wx-charts,微信小程序,圖表插件

3. line

new wxCharts({  canvasId: 'lineCanvas',  type: 'line',  categories: simulationData.categories,  animation: true,  background: '#f5f5f5',  series: [{    name: '成交量1',    data: simulationData.data,    format: function (val, name) {      return val.toFixed(2) + '萬';    }  }, {    name: '成交量2',    data: [2, 0, 0, 3, null, 4, 0, 0, 2, 0],    format: function (val, name) {      return val.toFixed(2) + '萬';    }  }],  xAxis: {    disableGrid: true  },  yAxis: {    title: '成交金額 (萬元)',    format: function (val) {      return val.toFixed(2);    },    min: 0  },  width: windowWidth,  height: 200,  dataLabel: false,  dataPointShape: true,  extra: {    lineStyle: 'curve'  }});

wx-charts,微信小程序,圖表插件

4. column

new wxCharts({  canvasId: 'columnCanvas',  type: 'column',  animation: true,  categories: chartData.main.categories,  series: [{    name: '成交量',    data: chartData.main.data,    format: function (val, name) {      return val.toFixed(2) + '萬';    }  }],  yAxis: {    format: function (val) {      return val + '萬';    },    title: 'hello',    min: 0  },  xAxis: {    disableGrid: false,    type: 'calibration'  },  extra: {    column: {      width: 15    }  },  width: windowWidth,  height: 200,});

wx-charts,微信小程序,圖表插件

5. area

new wxCharts({  canvasId: 'areaCanvas',  type: 'area',  categories: ['1', '2', '3', '4', '5', '6'],  animation: true,  series: [{    name: '成交量1',    data: [32, 45, 0, 56, 33, 34],    format: function (val) {      return val.toFixed(2) + '萬';    }  }, {   name: '成交量2',   data: [15, 20, 45, 37, 4, 80],   format: function (val) {    return val.toFixed(2) + '萬';   },  }],  yAxis: {    title: '成交金額 (萬元)',    format: function (val) {      return val.toFixed(2);    },    min: 0,    fontColor: '#8085e9',    gridColor: '#8085e9',    titleFontColor: '#f7a35c'  },  xAxis: {    fontColor: '#7cb5ec',    gridColor: '#7cb5ec'  },  extra: {    legendTextColor: '#cb2431'  },  width: windowWidth,  height: 200});

wx-charts,微信小程序,圖表插件

6.radar

new wxCharts({  canvasId: 'radarCanvas',  type: 'radar',  categories: ['1', '2', '3', '4', '5', '6'],  series: [{    name: '成交量1',    data: [90, 110, 125, 95, 87, 122]  }],  width: windowWidth,  height: 200,  extra: {    radar: {      max: 150    }  }});

wx-charts,微信小程序,圖表插件

本人是自己查閱資料自己整理,希望對自己和有問題的你們都有幫助,也希望大家多多支持VEVB武林網(wǎng)。


注:相關教程知識閱讀請移步到微信小程序開發(fā)頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 英吉沙县| 天祝| 香格里拉县| 金乡县| 梁平县| 烟台市| 罗城| 祁连县| 保康县| 新民市| 孝感市| 裕民县| 吉水县| 汉川市| 汕头市| 文水县| 岳阳县| 舟曲县| 宜兴市| 莫力| 金塔县| 辛集市| 岐山县| 潢川县| 大冶市| 常山县| 高雄市| 吉首市| 正镶白旗| 龙门县| 花莲市| 宁都县| 日喀则市| 霍山县| 随州市| 榆社县| 沧源| 平果县| 息烽县| 清水县| 凤庆县|