At present, there is only `1min` of simulation data, and there is no effect of switching between `time` line and `non-1min` line
new Vue({
el: '#module',
template: '<kline ref="kline"' +
' :isMobile="isMobile"' +
' :data="data"' +
' :loading="loading"' +
' :period.sync="period"' +
' @getMorePreData="getMorePreData"></kline>',
components: { kline: Kline },
data: function () {
return {
data: [],
isMobile: window.isMobile,
period: {},
loading: false
}
},
watch: {
period: function (val, oldVal) {
console.log('periodChange', val)
if (oldVal.value) {
this.loading = true
var that = this
setTimeout(function () {
that.loading = false
}, 1000)
}
}
},
methods: {
getMorePreData: function () {
console.log('getMorePreData')
this.loading = true
var that = this
setTimeout(function () {
that.loading = false
}, 1000)
}
},
beforeMount: function () {
this.loading = true
var that = this
setTimeout(function () {
that.data = klineData
that.loading = false
setInterval(function () {
var index = that.data.length - 1
var prices = that.data[index].concat([])
prices[4] = +(that.data[index][4] + 0.01).toFixed(2)
prices[2] = Math.max(prices[2], prices[4])
prices[3] = Math.min(prices[3], prices[4])
that.data = that.data.slice(0, index).concat([prices])
}, 3000)
}, 1500)
this.$nextTick(function () {
this.$refs.kline.setLang('en')
})
}
})