I have created polymer 1.x custom elements using d3 v3 before. I want to update them to polymer 3 and d3 v5.
Here is a base polymer 3 element that I want to include d3 v5 into:
import {html, PolymerElement} from '@polymer/polymer/polymer-element.js';
/**
* `foo-bar`
*
*
* @customElement
* @polymer
* @demo demo/index.html
*/
class FooBar extends PolymerElement {
static get template() {
return html`
<style>
:host {
display: block;
}
</style>
<h2>Hello [[prop1]]!</h2>
`;
}
static get properties() {
return {
prop1: {
type: String,
value: 'foo-bar',
},
};
}
constructor() {
super();
}
ready() {
super.ready();
console.log('foo-bar is ready!');
}
}
window.customElements.define('foo-bar', FooBar);
I call npm install d3
How shall I import d3 into this PolymerElement? I have two different types of polymer elements using d3. I have done both force and hierarchy polymer elements.
I am figuring that I need to do something in the constructor() or ready() functions within the polymer element to utilize the d3 library.
I was trying the following import:
import 'd3/dist/d3.js';