【发布时间】:2014-09-16 07:37:36
【问题描述】:
我正在做以下事情:
- 使用python django中的一些逻辑创建一个json文件
- 这个json文件现在被high chart js代码用来渲染饼图
highchart js 代码如下:
//高图json饼图
$(document).ready(function() {
console.log("hi from high chart from json PIE")
$.getJSON("{% static 'money/data/highchartpie.json' %}", function(json) {
console.log("haha i have read the json")
$('#containerHighChartJSONPie').highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: 1,//null,
plotShadow: false
},
title: {
text: 'Expenses per Types of Expenditures'
},
tooltip: {
pointFormat: '{point.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
}
}
}
},
series: [{
type: 'pie',
name: 'Type of Expenditure',
data: json
}]
});
});
});
json 中的数据是: [["杂货店",50.0],["杂项",30.0]]
问题 以下会根据需要生成良好的饼图,如果更改了任何数据,则图表也会更改,但有时图表会在其中显示更新的数据。我试过了:
- 从另一个浏览器运行它 - 它显示带有新值的更新图表
- 已清除缓存并在同一浏览器中再次尝试,现在它显示更新的代码
所以这似乎是一个缓存问题,但是有什么办法可以在 highchart 代码中解决这个问题?
【问题讨论】:
标签: javascript jquery json highcharts