vislite
Version:
灵活、快速、简单的数据可视化交互式跨端前端库
25 lines (17 loc) • 744 B
text/typescript
import type SVGType from '../types/SVG'
import OralSVG from './common/svg/index'
class SVG extends OralSVG implements SVGType {
constructor(el: HTMLElement | null) {
if (!el) {
throw new Error("VISLite SVG:The mount point requires an HTMLElement type but encountered null.")
}
const width = el.clientWidth, height = el.clientHeight
const ViewSVG = document.createElementNS("http://www.w3.org/2000/svg", 'svg')
el.appendChild(ViewSVG)
ViewSVG.setAttribute("width", width + "")
ViewSVG.setAttribute("height", height + "")
ViewSVG.setAttribute("viewBox", "0 0 " + width + " " + height)
super(ViewSVG)
}
}
export default SVG