如何在asp.net的highchart中打印json数据

时间:2015-09-18 07:48:20

标签: javascript asp.net json highcharts

<script type="text/javascript">

        $(document).ready(function () {
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: '../../GetJSONservice.asmx/BindMenu',
                data: "{}",
                dataType: "json",
                success: function (response) {
                    if (response.d != null) {
                        var xCategories = [];
                        var xCategories1 = [];
                        var processed_json = new Array();
                        var p = response.d[0].Name;
                        var p1 = response.d[0].value1;
                        var k = p.split(',');
                        var k1 = p1.split('},');

                        var i, cat, value, j;
                        for (i = 0; i < k.length; i++) {

                            cat = k[i];
                            xCategories[xCategories.length] = cat;

                        }

                        for (j = 0; j < k1.length - 1; j++) {

                            value = k1[j] + "}";
                            xCategories1[xCategories1.length] = value;

                        }

                        options.series[0].setData(data);
                        $(function () {
                            $('#<%=dvlicensekeysTitle.ClientID%>').highcharts({
                                chart: {
                                    type: 'column',
                                    margin: 75,
                                    options3d: {
                                        enabled: true,
                                        alpha: 15,
                                        beta: 0,
                                        depth: 50,
                                        viewDistance: 25
                                    }
                                },
                                title: {
                                    text: 'Total Classification With User'

                                },
                                subtitle: {
                                    text: ''
                                },
                                xAxis: {

                                    categories: xCategories,
                                    crosshair: true
                                },
                                yAxis: {
                                    min: 0,
                                    title: {
                                        text: 'Classification'
                                    }
                                },

                                plotOptions: {
                                    series: {
                                        cursor: 'pointer',
                                        point: {
                                            events: {
                                                click: function () {

                                                    window.location.href = '../Log/LogDisplayData.aspx?id=5&&days=1&&ReportName=Total Classification With User Report&&Value=' + this.category + '&&SeriseName=' + this.series.name;

                                                }
                                            }
                                        }
                                    }
                                },
                               series: [xCategories1]
                            });
                        });

                    }

                },
                complete: function (response) {

                }
            });
        });

    </script>

并且响应就像那样

{ 'name': 'Confidential', 'data': [0, 0, 0, 0, 0, ] }, { 'name': 'External Source', 'data': [0, 0, 0, 0, 0, ] }, { 'name': 'Internal', 'data': [0, 0, 0, 0, 0, ] }, { 'name': 'Public', 'data': [0, 0, 0, 0, 0, ] }, { 'name': 'Secret', 'data': [0, 0, 0, 0, 0, ]}

0 个答案:

没有答案