Click here to Skip to main content
14,924,198 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
</script>
    <script type="text/javascript">
        $(document).ready(function () {
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "Services/HighchartService.asmx/FruitAnalysis2",
                data: "{}",
                totaldata: "{}",
                dataType: "json",
                success: function (Result) {
                    Result = Result.d;
                    var data = [];

                    var totaldata = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]; //this declaration is correct for multi dimensional array i want 12 rows and 5 columns
                    var datesofh = [];
                    var m = 0;

                    var hours = Result[0].Name;
                    var dateex = Result[0].date;
                    var datesArray = new Array();
                    datesArray.push(dateex);

                    for (var r in Result) {
                        if (dateex != Result[r].date) {
                            dateex = Result[r].date;
                            datesArray.push(dateex);
                        }
                    }
                    for (var j in datesArray) {
                        for (var i in Result) {

                            if (i == 0) {

                            }
                            else {
                                m++;

                            }

                            var ser1 = new Array(Result[i].date);
                            if (datesArray[j] == Result[i].date) {
                                var serie = new Array(Result[i].Name, Result[i].Value, Result[i].date);
                                totaldata[j][m] = serie;  //here i didnt get multiple columns
                            }
                        }
                        m = 0;

                    }


                    DreawChart2(totaldata, datesArray);
                },
                error: function (Result) {
                    alert("Error");
                }
            });
        });


        function DreawChart2(series, data1) {
            var seriesk = [];
            var dataarray = [{}, {}, {}, {}, {}, {}, {}, {}];
            var r = 0;
            for (var i in data1) {
                for (var j = 0; j < 17; j++) {
                     dataarray[i][j] = series[i][j];  //here also i got  first row data how can i retrieve second and third rows 
                }
                seriesk.push({ name: data1[i],
                    data:dataarray[i][j] // here how to run a loop for j value
                });
            }

            $('#container2').highcharts({
                chart: {
                    type: 'column'
                },
                title: {
                    text: 'Day Print _ Hourly _ Sales'
                },

                plotOptions: {
                    column: {
                        dataLabels: {
                            enabled: false
                        }
                    }
                },
                credits: {
                    enabled: false
                },
                series: seriesk
            });
        }
Posted
Updated 6-Jul-15 22:33pm
v4
Comments
   
What do you mean by "high charts"? What arrays? What's the problem?
—SA
venkanna t 7-Jul-15 4:12am
   
high charts like a line chart and pie charts etc. how to declare multi dimensional array in the above program. my problem is not insert the data into multi dimensional array. its taken only one row

1 solution

C#
</script>
    <script type="text/javascript">
        $(document).ready(function () {
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "Services/HighchartService.asmx/FruitAnalysis2",
                data: "{}",
                totaldata: "{}",
                dataType: "json",
                success: function (Result) {
                    Result = Result.d;
                    var data = [];

                    var totaldata = []; 
                    var datesofh = [];
                    var m = 0;

                    var hours = Result[0].Name;
                    var dateex = Result[0].date;
                    var datesArray = new Array();
                    datesArray.push(dateex);

                    for (var r in Result) {
                        if (dateex != Result[r].date) {
                            dateex = Result[r].date;
                            datesArray.push(dateex);
                        }
                    }
                    for (var j in datesArray) {
                        for (var i in Result) {

                            if (i == 0) {

                            }
                            else {
                                m++;

                            }

                            var ser1 = new Array(Result[i].date);
                            if (datesArray[j] == Result[i].date) {
                                totaldata[j]=[];  //here created the two dimentional array
                                var serie = new Array(Result[i].Name, Result[i].Value, Result[i].date);
                                totaldata[j][m] = serie; 
                            }
                        }
                        m = 0;

                    }


                    DreawChart2(totaldata, datesArray);
                },
                error: function (Result) {
                    alert("Error");
                }
            });
        });



I can get this
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900