此代码适用于我们在用户个人资料中显示的图表。它是一个图表,显示特定日期范围(每周、每月、每年、生命周期)的统计数据。无论我们设置默认值的范围是什么,刻度线都会与数据点完美对齐。每当他们选择不同的间隔时,刻度线就不再排列。
图表的初始生成:
this.chartSpline = C3.generate({
bindto: '.splineChart',
colors:'#1BA39C',
data: {
xFormat: '%m-%d-%Y',
columns: [this.columns, this.rows],
type: 'area-spline',
x: 'Date',
},
padding: {
right: 100,
left: 100,
},
axis: {
x: {
type : 'timeseries',
tick:{
fit: true,
count: this.rows.length/2,
format: '%m/%d',
},
padding:{
left:0,
right: 10
}
},
y: {
padding:{
top:50,
bottom: 0
},
label: {
text: 'Minutes played',
position: 'outer-middle'
}
}
},
point: {
r: 8,
},
legend: {
show: false
}
});
上面的代码是在一个主干 View 中,然后我们加载另一个具有加载功能的主干 View 。当用户选择新的日期范围时,将调用加载函数:
this.plot.load({columns: [columns, rows]});
如果您能为我提供任何帮助,我将不胜感激。谢谢!
最佳答案
我删除了这段代码:
count: this.rows.length/2,
现在工作正常
关于javascript - C3 API 加载调用后刻度线未与数据对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43728166/