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.

After following Usage in Readme.md: SCALE_FUNCTIONS[type] is not a function

See original GitHub issue

After following the usage directions in Readme.md (essentially yarn add react-vis, yarn add react-addons-shallow-compare, setting up a few imports and adding the following to a component: )

<XYPlot
  width={300}
  height={300}>
  <HorizontalGridLines />
  <LineSeries
    data={[
      {x: 1, y: 10},
      {x: 2, y: 5},
      {x: 3, y: 15}
    ]}/>
  <XAxis />
  <YAxis />
</XYPlot>

The graph fails to render and I get the console error message Uncaught TypeError: SCALE_FUNCTIONS[type] is not a function. I’m using webpack2, presets for react and es2015… what I thought was a standard setup.

The line that is failing is here: https://github.com/uber/react-vis/blob/d96abc8841c2a6312aa/src/utils/scales-utils.js#L146

If I go into my node_modules directory and add a debugger statement just before it, I can see that my SCALE_FUNCTIONS only has literal defined, and that type is "ordinal".

Debugger

Has anyone seen this before or have any ideas what this could be? Unfortunately my workplace blocks gist and other services so I can’t easily drop my yarn lock file.

Here’s the stacktrace:

Uncaught TypeError: SCALE_FUNCTIONS[type] is not a function
    at _getScaleFnFromScaleObject (eval at <anonymous> (app.js:1598), <anonymous>:187:36)
    at _adjustCategoricalScale (eval at <anonymous> (app.js:1598), <anonymous>:493:17)
    at getScaleObjectFromProps (eval at <anonymous> (app.js:1598), <anonymous>:531:12)
    at getAttributeScale (eval at <anonymous> (app.js:1598), <anonymous>:543:21)
    at GridLines.render (eval at <anonymous> (app.js:1945), <anonymous>:146:54)
    at eval (eval at <anonymous> (vendor.js:6114), <anonymous>:796:21)
    at measureLifeCyclePerf (eval at <anonymous> (vendor.js:6114), <anonymous>:75:12)
    at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (eval at <anonymous> (vendor.js:6114), <anonymous>:795:25)
    at ReactCompositeComponentWrapper._renderValidatedComponent (eval at <anonymous> (vendor.js:6114), <anonymous>:822:32)
    at ReactCompositeComponentWrapper.performInitialMount (eval at <anonymous> (vendor.js:6114), <anonymous>:362:30)

react-vis is version 1.0.1, my react version is 15.4.2, webpack is 2.3.1, babel-core is 6.24. Babel presets are react, es2015 with these plugins:

        ["syntax-dynamic-import"],
        ["transform-decorators-legacy"],
        ["transform-object-rest-spread"],
        ["transform-react-display-name"],
        ["transform-object-assign"],
        ["react-transform", {
          "transforms": [{
            "transform": "react-transform-hmr",
            "imports": ["react"],
            "locals": ["module"]
          }, {
            "transform": "react-transform-catch-errors",
            "imports": ["react", "redbox-react"]
          }]
        }]

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
vjprcommented, Aug 21, 2017

Okay found the issue. There is a mismatch between the d3-scale exports and the ones used in scales-util.

export {default as linear} from "./src/linear";

vs.

_d3Scale.scaleLinear

So for me it turns out I have 2 versions of d3-scale, and the old one had an older api which was causing the issue.

0reactions
mcnuttandrewcommented, Aug 30, 2017

Hey @vjpr,

Can you say more about the mismatch you found? I’m not sure I get it? Also, this is a long shot (🤞) but this issue might have been resolved by #567

Read more comments on GitHub >

github_iconTop Results From Across the Web

About READMEs - GitHub Docs
You can add a README file to your repository to tell other people why your project is useful, what they can do with...
Read more >
New lines inside paragraph in README.md - Stack Overflow
Interpreting newlines as <br /> used to be a feature of Github-flavored markdown, but the most recent help document no longer lists this...
Read more >
How to create a Readme.md file? - Medium
In this blog, you will learn about the Markdown file or also called the .md file. What is an Md file? Where an...
Read more >
What is README.md File? - GeeksforGeeks
A README file is an essential guide that gives other developers a detailed description of your GitHub project. You may be wondering, ...
Read more >
README.md template | Documenting your project - Drupal
README documentation can include more Markdown-features than those used in the example snippets in ... Drupal recommends the following README formatting:.
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