amcharts / amcharts3-react

Official amCharts V3 React component
Apache License 2.0
118 stars 50 forks source link

d.AmXYChart is not a constructor #29

Closed cemremengu closed 7 years ago

cemremengu commented 7 years ago

I am trying to use the XYChart but I am getting the error TypeError: d.AmXYChart is not a constructor.

I tried using the imports but unfortunately no luck

import AmCharts from 'amcharts3-react';
require("amstock3/amcharts/amstock");

Is this currently implemented ?

Pauan commented 7 years ago

@cemremengu Try these imports instead:

import AmCharts from 'amcharts3-react';
import 'amcharts3/amcharts/xy';
cemremengu commented 7 years ago

@Pauan Great thanks so much!

Pauan commented 7 years ago

@cemremengu You're welcome, I'm glad I could help.

hero9 commented 6 years ago

Hey there, @Pauan i'm trying to use AmChart's Gantt Chart, but I have the errors like:

Uncaught TypeError: d.AmGanttChart is not a constructor
    at Object.d.makeChart (amcharts.js?c03a:11)
    at Object.componentDidMount (amcharts3-react.js?08e1:265)
    at Object.chainedFunction [as componentDidMount] (vendor.dll.js:97692)
    at commitLifeCycles (vendor.dll.js:109743)
    at commitAllLifeCycles (vendor.dll.js:111414)
    at HTMLUnknownElement.callCallback (vendor.dll.js:100059)
    at Object.invokeGuardedCallbackDev (vendor.dll.js:100097)
    at invokeGuardedCallback (vendor.dll.js:100146)
    at commitRoot (vendor.dll.js:111553)
    at completeRoot (vendor.dll.js:112461)

What can I do?

Pauan commented 6 years ago

@hero9 You need to include gantt.js, like this:

<script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="https://www.amcharts.com/lib/3/serial.js"></script>
<script src="https://www.amcharts.com/lib/3/gantt.js"></script>
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
<script src="https://www.amcharts.com/lib/3/plugins/export/export.min.js"></script>