scala - Morris graph, edit x-axis to display date and month -
i want display date , month in x-axis in these morris graphs. date in first , month in second. i'm getting 0's , wednesdays. have ideas how can fix this?
here code:
<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>
Comments
Post a Comment