duplicate month data into stack in morris bar chart
Asked Answered
H

1

7

how to push data into stack of morris bar chart, if come multiple similar month data from ajax call from different account this is my code:

DashboardService.getGraphForYear(year).success(function (data) {
    $scope.count = data.results_count;
    for(var j=0;j< $scope.count;j++)
    {
       $scope.month = data.results[j].month;
        switch ($scope.month) {
            case 1:
                sales_com_year.push({month:month[1],amount:data.results[j].order_total_amount});
                break;
            case 2: sales_com_year.push({month:month[2],amount:data.results[j].order_total_amount});
                break;
         }
    }

  }).error(function (error) });

How to push data into if come January so all data push into as a stack into January as well for all month

Housum answered 24/7, 2014 at 5:38 Comment(5)
What? Sorry, but I don't understand.Lenin
Please ask your question clearly, if any.Homburg
For what I understood, you want to add columns for January instead of adding them one another... Check this example: jsbin.com/uzosiq/258/embed?js,output I think you should get ALL data from one month and then use the push but you need to specify a different column... in the example A or B You can see in my example, I added column C in the same year: jsbin.com/conafadevu/1/edit?html,js,outputDentilabial
So you want to accumulate data from any other month into January as well? Your question is hard to interpret.Chaworth
also in sales_com_year.push({month:month[1],amount:data.results[j].order_total_amount}); month is not defined.Inanimate
T
0

You have to create list that have date and value pair push into an array

                var myJSON = [];
                $.each(YourList, function (i, item) {

                    var jsonArray = { year: item.Date, value: item.value };
                    var temp = jsonArray;
                    myJSON.push(temp);

                });

and internalize Morris.Area with following parameters.

                Morris.Area({
                    element: 'chart',
                    xLabelMargin: 10,
                    xLabelAngle: 60,
                    parseTime: false,
                    data: myJSON,
                    xkey: 'year',
                    ykeys: ['value'],
                    labels: ['Your Lable'],
                    lineColors: ['red'],
                    pointFillColors: ['#ffffff'],
                    pointStrokeColors: ['black'],
                });
Tobytobye answered 11/9, 2015 at 12:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.