Highcharts 海图不显示

Highcharts 海图不显示,highcharts,Highcharts,我正在使用highcharts创建一个简单的图表。图表似乎没有显示出来。 坚持了几个小时,我不知道出了什么问题。有什么我遗漏的吗?这里需要帮助 <script type="text/javascript"> function renderChart(divId, chartType, chartTitle, chartData, categories){ var options = createOption(divId, chartType,

我正在使用highcharts创建一个简单的图表。图表似乎没有显示出来。 坚持了几个小时,我不知道出了什么问题。有什么我遗漏的吗?这里需要帮助

<script type="text/javascript">
        function renderChart(divId, chartType, chartTitle, chartData, categories){
            var options = createOption(divId, chartType, chartTitle, categories);
            options.series = $.parseJSON(chartData);
            var chart = new Highcharts.Chart(options);
        }

        function createOption(divId, chartType, chartTitle, categories){
            var options = {
                colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4'],
                chart: {
                    backgroundColor: {
                        linearGradient: [0, 0, 500, 500],
                        stops: [
                            [0, 'rgb(255, 255, 255)'],
                            [1, 'rgb(240, 240, 255)']
                        ]
                    },
                    borderWidth: 2,
                    plotBackgroundColor: 'rgba(255, 255, 255, .9)',
                    plotShadow: true,
                    plotBorderWidth: 1,
                    renderTo: divId,
                    type: chartType
                },
                title: {
                    text: 'JVM Heap Memory Usage Chart',
                    style: {
                        color: '#000',
                        font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
                    }
                },
                subtitle: {
                    text: 'Source: http://java-bytes.blogspot.com',
                    style: {
                        color: '#666666',
                        font: 'bold 12px "Trebuchet MS", Verdana, sans-serif'
                    }
                },
                xAxis: {
                    ridLineWidth: 1,
                    lineColor: '#000',
                    tickColor: '#000',
                    categories: $.parseJSON(categories),
                    labels: {
                        style: {
                            color: '#000',
                            font: '11px Trebuchet MS, Verdana, sans-serif'
                        },
                        formatter: function() {
                            return this.value;
                        }
                    },
                    title: {
                        style: {
                            color: '#333',
                            fontWeight: 'bold',
                            fontSize: '12px',
                            fontFamily: 'Trebuchet MS, Verdana, sans-serif'

                        }
                    }
                },
                yAxis: {
                    minorTickInterval: 'auto',
                    lineColor: '#000',
                    lineWidth: 1,
                    tickWidth: 1,
                    tickColor: '#000',
                    title: {
                        style: {
                            color: '#333',
                            fontWeight: 'bold',
                            fontSize: '12px',
                            fontFamily: 'Trebuchet MS, Verdana, sans-serif'
                        },
                        text: 'Heap Memory Usage'
                    },
                    labels: {
                        formatter: function() {
                            return this.value +'MB';
                        },
                        style: {
                            color: '#000',
                            font: '11px Trebuchet MS, Verdana, sans-serif'
                        }
                    }
                },
                plotOptions: {
                    area: {
                        stacking: 'normal',
                        lineColor: '#666666',
                        lineWidth: 1,
                        marker: {
                            lineWidth: 1,
                            lineColor: '#666666'
                        }
                    }
                },
                tooltip: {
                    formatter: function() {
                        return ''+ this.x +': '+ Highcharts.numberFormat(this.y, 0, ',') +' MB';
                    }
                },
                legend: {
                    itemStyle: {
                        font: '9pt Trebuchet MS, Verdana, sans-serif',
                        color: 'black'

                    },
                    itemHoverStyle: {
                        color: '#039'
                    },
                    itemHiddenStyle: {
                        color: 'gray'
                    }
                },
                labels: {
                    style: {
                        color: '#99b'
                    }
                },
                series: []
            };

            return options;
        };
    </script>

<h1>Highcharts</h1>
    <p:commandButton oncomplete="renderChart('container','area','Sample Chart','${pc_Test.chartData}', '${pc_Test.categories}');" action="#{pc_Test.loadChartData}" id="chartvalue_btn">
        <div id="container" style="width: 100%; height: 500px"></div>
    </p:commandButton>
xhtml

<script type="text/javascript">
        function renderChart(divId, chartType, chartTitle, chartData, categories){
            var options = createOption(divId, chartType, chartTitle, categories);
            options.series = $.parseJSON(chartData);
            var chart = new Highcharts.Chart(options);
        }

        function createOption(divId, chartType, chartTitle, categories){
            var options = {
                colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4'],
                chart: {
                    backgroundColor: {
                        linearGradient: [0, 0, 500, 500],
                        stops: [
                            [0, 'rgb(255, 255, 255)'],
                            [1, 'rgb(240, 240, 255)']
                        ]
                    },
                    borderWidth: 2,
                    plotBackgroundColor: 'rgba(255, 255, 255, .9)',
                    plotShadow: true,
                    plotBorderWidth: 1,
                    renderTo: divId,
                    type: chartType
                },
                title: {
                    text: 'JVM Heap Memory Usage Chart',
                    style: {
                        color: '#000',
                        font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
                    }
                },
                subtitle: {
                    text: 'Source: http://java-bytes.blogspot.com',
                    style: {
                        color: '#666666',
                        font: 'bold 12px "Trebuchet MS", Verdana, sans-serif'
                    }
                },
                xAxis: {
                    ridLineWidth: 1,
                    lineColor: '#000',
                    tickColor: '#000',
                    categories: $.parseJSON(categories),
                    labels: {
                        style: {
                            color: '#000',
                            font: '11px Trebuchet MS, Verdana, sans-serif'
                        },
                        formatter: function() {
                            return this.value;
                        }
                    },
                    title: {
                        style: {
                            color: '#333',
                            fontWeight: 'bold',
                            fontSize: '12px',
                            fontFamily: 'Trebuchet MS, Verdana, sans-serif'

                        }
                    }
                },
                yAxis: {
                    minorTickInterval: 'auto',
                    lineColor: '#000',
                    lineWidth: 1,
                    tickWidth: 1,
                    tickColor: '#000',
                    title: {
                        style: {
                            color: '#333',
                            fontWeight: 'bold',
                            fontSize: '12px',
                            fontFamily: 'Trebuchet MS, Verdana, sans-serif'
                        },
                        text: 'Heap Memory Usage'
                    },
                    labels: {
                        formatter: function() {
                            return this.value +'MB';
                        },
                        style: {
                            color: '#000',
                            font: '11px Trebuchet MS, Verdana, sans-serif'
                        }
                    }
                },
                plotOptions: {
                    area: {
                        stacking: 'normal',
                        lineColor: '#666666',
                        lineWidth: 1,
                        marker: {
                            lineWidth: 1,
                            lineColor: '#666666'
                        }
                    }
                },
                tooltip: {
                    formatter: function() {
                        return ''+ this.x +': '+ Highcharts.numberFormat(this.y, 0, ',') +' MB';
                    }
                },
                legend: {
                    itemStyle: {
                        font: '9pt Trebuchet MS, Verdana, sans-serif',
                        color: 'black'

                    },
                    itemHoverStyle: {
                        color: '#039'
                    },
                    itemHiddenStyle: {
                        color: 'gray'
                    }
                },
                labels: {
                    style: {
                        color: '#99b'
                    }
                },
                series: []
            };

            return options;
        };
    </script>

<h1>Highcharts</h1>
    <p:commandButton oncomplete="renderChart('container','area','Sample Chart','${pc_Test.chartData}', '${pc_Test.categories}');" action="#{pc_Test.loadChartData}" id="chartvalue_btn">
        <div id="container" style="width: 100%; height: 500px"></div>
    </p:commandButton>

您是否收到任何错误,您解析的JSON是什么样子的?$。parseJSON(chartData);在这行中?您好,我认为它很可能被困在$.parseJSON(chartData)中的某个地方;和/或$.parseJSON(类别)。我们是否可以输出错误?我尝试了document.write($.parseJSON(chartData));但是它不打印任何东西当我第一次启动页面并单击按钮时,您可以使用console.log()并在控制台(firebug或Chrome控制台)中打印json,chartData和categories为空。当我重新启动页面并单击按钮后,图表显示出来。我怎样才能解决这个问题?有没有链接到live demo?由于没有代码/控制台,导致其难以调试