Make Panels invisible amchart

我怕爱的太早我们不能终老 提交于 2020-01-07 05:41:10

问题


I would like to make panels visible/invisible by button.

in this sample remove/add panels. But when adding, I need to make a panel and settings again.

I would like to just make panels visible/invisible not delete.

I have googled around and not found samples.

Is it possible??


Thanks to @Robbert reply

I could hide the panel . like this .

    $(".amcharts-stock-panel-div-stockPanel1").hide();

However it does not re-adjust the each panel size.

If I call the

So I try like this .

$(".amcharts-stock-panel-div-stockPanel1").hide();
chart.panels[1].percentHeight = 1;
chart.validateNow();

it hide the panel and adjust the each panel height.

However, if you use validateNow() when percentHeight = 1;

this error happens.

  amcharts.js:26 Uncaught TypeError: Cannot read property 'translate' of undefined
    at b.fixVLine (amcharts.js:26)
    at b.adjustBalloonCoordinate (serial.js:17)
    at b.showBalloon (amcharts.js:5)
    at b.handleCursorMove (serial.js:8)
    at b.dispatchMovedEvent (amcharts.js:27)
    at b.syncWithCursorReal (amcharts.js:28)
    at b.syncWithCursor (amcharts.js:28)
    at b.handleCursorChange (amstock.js:2)
    at b.a.inherits.b.fire (amcharts.js:1)
    at b.dispatchMovedEvent (amcharts.js:27)

my final solution is like this , not use css, but prepare variable panelBack for panel backup.

//removing ...
pos = //panel position.
var panelBack = chart.panels[pos];
chart.removePanel(chart.panels[pos]);
chart.validateNow();

//adding...
chart.addPanelAt(panelBack,1);
chart.validateNow();

回答1:


By looking at the source of the demo, you'll see that the second Stock Panel gets a classname of amcharts-stock-panel-div-stockPanel1. You could hide it using CSS:

.amcharts-stock-panel-div-stockPanel1 {
  display: none;
}

.amcharts-stock-panel-div-stockPanel1 * {
  /* hide SVG nodes as well */
  visibility: hidden;
}

However, amCharts itself is not aware that this panel is hidden, so it will not re-adjust the height of the first stock panel when "removing" it.

I would advice following the method as seen in the example.



来源:https://stackoverflow.com/questions/45909386/make-panels-invisible-amchart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!