javascript - 如何显示多行的 Highcharts ?

标签 javascript c# highcharts asp.net-mvc-5

我有一个列表名称 aaa。这是列表的列表

aaa[0] = [[{'a',1},{'b',2}]

aaa[1] = [[{'q',2},{'bd',0}]

aaa[2] = [[{'sa',3},{'bs',6}]

aaa[2] = [[{'sa',5},{'vb',8}]

我收到了模型的回复

现在我需要将该值填充到图表中 我的图表将包含四行 aaa[0]aaa[1]aaa[2]aaa[3]

这是我的 Highcharts 代码

<script>
    $(document).ready(function () {

        //Default time zone
        moment.tz.setDefault("America/New_York");

        // Global option to disable UTC time usage
        Highcharts.setOptions({
            global: {
                useUTC: false
            }
        });

        // Chart configurations
        var options = {
            chart: {
                renderTo: 'container2',
                type: 'area',
                marginRight: 45,
                zoomType: 'x'
            },
            title: {
                text: 'aaaa'
            },
            xAxis: {

                type: 'datetime',
                minRange: 8 * 24 * 3600000,
                labels: {
                    format: '{value:%m-%d-%Y}',
                    rotation: 45

                }


            },
            yAxis: {
                title: {
                    text: 'count'
                },
                labels: {
                    formatter: function () {
                        return this.value;
                    }
                }
            },

            plotOptions: {
                area: {
                    marker: {
                        enabled: true,
                        symbol: 'circle',
                        radius: 2,
                        states: {
                            hover: {
                                enabled: true
                            }
                        }
                    },
                    lineWidth: 1,
                    threshold: null
                }
            },
            series: [{
                fillOpacity: 0.1,
                name: 'aaa',
                pointInterval: 24 * 3600 * 1000,
                pointStart: 1375295400000,
                data: GetPercentage()

            }]
        };

        // Rendering the Highcharts
        chart = new Highcharts.Chart(options);


         function GetPercentage() {

            var data = @Html.Raw(JsonConvert.SerializeObject(Model.aaa));

            //  alert(data)

            @foreach(var val in Model.aaa) //loop of getting a list from aaa
            {

                     var percentages = [];


                for (var x = 0; x < @val.Count; x++)
                {                                 
                     //Here I need to push the list 

                }
                //percentages.sort(SortByDate);
                // return percentages;
            }
        }

        //Sort the array based on first array element
        function SortByDate(a,b){
            //alert(a[0] +" - " +b[0]);
            return (a[0] - b[0]);
        }


        //Timeout function to reload page on everyone hour
        setTimeout(function () {
            location.reload(true);
        }, 60* 60 * 1000);

        //Progress bar to display feed delivery percentage
        $('.progress .progress-bar').progressbar({
            transition_delay: 500,
            display_text: 'fill',
            refresh_speed: 500
        });
    });
</script>

有人可以帮我显示一个四线图表吗?

提前致谢

最佳答案

这里可以看到该系列是一个对象数组

$(function () { 
$('#container').highcharts({
    chart: {
        type: 'bar'
    },
    title: {
        text: 'Fruit Consumption'
    },
    xAxis: {
        categories: ['Apples', 'Bananas', 'Oranges']
    },
    yAxis: {
        title: {
            text: 'Fruit eaten'
        }
    },
    series: [{
        name: 'Jane',
        data: [1, 0, 4]
    }, {
        name: 'John',
        data: [5, 7, 3]
    }]
});

});

您应该将更多对象添加到系列数组中以创建多条线。

关于javascript - 如何显示多行的 Highcharts ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30994601/

相关文章:

c# - 以编程方式设置和保存与导入 Assets 关联的图标

javascript - 如何执行日期范围以查看选定日期 Highcharts 中的数据

php - 为 Highcharts 使用重组数组

javascript - 调整最小图像尺寸

c# - sendgrid 中的替换问题

c# - 编辑现有的 Excel 文件 C# npoi

javascript - HighCharts 插件 JQuery

javascript - 如果 ajax 返回时没有焦点,jquery ui 自动完成不会关闭选项菜单

javascript - 阻止jquery函数被自动调用

javascript - Knockoutjs observable 和 jQuery extends 函数