Search code examples
shieldui

Shield UI Chart won’t show again after being hidden


I have followed your advice, however once hidden, the chart won’t show up when the check box has been unchecked. Here is my code:

                   var charta=document.getElementById("Chart_A").value;
                    var containter = $("#ChartA_Container").swidget();
                    containter.destroy();                            
                    if (Chart_A.checked == false){
                    $("#ChartA_Container").shieldChart(
                        {
                            seriesSettings: {
                                line: {
                                    applyAnimation: {
                                        duration: 0
                                    },
                                    pointMark:{
                                        enabled: false
                                    }
                                }
                            },
                            tooltipSettings: {
                                enabled: false
                            },
                            exportOptions:
                            {
                                image: false,
                                print: false
                            },

                            axisX: {
                                min: 0,
                                max: 55
                            },

                            primaryHeader: {
                                text: "EUR/USD"
                            },
                            dataSeries: [
                                {
                                    seriesType: 'line',
                                    collectionAlias: 'EUR/USD',
                                    data: EURUSD,
                                }
                            ]
                        }
                        )
                    }else{
                        document.getElementById("EURUSDChart").innerHTML="Chart Hidden"
                    };

I will appreciate some more detailed help on this matter.


Solution

  • The problem is quite simple. The containter.destroy(); statement is used to unset the chart’s container. Once done, there is no container which to be unset the next time function is called. What you need is to put this statement inside the checkbox clause, so that if destroyed, it is immediately recreated:

    if (Chart_A.checked == false){
     var containter = $("#ChartA_Container").swidget();
     containter.destroy();