Coder Social home page Coder Social logo

Comments (22)

mspe87 avatar mspe87 commented on June 16, 2024 2

I had been struggling with this issue all day, and 5 minutes after posting my issue i found the solution.
For other who might have the same problem, the solution is to us bundled version of highstock and non bundled version of highcharts. The non bundled version, expects highcharts to already be loaded

var Highstocks = require('react-highcharts/dist/bundle/highstock');
var Highcharts = require('react-highcharts');

from react-highcharts.

kirjs avatar kirjs commented on June 16, 2024

Thanks Mads, feel free to PR a readme update if you feel this info belongs there.

from react-highcharts.

joshhornby avatar joshhornby commented on June 16, 2024

@mspe87 Thanks for this, although I seem to get this error

Error: Starting with version 3 of react-highcharts, Highcharts is not bundled by default. use "react-highcharts/bundle/highcharts" instead, or include highcharts

from react-highcharts.

mspe87 avatar mspe87 commented on June 16, 2024

@joshhornby That was the same problem i had. You need to use it like this:

var Highstocks = require('react-highcharts/dist/bundle/highstock');
var Highcharts = require('react-highcharts');

And not like this:

var Highstock = require('react-highcharts/dist/bundle/highstock');
var Highcharts = require('react-highcharts/dist/bundle/highcharts');

from react-highcharts.

joshhornby avatar joshhornby commented on June 16, 2024

@mspe87 I was doing that, I have re-run my build and the errors seem to have code away. But of been webpack playing up!

from react-highcharts.

joshhornby avatar joshhornby commented on June 16, 2024

@mspe87 I can actually confirm that this isn't a webpack caching issue. I still get the error when using the packages like you stated.

from react-highcharts.

kirjs avatar kirjs commented on June 16, 2024

Which version are you using?
I got rid of the dist part in the latest version

from react-highcharts.

joshhornby avatar joshhornby commented on June 16, 2024

I am using version 5.0.2. I still see the dist directory in my node modules

from react-highcharts.

kirjs avatar kirjs commented on June 16, 2024

Can you show me how exactly your code looks like?

from react-highcharts.

joshhornby avatar joshhornby commented on June 16, 2024

Highchart

render() {

      let Highcharts = require('react-highcharts');
      Highcharts.Highcharts.setOptions({
        global: {
            useUTC: false
        }
      });

      return (
        <div>
          <Highcharts config={this.props.chartData} />
        </div>
      );
    };

Highstock

  render() {

      let Highstock = require('react-highcharts/dist/bundle/highstock');
      Highstock.Highcharts.setOptions({
        global: {
            useUTC: false
        }
      });

      return (
        <div>
          <Highstock config={this.props.chartData} />
        </div>
      );
    };

}

from react-highcharts.

kirjs avatar kirjs commented on June 16, 2024

That was fast. Which exact error do you get?
What's the stack trace?

from react-highcharts.

joshhornby avatar joshhornby commented on June 16, 2024

screenshot 2015-11-17 15 42 50

The odd thing is I don't get the error on every render.

from react-highcharts.

kirjs avatar kirjs commented on June 16, 2024

I think the case here is that require('react-highcharts/dist/bundle/highstock'); should be required before require('react-highcharts');, because it's the one who's getting the Highcharts in the code base.

Also try getting rid of the dist part, it should work without it.

from react-highcharts.

joshhornby avatar joshhornby commented on June 16, 2024

How would this work with two separate files though? This might explain why it sometimes errors and one chart may load before another?

from react-highcharts.

kirjs avatar kirjs commented on June 16, 2024

Do require('react-highcharts/dist/bundle/highstock'); somewhere on the top level of the app.
That should fix it.

from react-highcharts.

joshhornby avatar joshhornby commented on June 16, 2024

Doing this throws Highcharts error #16: www.highcharts.com/errors/16

from react-highcharts.

kirjs avatar kirjs commented on June 16, 2024

Use non-bundled highstock in Highstock file

from react-highcharts.

joshhornby avatar joshhornby commented on June 16, 2024

So require('react-highcharts/highstock');

from react-highcharts.

kirjs avatar kirjs commented on June 16, 2024

Yes, not on top level, but in highstock file

from react-highcharts.

joshhornby avatar joshhornby commented on June 16, 2024

Adding const Highcharts = require('react-highcharts/bundle/highstock'); at the top of the file seems to have fixed this. Thanks for the help @kirjs I will continue testing tomorrow. Can we leave this issue open for next 24 hours until I can 100% confirm its fixed? If so I will PR the docs.

from react-highcharts.

kirjs avatar kirjs commented on June 16, 2024

Sure, this seems like a good place for the docs.

Also this makes me want to get rid of bundles and just better document including highcharts release in the bundle in the future.

from react-highcharts.

kirjs avatar kirjs commented on June 16, 2024

I'll close it, feel free to reopen if needed

from react-highcharts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.