amcharts3 icon indicating copy to clipboard operation
amcharts3 copied to clipboard

Images not found when used as node_module

Open timwis opened this issue 10 years ago • 5 comments

Not sure there's much that can be done to resolve this, but I'm just posting the workaround here in case anyone else comes across this problem.

When used via require('amcharts3'), images such as the drag icons give a 404 since it's looking inside an amcharts/ folder at the root that doesn't exist.

The work around is to set window.AmCharts_path = 'node_modules/amcharts3/amcharts';

timwis avatar Sep 08 '15 10:09 timwis

In addition, amcharts path can be set using chart instance's path property.

martynasma avatar Sep 08 '15 11:09 martynasma

Above methods are not working on Webpack build app. Getting error http://localhost:3000/node_modules/amcharts3/amcharts/images/lens.svg 404 (Not Found) on no matter set path or not.

lanocturne avatar Oct 28 '15 19:10 lanocturne

@lanocturne, there is no trouble with webpack.

// copy images from node_modules to webpack output directory
var imagesContext = require.context('!!file?name=images/amcharts/[name].[ext]!amcharts3/amcharts/images');
imagesContext.keys().forEach(imagesContext);

AmCharts.makeChart(elem, {
    // specify path to images
    pathToImages: 'images/amcharts/'

dizel3d avatar Dec 16 '15 06:12 dizel3d

@timwis, in your case, you manage images separately from js and should use pathToImages in a chart config.

dizel3d avatar Dec 16 '15 07:12 dizel3d

@dizel3d Uncaught Error: Cannot find module "!!file?name=images/amcharts/[name].[ext]!node_modules/amstock3/amcharts/images"

I tried your code with amstock3 but got this error

daniilc-magnumwm avatar Jul 26 '18 03:07 daniilc-magnumwm