diff --git a/README.md b/README.md index 55b41db..7d24f03 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,12 @@ A Web Component that builds an SVG Sparkline. ``` +### Set a custom title + +```html + +``` + ## Features This Web Component builds a sparkline based on the required `values` attribute. diff --git a/svg-sparkline.js b/svg-sparkline.js index 8833782..b225a9e 100644 --- a/svg-sparkline.js +++ b/svg-sparkline.js @@ -111,9 +111,10 @@ class SVGSparkline extends HTMLElement { content.push(`${this.startLabel}`) } + const title = this.title || `Sparkline ranging from ${this.getMinY(this.values)} to ${this.getMaxY(this.values)}.`; content.push(` - Sparkline ranging from ${this.getMinY(this.values)} to ${this.getMaxY(this.values)}. + ${title} `) let gradientID