1

I am trying to use dygraphs in Angular CLI 7, but the import is not working. I installed it first using npm install --save dygraphs and in my imports i wrote import { Dygraph } from 'dygraphs';, but the error in TSLint still says File '/home/[...]/node_modules/@types/dygraphs/index.d.ts' is not a module.ts(2306).

The same error message appears for the chart.js import, but here, it works fine. All graphs are displayed correctly.

Also, the compiler says error TS2305: Module '"dygraphs"' has no exported member 'Dygraph'., which would mean that the module imports fine but the member is not found?

In the web console, the error message is RROR Error: Uncaught (in promise): TypeError: dygraphs__WEBPACK_IMPORTED_MODULE_6__.Dygraph is not a constructor. I am trying to create a graph like this:

private config = [
    [1, 2, 3],
    [4, 5, 6],
];
g = new Dygraph(document.getElementById("div_g"), this.config,
    {
        drawPoints: true,
        showRoller: true,
        valueRange: [0.0, 1.2],
        labels: ['Time', 'Random']
    });

Thanks for helping me out.

mneumann
  • 491
  • 1
  • 5
  • 25

1 Answers1

1

Your import is incorrect:

import { Dygraph } from 'dygraphs';

should be

import Dygraph from 'dygraphs';

For an explanation, have a look at this answer.

Kim Kern
  • 33,055
  • 14
  • 114
  • 135