nicolaskruchten / pivottable

Open-source Javascript Pivot Table (aka Pivot Grid, Pivot Chart, Cross-Tab) implementation with drag'n'drop.
https://pivottable.js.org/
MIT License
4.36k stars 1.08k forks source link

How do I reset the pivotUI options #761

Open sujeetsks opened 7 years ago

sujeetsks commented 7 years ago

I have one div say "output" for Pivot functionalities.

$("#output").pivotUI( $.pivotUtilities.tipsData, { rows: ["YEAR_PAID"], cols: ["STATUS"], aggregatorName: "Count", rendererName: "Table", renderers: $.extend( $.pivotUtilities.renderers, $.pivotUtilities.c3_renderers ) });

I have added my ajax call for assigning my $.pivotUtilities.tipsData and it is working fine till now. But now I want to render PivotUI options such as rows, cols, vals, aggregator name, renderername etc. from database values on the same div with the same $.pivotUtilities.tipsData. Now I am taking these values from database to reset the pivotUI option.

when i am taking another div say "Myfavorite" to render these option it is working fine. Here is my code..

    $("#Myfavorite").pivotUI(
  $.pivotUtilities.tipsData, {  
      rows: [rowsname],   //rowsname is taken from database
      cols: [colsname],    //colsname is taken from database
      vals: [valsname],   //valsname is taken from database
      aggregatorName: aggregator,
      rendererName: renderer,
      //onRefresh: saveState,
      renderers: $.extend(
          $.pivotUtilities.renderers,
        $.pivotUtilities.c3_renderers
      )
  });

But when i want to again reset the PivotUI options from database , "Myfavorite" div is not working. I need another third dive to achieve it what i am facing now. means in short one div is working for one time dynamic rendering of options. I want to play with the same div "output" with the options stored in database. For that I want to reset and reassign the options. Could anyone tell me if achieved it already.?

nicolaskruchten commented 7 years ago

This example shows you how to reset/overwrite the config: https://pivottable.js.org/examples/save_restore.html

You need to set the overwrite parameter to true.

amharfm commented 7 years ago

thank youu

ghost commented 2 years ago

@nicolaskruchten is there any package available which has above reset/overwrite the config changes available which can be installed in jupyter notebook and used to create and save charts.