question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

D3 not available when RequireJS is present

See original GitHub issue

When I call chart.render() for piechart it throws the following error:

keen.js:19724 Unhandled rejection TypeError: d3.select is not a function
    at Dataviz.module.exports (http://localhost:8010/lib/keen.js:23456:25)
    at Dataviz.render (http://localhost:8010/lib/keen.js:24074:40)
    at http://localhost:8010/lib/keen.js:23264:55
    at domReady (http://localhost:8010/lib/keen.js:23361:13)
    at Dataviz.render (http://localhost:8010/lib/keen.js:23242:9)

Using version 4.3.0 of keen-js. Furthermore the legend is not showing in any chart type.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
adamkasprowiczcommented, May 30, 2018

Hi @alejandromagnorsky ,

We’ve just published new versions of our 3 core libs.

Moving from keen-js main package to standalone packages will give you much more freedom and new opportunities. Especially if you are using js bundlers.

Thanks

1reaction
dustinlarimercommented, Oct 11, 2017

Thank your for digging into that further and helping figuring this out!

Require has issues with nested dependencies that also define Require modules. I just double-checked the version of D3 we’re including, and it’s module definition block looks like this:

// ...
if (typeof define === "function" && define.amd) this.d3 = d3, define(d3); else if (typeof module === "object" && module.exports) module.exports = d3; else this.d3 = d3;

If I’m reading this correctly, when RequireJS is present the D3 module just isn’t loaded the way our library expects to reference it… which in turn triggers the d3.select is not a function error you noted. I’ll look into solutions for patching this up… Sorry for the bumpy ride!


As for the original issue, I think this id.substring() error stems from an edge case with the type of data being passed in. Categorical data labels are passed in as a string, but in this case those labels are likely Date instances, since your query uses an interval but no groups.

Example:

new Date().substring(0, 10);
> Uncaught TypeError: (intermediate value).substring is not a function

Try changing the type to 'line' or 'area' and it should work as expected. I’ll look into the error and see if type-enforcement can squash the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Requirejs, d3 and nvd3 integration - javascript - Stack Overflow
I'm facing the problem of integrating requirejs with d3 and nvd3, and i found an easy solution using require's shim. Using the shim...
Read more >
RequireJS API
If this function returns a value, //then that value is used as the module export value //instead of the object found via the...
Read more >
How to use D3 Component library in Require.js Dashboard
How to use D3 Component library plugin in Require.js Dashboard.?Right now d3 component library is missing in Require.js dashboard.
Read more >
d3 CVC not working when embedded using visualize.js
You are trying to embed one of the example d3 CVC components (d3_treemap) using visualize.js and are encountering a "Report render error".
Read more >
Have trouble with require/requirejs - Jupyter Community Forum
Hi, The answer found from Display d3.js visualisation in Jupyter Lab - Stack Overflow works in jupyter lab but not in the “classic”...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found