You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
936 B

3 years ago
// word-cloud/index.js
const {
WordCloud
} = require("./WordCloud.js")
Component({
/**
* 组件的属性列表
*/
properties: {
list: {
type: Array,
value: [],
},
height: {
type: String,
value: "200"
},
width: {
type: String,
value: ""
},
color: {
type: String,
value: "random-light"
},
},
data: {
spans: []
},
ready() {
let that = this;
this.ctx = wx.createCanvasContext('canvas', this);
let query = this.createSelectorQuery();
query.select("#canvas").boundingClientRect(function (res) {
WordCloud(that.ctx, res, {
minSize: 8,
list: that.data.list,
color: that.data.color
}, that, function (val) {
that.data.spans.push(val)
// w.to_file("../../images/carSide.png")
that.setData({
spans: that.data.spans
})
})
}).exec();
}
})