Setting Plotly to render Rpivottable Graph Output

Hi all,

I'm using the package rpivotTable, which is a html widget wrapper around PivotTable.js.

I'd really, really like to make plotly render the graphs, as it does a much better job than the default renderer. On the PivotTable.js website, they have a function example of this which is available here

The end result there is exactly what I want to be able to do. I've looked in the rpivotTable.js file to try to see where to add the code, but I haven't been successful.

The file contents is as below:

HTMLWidgets.widget({
    name: 'rpivotTable',
    type: 'output',
    initialize: function(el, width, height) {
	    return {};
    },
    resize: function(el, width, height, instance) { },

    renderValue: function(el, x, instance) {
	    x.data = HTMLWidgets.dataframeToD3(x.data);

      if (typeof x.params.sorters != "undefined") {
        if (typeof x.params.sorters[0] == "string") {
            x.params.sorters = eval("("+x.params.sorters[0]+")")
          }
      }

      if (typeof x.params.onRefresh != "undefined") {
        x.params.onRefresh = x.params.onRefresh[0];
      }

      var locale = $.pivotUtilities.locales[x.locale];
      locale.renderers = $.extend({}, locale.renderers,
        locale.d3_renderers || $.pivotUtilities.d3_renderers,
        locale.c3_renderers || $.pivotUtilities.c3_renderers);

      // if subtotals then override renderers to add subtotals
      if(x.subtotals) {
        x.params.renderers = $.extend(
          $.pivotUtilities.subtotal_renderers,
          $.pivotUtilities.d3_renderers,
          $.pivotUtilities.c3_renderers
        );
        x.params.dataClass = $.pivotUtilities.SubtotalPivotData;
      }

      $('#'+el.id).pivotUI(x.data, x.params, true, x.locale);
    }
});

If anyone is able to help here it would be very much appreciated.

This is a pretty technical javascript question, I haven't had much luck in this form with js stuff. I suggest you post in Stack Overflow instead.

Cheers, will do. Hopefully my second question on here is a bit gentler!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.