我隔离了问题,但无法解决。我希望堆栈溢出的聪明人能为您提供帮助!
问题:存在注入表时,排序功能停止工作。当我移除进样针时,分选功能可以正常工作。有没有办法隔离src脚本,使其仅适用于注入的图表?尝试在最高图表之前引用它们不起作用。
我的页面:http://www.wcsddata.net/wearewcsd
在页面的开头,我引用了以下脚本,因此,我的图表将在页面底部的选项卡中运行:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/data.js"></script>
<script src="https://code.highcharts.com/modules/drilldown.js"></script>
<script src="https://code.highcharts.com/modules/offline-exporting.js"></script>
在顶部,我有4个图表通过everviz注入到页面中并利用“ script srce”:
<div id="highcharts-fvqBbZn4G" style="width: 100%; height: 220px; float: left; padding-bottom: 40px;"><script src="https://app.everviz.com/inject/fvqBbZn4G/" defer="defer"></script></div>
<div id="highcharts-AMGYgGD6V" style="width: 34%; height: 300px; float: left;"><script src="https://app.everviz.com/inject/AMGYgGD6V/" defer="defer"></script></div>
<div id="highcharts-pEyKRkM-l" style="width: 33%; height: 300px; float: left;"><script src="https://app.everviz.com/inject/pEyKRkM-l/" defer="defer"></script></div>
<div id="highcharts-USL8gYv5J" style="width: 33%; height: 300px; float: left;"><script src="https://app.everviz.com/inject/USL8gYv5J/" defer="defer"></script></div>
在底部,我具有选项卡集,其中包含8个不同的图表,其中许多具有排序功能(按字母顺序排列,从低到高和从高到低)。以下是其中之一的代码:
<script>
var categories = ['AACT', 'Allen', 'Anderson', 'Beasley', 'Beck', 'Bennett', 'Billinghurst', 'Booth', 'Brown', 'Cannan', 'Caughlin Ranch', 'Clayton', 'Cold Springs', 'Corbett', 'Damonte Ranch', 'Depoali', 'Desert Heights', 'Desert Skies', 'Diedrichsen', 'Dilworth', 'Dodson', 'Donner Springs', 'Double Diamond', 'Drake', 'Duncan', 'Dunn', 'Elmcrest', 'Galena', 'Gerlach K-12', 'Gomes', 'Gomm', 'Greenbrae', 'Hall', 'Hidden Valley', 'Huffaker', 'Hug', 'Hunsberger', 'Hunter Lake', 'Incline ES', 'Incline HS', 'Incline MS', 'Innovations', 'Inspire', 'Juniper', 'Lemelson', 'Lemmon Valley', 'Lenz', 'Lincoln Park', 'Loder', 'Mathews', 'Maxwell', 'McQueen', 'Melton', 'Mendive', 'Mitchell', 'Moss', 'Mount Rose K-8', 'Natchez', 'North Star', 'North Valleys', 'OBrien', 'Palmer', 'Peavine', 'Picollo', 'Pine', 'Pleasant Valley', 'Poulakidas', 'Reed', 'Reno', 'Risley', 'Sepulveda', 'Shaw', 'Silver Lake', 'Sky Ranch', 'Smith Alice', 'Smith Kate', 'Smithridge', 'Spanish Springs ES', 'Spanish Springs HS', 'Sparks HS', 'Sparks MS', 'Stead', 'Sun Valley', 'Swope', 'Taylor', 'TMCC HS', 'Towles', 'Traner', 'Turning Point', 'Van Gorder', 'Vaughn', 'Verdi', 'Veterans', 'Warner', 'Westergard', 'Whitehead', 'Winnemucca', 'Wooster'];
Highcharts.chart('containerfrlschl', {
chart: {
type: 'bar',
events: {
load: function() {
var points = this.series[0].points,
chart = this,
newPoints = [];
Highcharts.each(points, function(point, i) {
point.update({
name: categories[i]
}, false);
newPoints.push({
x: point.x,
y: point.y,
name: point.name
});
});
chart.redraw();
// Sorting A - Z
$('#sort7').on('click', function() {
newPoints.sort(function(a, b) {
if (a.name < b.name)
return -1;
if (a.name > b.name)
return 1;
return 0;
});
Highcharts.each(newPoints, function(frl, i) {
frl.x = i;
});
chart.series[0].setData(newPoints, true, false, false);
});
// Sorting min - max
$('#sort8').on('click', function() {
newPoints.sort(function(a, b) {
return a.y - b.y
});
Highcharts.each(newPoints, function(frl, i) {
frl.x = i;
});
chart.series[0].setData(newPoints, true, false, false);
});
// Sorting max - min
$('#sort9').on('click', function() {
newPoints.sort(function(a, b) {
return b.y - a.y
});
Highcharts.each(newPoints, function(frl, i) {
frl.x = i;
});
chart.series[0].setData(newPoints, true, false, false);
});
}
}
},
exporting: {
enabled: false
},
title:{
text:''
},
xAxis: {
type: 'category'
},
yAxis: {
min: 0,
max: 100,
title: {
text: 'Percentage of Student Population'
}
},
tooltip: {
valueSuffix: '%'
},
credits: {
enabled: false
},
legend: {
enabled: false,
reversed: true,
align: 'center',
verticalAlign: 'top',
itemDistance: 20,
itemStyle: {
"font-family": "'Open Sans', sans-serif",
"color": "#373737",
"fontSize": "16px",
"fontWeight": "normal"
}
},
plotOptions: {
series: {
stacking: 'normal',
dataLabels: {
enabled: true,
filter: {
property: 'percentage',
operator: '>',
value: 1
},
style: {
"font-family": "'Open Sans', sans-serif",
"color": "#ffffff",
"fontSize": "14px",
"fontWeight": "normal",
"textOutline": false
},
format: '{point.y}%'
}
}
},
series: [{
name: 'FRL',
color: '#00619e',
data: [19, 100, 100, 25, 28, 100, 26, 100, 15, 100, 9, 49, 43, 100, 24, 21, 100, 100, 45, 100, 100, 59, 38, 100, 100, 55, 100, 30, 32, 41, 10, 100, 29, 53, 32, 100, 4, 47, 45, 41, 46, 45, 100, 57, 100, 100, 9, 100, 100, 100, 100, 24, 11, 40, 100, 35, 35, 100, 28, 44, 58, 100, 52, 100, 50, 19, 12, 28, 19, 100, 30, 21, 50, 23, 100, 100, 100, 13, 27, 60, 100, 100, 100, 27, 23, 18, 45, 100, 100, 13, 100, 24, 100, 100, 21, 36, 37, 52]
}]
});</script>
先感谢您!肯
我发现这是everviz图表和Highcharts图表集成之间的一个普遍问题。发生此问题的原因是,everviz包括所有Highcharts模块,并且在主图表上进行更新使该图表“希望获得对这些模块的访问”,但是分配的参数错误。
将缺少模块(highcharts-更多和可访问性在这种情况下)修复该问题。
演示:https : //jsfiddle.net/BlackLabel/tqfp79c1/
<div id="highcharts-fvqBbZn4G" style="width: 100%; height: 220px; float: left; padding-bottom: 40px;"><script src="https://app.everviz.com/inject/fvqBbZn4G/" defer="defer"></script></div>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/data.js"></script>
<script src="https://code.highcharts.com/modules/drilldown.js"></script>
<script src="https://code.highcharts.com/modules/offline-exporting.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句