[R] Guidance on how to make extensions usable from R.

Hi,
I am after a brief overview about what would be involved in making an extension like the Surface3d example usable from R. My guess is that this involves passing the JS implementation through R? At a high level what R functions would need to be created/updated to facilitate this?

Depending on what is involved, I may be able to get some time at work to make the changes and push back upstream.

Kind Regards,

Miles

CC'ing Ryan Hafen, who is the primary maintainer of RBokeh. He is in the middle of making foundational improvements to RBokeh including auto generating a "bokeh.models" low level API, so that the high level interfaces can be insulated and more maintained. So now is a good time to ask about this, actually.

Otherwise, from a general point of view, you'd need to create the right pile of JSON that including a JSON object to represent your extension in the document, and you need to define a JS module that implements the extension that gets executed first. A small one would look something like this:

      "custom/bk_script_5f5f109f0ce649818d9b2abce022f66a.my_formatter": [function(require, module, exports) {
          "use strict";
          Object.defineProperty(exports, "__esModule", { value: true });
          var extend = function (child, parent) { for (var key in parent) {
              if (hasProp.call(parent, key))
                  child[key] = parent[key];
          } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty;
          var tick_formatter_1 = require("models/formatters/tick_formatter");
          exports.MyFormatter = (function (superClass) {
              extend(MyFormatter, superClass);
              function MyFormatter() {
                  return MyFormatter.__super__.constructor.apply(this, arguments);
              }
              MyFormatter.prototype.type = "MyFormatter";
              MyFormatter.prototype.doFormat = function (ticks) {
                  var formatted, i, j, ref;
                  formatted = ["" + ticks[0]];
                  for (i = j = 1, ref = ticks.length; 1 <= ref ? j < ref : j > ref; i = 1 <= ref ? ++j : --j) {
                      formatted.push("+" + ((ticks[i] - ticks[0]).toPrecision(2)));
                  }
                  return formatted;
              };
              return MyFormatter;
          })(tick_formatter_1.TickFormatter);
          
          }, {}],

The Bokeh python API has conveniences to help generate all this, by looking at __implementation__ so presumably to make RBokeh easily extendible it would need some high level functions that do something similar.

Thanks,

Bryan

···

On Aug 7, 2017, at 02:08, [email protected] wrote:

Hi,
I am after a brief overview about what would be involved in making an extension like the Surface3d example usable from R. My guess is that this involves passing the JS __implementation__ through R? At a high level what R functions would need to be created/updated to facilitate this?

Depending on what is involved, I may be able to get some time at work to make the changes and push back upstream.

Kind Regards,
Miles

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/a054cc61-05a1-4b15-b572-b9cc6dbada4b%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Yes this is a good time to ask. This should theoretically be much more easily done with the refactor I’m working on, which I will be providing some developer docs on in the next week or two.

···

On Aug 7, 2017, at 6:55 AM, Bryan Van de ven [email protected] wrote:

CC’ing Ryan Hafen, who is the primary maintainer of RBokeh. He is in the middle of making foundational improvements to RBokeh including auto generating a “bokeh.models” low level API, so that the high level interfaces can be insulated and more maintained. So now is a good time to ask about this, actually.

Otherwise, from a general point of view, you’d need to create the right pile of JSON that including a JSON object to represent your extension in the document, and you need to define a JS module that implements the extension that gets executed first. A small one would look something like this:

  "custom/bk_script_5f5f109f0ce649818d9b2abce022f66a.my_formatter": [function(require, module, exports) {
      "use strict";
      Object.defineProperty(exports, "__esModule", { value: true });
      var extend = function (child, parent) { for (var key in parent) {
          if (hasProp.call(parent, key))
              child[key] = parent[key];
      } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty;
      var tick_formatter_1 = require("models/formatters/tick_formatter");
      exports.MyFormatter = (function (superClass) {
          extend(MyFormatter, superClass);
          function MyFormatter() {
              return MyFormatter.__super__.constructor.apply(this, arguments);
          }
          MyFormatter.prototype.type = "MyFormatter";
          MyFormatter.prototype.doFormat = function (ticks) {
              var formatted, i, j, ref;
              formatted = ["" + ticks[0]];
              for (i = j = 1, ref = ticks.length; 1 <= ref ? j < ref : j > ref; i = 1 <= ref ? ++j : --j) {
                  formatted.push("+" + ((ticks[i] - ticks[0]).toPrecision(2)));
              }
              return formatted;
          };
          return MyFormatter;
      })(tick_formatter_1.TickFormatter);

      }, {}],

The Bokeh python API has conveniences to help generate all this, by looking at implementation so presumably to make RBokeh easily extendible it would need some high level functions that do something similar.

Thanks,

Bryan

On Aug 7, 2017, at 02:08, [email protected] wrote:

Hi,
I am after a brief overview about what would be involved in making an extension like the Surface3d example usable from R. My guess is that this involves passing the JS implementation through R? At a high level what R functions would need to be created/updated to facilitate this?

Depending on what is involved, I may be able to get some time at work to make the changes and push back upstream.

Kind Regards,
Miles


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/a054cc61-05a1-4b15-b572-b9cc6dbada4b%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks for your replies. The JS example is useful. I am also a little unclear on how that JS code should be embedded in the JSON. I’ll try and educate myself by serving one and getting the JSON with PULL-DOC.

Looking forward to the updates!

Miles

···

On Wed, Aug 9, 2017 at 5:34 AM, Ryan Hafen [email protected] wrote:

Yes this is a good time to ask. This should theoretically be much more easily done with the refactor I’m working on, which I will be providing some developer docs on in the next week or two.

On Aug 7, 2017, at 6:55 AM, Bryan Van de ven [email protected] wrote:

On Aug 7, 2017, at 02:08, [email protected] wrote:

Hi,
I am after a brief overview about what would be involved in making an extension like the Surface3d example usable from R. My guess is that this involves passing the JS implementation through R? At a high level what R functions would need to be created/updated to facilitate this?

Depending on what is involved, I may be able to get some time at work to make the changes and push back upstream.

Kind Regards,
Miles


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/a054cc61-05a1-4b15-b572-b9cc6dbada4b%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
CC’ing Ryan Hafen, who is the primary maintainer of RBokeh. He is in the middle of making foundational improvements to RBokeh including auto generating a “bokeh.models” low level API, so that the high level interfaces can be insulated and more maintained. So now is a good time to ask about this, actually.

Otherwise, from a general point of view, you’d need to create the right pile of JSON that including a JSON object to represent your extension in the document, and you need to define a JS module that implements the extension that gets executed first. A small one would look something like this:

  "custom/bk_script_5f5f109f0ce649818d9b2abce022f66a.my_formatter": [function(require, module, exports) {
      "use strict";
      Object.defineProperty(exports, "__esModule", { value: true });
      var extend = function (child, parent) { for (var key in parent) {
          if (hasProp.call(parent, key))
              child[key] = parent[key];
      } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty;
      var tick_formatter_1 = require("models/formatters/tick_formatter");
      exports.MyFormatter = (function (superClass) {
          extend(MyFormatter, superClass);
          function MyFormatter() {
              return MyFormatter.__super__.constructor.apply(this, arguments);
          }
          MyFormatter.prototype.type = "MyFormatter";
          MyFormatter.prototype.doFormat = function (ticks) {
              var formatted, i, j, ref;
              formatted = ["" + ticks[0]];
              for (i = j = 1, ref = ticks.length; 1 <= ref ? j < ref : j > ref; i = 1 <= ref ? ++j : --j) {
                  formatted.push("+" + ((ticks[i] - ticks[0]).toPrecision(2)));
              }
              return formatted;
          };
          return MyFormatter;
      })(tick_formatter_1.TickFormatter);

      }, {}],

The Bokeh python API has conveniences to help generate all this, by looking at implementation so presumably to make RBokeh easily extendible it would need some high level functions that do something similar.

Thanks,

Bryan

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/99BD6640-10B2-4083-81DA-C47154679063%40gmail.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi again,
I setup the Surface3D example on a Bokeh Server and issued a PULL-DOC which I caught and examined. I am somewhat mystified by the extension JS implementation not appearing in the document JSON… There are some raw fields associated with ‘z’ and ‘color’ which I guess could hold javascript, but that would be an unexpected place for it. Where does the server keep the implementation JS and how is it mapped to the document?

I’ve attached the document JSON in case I am missing something.

Kind Regards,

Miles

sf3d_extension_pull_doc.json (25.4 KB)

···

On Wednesday, August 9, 2017 at 11:42:57 AM UTC+10, Miles McBain wrote:

Thanks for your replies. The JS example is useful. I am also a little unclear on how that JS code should be embedded in the JSON. I’ll try and educate myself by serving one and getting the JSON with PULL-DOC.

Looking forward to the updates!

Miles

For server apps, any JS implementations are bundled in the custom autoload.js that is served for the app, e.g.

  https://demo.bokehplots.com/apps/surface3d/autoload.js?bokeh-autoload-element="foo"

For a standalone document it would be in the templated call to Bokeh.embed_items IIRC

Bryan

···

On Aug 10, 2017, at 21:31, Miles McBain <[email protected]> wrote:

Hi again,
I setup the Surface3D example on a Bokeh Server and issued a PULL-DOC which I caught and examined. I am somewhat mystified by the extension JS implementation not appearing in the document JSON... There are some raw fields associated with 'z' and 'color' which I guess could hold javascript, but that would be an unexpected place for it. Where does the server keep the implementation JS and how is it mapped to the document?

I've attached the document JSON in case I am missing something.

Kind Regards,
Miles

On Wednesday, August 9, 2017 at 11:42:57 AM UTC+10, Miles McBain wrote:
Thanks for your replies. The JS example is useful. I am also a little unclear on how that JS code should be embedded in the JSON. I'll try and educate myself by serving one and getting the JSON with PULL-DOC.

Looking forward to the updates!

Miles

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/a3f0dc24-19f9-42af-8bcd-bb5deaeaaca4%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
<sf3d_extension_pull_doc.json>