简体   繁体   English

更改选项卡时,Highcharts-legend-item.last()消失

[英]Highcharts-legend-item.last() disappears when changing tab

I have a "tab container" set up on my page with three tabs, each containing a different highcharts pie chart. 我在页面上设置了一个“标签容器”,其中包含三个标签,每个标签包含一个不同的highcharts饼图。 They are rendered depending on the active tab. 它们的显示取决于活动选项卡。 For each one of them I put a total of 100% column at the end of the legend, with this code; 对于其中的每一个,我将使用此代码在图例的末尾添加总计100%的列;

chart: {
    type:'pie',
    renderTo: 'ctl00_ContentPlaceHolder1_Overview1_AssetXRayChart',
    events: {
        load: function(event) {
            $('.highcharts-legend-item').last().append('<br/><div style="width: 220px; margin-left: 190px;">_____</div><br/><div style="width:220px"><span style="float:right"><b>100%</b></span> </div>');
        }
    }
}

On the initial render everything looks great, but if I click on any of the subsequent tabs to display those pie charts, and then return to a different tab to view the chart i've already seen that total column is gone, except for the third tab, which is the final rendered chart. 在初始渲染中,一切看起来都很不错,但是如果我单击随后的任何一个选项卡以显示那些饼图,然后返回到另一个选项卡以查看该图,我已经看到除第三个以外的总列已消失标签,这是最终呈现的图表。 I believe it is because the third chart rendered is actually the official "last" legend item element and that is why it stays, but since all of these are rendered in their own respective shouldn't that allow for the total row to stay there? 我相信这是因为渲染的第三个图表实际上是官方的“最后一个”图例项元素,这就是为什么保留它的原因,但是既然所有这些图表都是以各自的形式渲染的,那是否不应该允许总行停留在那儿? is it because i use that exact same line of code for each one of them with no unique id's in the div's or span's? 是因为我为每个人使用了完全相同的代码行,但在div或span里没有唯一的ID? any help is appreciated. 任何帮助表示赞赏。 Thank you very much, NickG 非常感谢NickG

Change for each chart path from: 从以下位置更改每个图表路径:

 $('.highcharts-legend-item')...

to: 至:

 $('#tl00_ContentPlaceHolder1_Overview1_AssetXRayChart .highcharts-legend-item')...

Where #tl00_ContentPlaceHolder1_Overview1_AssetXRayChart is different for each chart ( as ID's for chart containers) 每个图表的#tl00_ContentPlaceHolder1_Overview1_AssetXRayChart不同(作为图表容器的ID)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM