3.0.0-pre.1 • Published 6 years ago

@polymer-vis/polymer-vis v3.0.0-pre.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

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

ParamTypeDefaultDescription
srcstringThe url to the script to load.
onloadfunctioncallback when script is loaded.
onerrorfunctioncallback when error loading script.
optAsyncbooleantruewhether 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

ParamTypeDefaultDescription
hrefstringThe url to the script to load.
onloadfunctioncallback when script is loaded.
onerrorfunctioncallback when error loading script.
optAsyncbooleantruewhether 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

ParamTypeDefaultDescription
cssSrcStringurl to the css file
shadowRootStringNode to insert the style element
onloadfunctioncallback when CSS is inserted
idStringcustomid 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

ParamTypeDescription
nodeNodethe node to check