我想在这些莫里斯图中显示x轴的日期和月份。 第一个月和第二个月。 我现在得到的只是0和周三。 有没有人对我如何解决这个问题有任何好的想法?
以下是代码:
<script type="text/javascript">
$.getScript('/assets/javascripts/raphael-min.js',function(){
$.getScript('/assets/javascripts/morris.min.js',function(){
var donutData = [];
var monthLineData = [];
var yearLineData = [];
@for((activity, steps) <- morrisDonut) {
donutData.push({label: '@activity', value: @steps});
}
@for(steps <- monthLineData) {
if(@monthLineData.indexOf(steps) > 0) {
monthLineData.push({ y:
'@{var day = Calendar.getInstance(); day.add(Calendar.DATE, -(30 - yearLineData.indexOf(steps))); day.getTime().format("EEEE");}',
a: @steps, b: @{goals(0).steps/7} });
} else {
monthLineData.push({ y: '0', a: @steps, b: @{goals(0).steps/7} });
}
}
@for(steps <- yearLineData) {
yearLineData.push({ y: '@yearLineData.indexOf(steps)', a: @steps, b: @goals(1).steps });
}
Morris.Donut({
element: 'user_activity-donut',
data: donutData
});
Morris.Line({
element: 'month_step-line',
data: monthLineData,
xkey: 'y',
ykeys: ['a', 'b'],
labels: ['Steps achieved', 'Goal'],
lineColors: ['#404080', '#000000'],
pointSize: 0,
parseTime: false
});
Morris.Line({
element: 'year_step-line',
data: yearLineData,
xkey: 'y',
ykeys: ['a', 'b'],
labels: ['Steps achieved', 'Goal'],
lineColors: ['#004080', '#000000'],
pointSize: 0,
parseTime: false
});
});
});
</script>