【问题标题】:High chart is not getting populated高图表未填充
【发布时间】:2015-05-21 10:16:52
【问题描述】:

我是 highchart 的新手,我开始学习,我试图在 html 中显示简单的饼图,但它不起作用。在我看来一切都很好,我不知道出了什么问题。 highchart 没有被填充。

jsfiddle link

<!DOCKTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Final</title>
		<!--Bootstrap source start-->
		<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
		<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
		<!--Bootstrap source end-->
		
		<!--highchart source start-->
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
		<script src="C:\Users\Global Soft\Desktop\HighChart\js\highcharts.js" type="text/javascript"></script>
		<script src="http://code.highcharts.com/modules/exporting.js" type="text/javascript"></script>
		<!--highchart source end--> 
		
		
		<!--Charts starts here-->
		<script type="text/javascript">
		$(function (){
			var charti;
			$(document).ready(function(){
				charti=new Highcharts.Chart({
					chart:{
                        renderTo:'pie',
						plotBackgroundColor:null,
						plotBorderWidth:null,
						plotShadow:false		
					},
					
					title:{
						text:'Browser market shares at a specific website, 2014'
					},
					
					subtitle:{
						text: ' Pie Chart'
					},
					tooltip: {
						pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
					},
					plotOptions: {
						pie: {
							allowPointSelect: true,		
							cursor: 'pointer',
							dataLabels: {
								enabled: false		
								
							},
							showInLegend: true
						}
					},
					
					series:[{
						type:'pie',
						name:'Browser share',
						data:[
							['Firefox',45.0],
							['IE',26.8],
							{
								name:'Chrome',
								y:12.8,
								sliced:true,
								selected:true
							},
							['Safari',	8.5],
							['Opera',	6.2],
							['Others',  0.7]
						]
										
					}]
				
					
			});
			
		});	
	});
			

	</head>
	
	<body>
		
		<div class="container">
			<h1 align="center"><a href ="#">Different charts in one page</a></h1>
			<!--First chart-->
					<div class="col-md-6">		
						<div id="pie" style="min-width: 300px; height: 300px; margin: 30 auto"></div>		
					</div>
			
		</div>
	</body>
</html>

【问题讨论】:

  • 我认为你通往 Highcharts 的道路是错误的。打开 JavaScript 控制台(Web 开发人员工具)并检查错误。并且 jsFiddle 不起作用,因为您没有包含 Highcharts 和 jQuery。
  • 我同意,但在我的 html 代码中,我已经包含了 highchart,虽然它不起作用
  • 看看小提琴jsfiddle.net/e1v1kq1m 我想这就是你要找的。我刚刚更新了你的。

标签: jquery html highcharts


【解决方案1】:

如果你得到了通往高图的正确路径,它应该可以工作。我添加了这个,效果很好

<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>

【讨论】:

  • 对不起,它真的不起作用,我已经下载了 highchart 并给出了正确的路径。但它仍然不起作用,请让它更清楚
  • 当我将它包含到我的代码中时,我在控制台中收到文件未找到错误
  • 未捕获的 TypeError:无法读取未定义的 exporting.js 的属性“addEvent”:9 未捕获的类型错误:无法读取未定义的 highcharts.js 的属性“fireEvent”:13 未捕获的 Highcharts 错误 #16:www.highcharts。 com/errors/16 exporting.js:9 Uncaught TypeError: Cannot read property 'fireEvent' of undefined
  • 删除您的包含并添加提到的包含,它应该可以工作。我不知道你为什么会收到这个错误。
  • 出了什么问题?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多