# Referencing External Javascript - (SystemJS) this is undefined

**URL:** <https://community.grafana.com/t/referencing-external-javascript-systemjs-this-is-undefined/136>\
**Category:** Grafana Plugin Development\
**Created:** [March 20, 2017, 1:44pm UTC](https://community.grafana.com/t/referencing-external-javascript-systemjs-this-is-undefined/136 "2017-03-20T13:44:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unifygroupluke](https://avatars.discourse-cdn.com/v4/letter/u/e9bcb4/32.png) [@unifygroupluke](https://community.grafana.com/u/unifygroupluke)\
**Post date:** [March 20, 2017, 1:44pm UTC](https://community.grafana.com/t/referencing-external-javascript-systemjs-this-is-undefined/136/1 "2017-03-20T13:44:59Z")

</div>

Hi,

I’m trying to develop my fist plug-in for Grafana which will incorporate a Plotly heatmap.

Taking inspiration from [https://github.com/NatelEnergy/grafana-plotly-panel](https://github.com/NatelEnergy/grafana-plotly-panel) I’ve included plotly.js in an dist/external file.

However when I reference Plotly with an import…

`import * as Plotly from './external/plotly'`

I’m getting an error:

(SystemJS) this is undefined  
Error loading [http://grafana.staged-by-discourse.com/public/plugins/myplugin/module.js](http://grafana.staged-by-discourse.com/public/plugins/myplugin/module.js)

```auto
import {PanelCtrl} from 'app/plugins/sdk';
import _ from 'lodash';
import * as Plotly from './external/plotly'

const panelDefaults = {
  message: 'Bar Foo'
}

export class HeatmapControl extends PanelCtrl {
  constructor($scope, $injector) {
    super($scope, $injector);    
    _.defaults(this.panel, panelDefaults);
    
    this.events.on('init-edit-mode', this.onInitEditMode.bind(this));        
    this.events.on('panel-initialized', this.render.bind(this));
    this.events.on('panel-teardown', this.onPanelTeardown.bind(this));
  }

  onInitEditMode() {
    this.addEditorTab('Options', 'public/plugins/unify-group-plotly-heatmap-panel/editor.html', 2);
  }

  onPanelTeardown() {
    //Clean up code goes here.
  }

  render() {
    console.log("render");
  }
}

HeatmapControl.templateUrl = 'module.html';

```

---

<div class="post-metadata">

**Author:** ![unifygroupluke](https://avatars.discourse-cdn.com/v4/letter/u/e9bcb4/32.png) [@unifygroupluke](https://community.grafana.com/u/unifygroupluke)\
**Post date:** [March 20, 2017, 2:08pm UTC](https://community.grafana.com/t/referencing-external-javascript-systemjs-this-is-undefined/136/2 "2017-03-20T14:08:09Z")

</div>

My bad. T’was a problem with the npm-scripts not copying everything to the plugins directory!
