Search code examples
javascriptcsschartsresponsiveclappr

Set background as transparent and responsive for google Line Chart


I want to use Google linechart .

This is my project's image its a chart for Clappr

My questions:

1) How can I set the background-color:transparent ??

2) If user click on full page size ( button right ) , the chart will not be 100% width again , how to set it 100% ?

This picture is for second question

responsive


Solution

  • There is only way to reaction about device width (or windows width) and that is redraw chart. It is true, but do not forget to destroy old chart before redraw new version.

     .destroy()
    

    This code can remove old chart , after that you can add new chart

      // Example from the docs
            var myLineChart = new Chart(ctx, config);
       // Destroys a specific chart instance
            myLineChart.destroy();
    

    I tested, It is working fine