Created
August 6, 2016 20:37
-
-
Save mpalmr/946d2f5773e4d6346aa7524a1f75c7c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as d3 from "d3"; | |
export default class Chart { | |
private elements: Array<Element>; | |
constructor(target: string|Element|NodeList) { | |
this.elements = Chart.parseTarget(target); | |
} | |
private static parseTarget(target: string|Element|NodeList): Array<Element> { | |
if (typeof target === "string") return Array.from(document.querySelectorAll(target)); | |
if (typeof target === "NodeList") return Array.from(target); | |
if (target instanceof Element) return [target]; | |
throw new TypeError(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment