首先需要用到的是官網的:可以改變標題api
A.html:
plotOptions: {
series: {
cursor: 'pointer',
point: {
events: {
click: function (e) {
var names = decodeURIComponent( e.point.series.name);
window.open(`A.html?month=${e.point.category}&length=${names}`);
}
}
}
},
},
B.html:接收傳過來的參數
var perimeters = window.location.search;
perimeters = decodeURI(perimeters.substr(1).split('&')[0] + "=" + perimeters.substr(2).split('&')[1]);
var months = perimeters.split('=')[1], type = perimeters.split('=')[3];
console.log(perimeters );//month=Oct=length=Target;
console.log(months);//Oct
console.log(type );//Target
ok,值都接收來了,接下來點擊當前數據圖出現另一個數據圖如何寫呢?這個問題很白癡哈,大家曉得怎麽寫,但是,如何讓兩個數據圖像是有刷新一樣的自適應寬度效果呢?
好這下來分享下成果,我是利用了reflow();這個方法完成的,代碼如下:
B.html
<div class="highchartscontainer">
<div id="container" class="container hcartsone"></div>
<div id="container1" class="container hidechart" style="display:none"></div>
</div>
B.js
plotOptions: {
series: {
cursor: 'pointer',
point: {
events: {
click: function (e) {
var hidechart = document.getElementsByClassName('hidechart')[0],
container = document.getElementsByClassName('container')[0];
setTimeout(function () {
hidechart.style.cssText = 'display:inline-block;float:right';
container.style.width = (containersw / 2 - 4) + 'px';
hidechart.style.width = (containersw / 2 - 4) + 'px';
var chartmon = e.point.category,
charttype = e.point.series.name;
this.chart.reflow();
chart1.reflow();
chart1.setTitle({text: charttype }, {text: chartmon});
}, 500)
}
}
}
},
},
- chart1:是另一個數據圖的名字
- setTimeout:定時器是可要也不可要,
- e.point.category:為chart這個數據圖的當前點擊的月份
- e.point.series.name:為數據綫的name
- this.chart.reflow():為刷新當前數據圖
- chart1.reflow():為刷新第二個數據圖
- chart1.setTitle({text: charttype }, {text: chartmon}):為第二個數據圖的標題賦值,第一個text是正標題title,第二個text是附標題subtitle
儅只有一個數據圖B.html:
點擊后:可以看到2個數據圖寬度響應了