Commit ef685421 by 姜雷

修复储值视图数据少于4条时无法显示问题

parent 08a0d137
...@@ -244,11 +244,12 @@ export default { ...@@ -244,11 +244,12 @@ export default {
updateSlider() { updateSlider() {
this.sliderDom.innerHTML = ''; this.sliderDom.innerHTML = '';
const arrLength = this.data.length; const arrLength = this.dataList.length;
console.log('2222', this.data.length - 1); let start = this.dataList.length - 4 >= 0 ? this.dataList.length - 4 : 0;
let end = this.dataList.length - 1 >= 1 ? this.dataList.length - 1 : 1;
// console.log('2222', this.dataList.length - 1, start, end);
if (arrLength) { if (arrLength) {
// let spanNum = 4 / arrLength;
this.slider = new Slider({ this.slider = new Slider({
container: this.sliderDom, container: this.sliderDom,
width: 26, width: 26,
...@@ -266,8 +267,8 @@ export default { ...@@ -266,8 +267,8 @@ export default {
}, },
}, },
}, },
start: this.data.length - 4, start: start,
end: this.data.length - 1, end: end,
minSpan: 4, minSpan: 4,
maxSpan: 4, maxSpan: 4,
data: this.dataList, data: this.dataList,
...@@ -291,16 +292,18 @@ export default { ...@@ -291,16 +292,18 @@ export default {
if (this.chart) { if (this.chart) {
const arrLength = this.data.length; const arrLength = this.data.length;
let spanNum = 4 / arrLength; let spanNum = 4 / arrLength;
let start =
this.dataList.length - 4 >= 0 ? this.dataList.length - 4 : 0;
let end = this.dataList.length - 1 >= 1 ? this.dataList.length - 1 : 1;
this.ds.setState('start', this.data.length - 4); this.ds.setState('start', start);
this.ds.setState('end', this.data.length - 1); this.ds.setState('end', end);
this.dv.source(this.dataList); this.dv.source(this.dataList);
// let height = this.data.length * 50; // let height = this.data.length * 50;
// this.chart.changeHeight(height); // this.chart.changeHeight(height);
this.updateSlider(); this.updateSlider();
this.updateData(); this.updateData();
console.log(this.chart.getYScales()); console.log(this.chart.getYScales());
} else { } else {
this.initData(); this.initData();
this.initSlider(); this.initSlider();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment