高架图绘制问题

Highchart drawing issue

本文关键字:问题 绘制 高架图      更新时间:2023-09-26

我在html文件中有以下代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<div id=0 style='width:400px; height:400px'></div>
<script type='text/javascript' src='https://dl.dropboxusercontent.com/u/93241685/jquery.1.9.1.min.js'></script>
<script type='text/javascript' src='https://dl.dropboxusercontent.com/u/93241685/highcharts.js'></script>
<script>
$(function () {
$('#0').highcharts({
chart: {type: 'area',plotBackgroundColor:'white',plotBorderWidth: '',plotShadow: true,zoomType:'undefined'},
title: {text:'TTT'},
xAxis: {title: {text:'trX'}},
yAxis: {title: {text:'Ygrg'}},
tooltip: {pointFormat: '{series.name}  {point.x}'},
});});
var chart = $('#0').highcharts();
chart.addSeries({
name: 'S1',
data: [1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6]
}, false);
chart.redraw();
</script>
</body>
</html>

当我运行这个,只有div显示与图表标题在顶部。别的什么也没有。甚至不显示xAxis标题或yAxis标题。现在,有趣的是,当我尝试在JSFiddle上运行它时,它完美地显示了图形。下面还提供了JSFiddle链接。什么可能是在一个html文件中做它的问题,我试着从文件中删除额外的比特,可能是一切,但仍然没有用。请帮助。

http://jsfiddle.net/5fway/

尝试将其包含在document.ready()中,因为在jsfiddle中,您指示运行代码jquery onload(如document.ready()),如下所示:

$(document).ready(function(){
  $('#0').highcharts({
    chart: {type: 'area',plotBackgroundColor:'white',plotBorderWidth: '',plotShadow: true,zoomType:'undefined'},
    title: {text:'TTT'},
    xAxis: {title: {text:'trX'}},
    yAxis: {title: {text:'Ygrg'}},
    tooltip: {pointFormat: '{series.name}  {point.x}'},
  });
  var chart = $('#0').highcharts();
  chart.addSeries({
    name: 'S1',
    data: [1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6]
  }, false);
  chart.redraw();
});