@polymer-vis/polymer-vis v3.0.0-pre.1
PolymerVis
PolymerVis is a suite of Polymer elements for visualizations.
Usage
Installation
npm i @polymer-vis/polymer-vis --save
yarn add @polymer-vis/polymer-vis --save
Import into project
import PolymerVis from '../polymer-vis/polymer-vis.js';
import {insertCssIntoShadowRoot} from '../polymer-vis/polymer-vis.js';
API reference
PolymerVis.loadScript(src, onload, onerror, optAsync) ⇒ HTMLScriptElement
Convenience method for dynamically loading a script.
This method creates a new <script>
element with the provided URL and
appends it to the document to start loading. In the onload callback, the
import property of the link element will contain the imported document
contents.
Kind: static method of PolymerVis
Param | Type | Default | Description |
---|---|---|---|
src | string | The url to the script to load. | |
onload | function | callback when script is loaded. | |
onerror | function | callback when error loading script. | |
optAsync | boolean | true | whether to execute the script asynchronously. |
PolymerVis.loadStylesheet(href, onload, onerror, optAsync) ⇒ HTMLLinkElement
Convenience method for dynamically loading a stylesheet.
This method creates a new <link rel="stylesheet">
element with the
provided URL and appends it to the document to start loading. In the onload
callback, the import property of the link element will contain the
imported document contents.
Kind: static method of PolymerVis
Param | Type | Default | Description |
---|---|---|---|
href | string | The url to the script to load. | |
onload | function | callback when script is loaded. | |
onerror | function | callback when error loading script. | |
optAsync | boolean | true | whether to execute the script asynchronously. |
PolymerVis.insertCssIntoShadowRoot(cssSrc, shadowRoot, onload, id)
Load an external CSS file, and insert a style
element
into the shadowRoot.
Kind: static method of PolymerVis
Param | Type | Default | Description |
---|---|---|---|
cssSrc | String | url to the css file | |
shadowRoot | String | Node to insert the style element | |
onload | function | callback when CSS is inserted | |
id | String | custom | id for style element |
Example
import PolymerVis from '../polymer-vis/polymer-vis.js';
PolymerVis.insertCssIntoShadowRoot('https://some.css', ele.shadowRoot, null, 'custom');
PolymerVis.isInShadowRoot(node) ⇒ Node
Check if the node is inside a shadowRoot
or not.
Return the shadowRoot
otherwise return false
.
Kind: static method of PolymerVis
Param | Type | Description |
---|---|---|
node | Node | the node to check |
6 years ago