diff --git a/site/source/partials/example-bar-url.hbs b/site/source/partials/example-bar-url.hbs index b4ad0426..cedf508e 100644 --- a/site/source/partials/example-bar-url.hbs +++ b/site/source/partials/example-bar-url.hbs @@ -32,7 +32,7 @@ } ]; - + chart.tooltip = { "title": "{Type}", "content": "{Number_of_SUM} Students in {Type}" diff --git a/src/cedar.js b/src/cedar.js index 874bf53b..f8cd5473 100644 --- a/src/cedar.js +++ b/src/cedar.js @@ -440,14 +440,20 @@ export default class Cedar { } try { + if (this._definition.datasets && this._definition.series) { + this._definition.dataset = specUtils.convertDatasetsToDataset(this._definition.datasets, this._definition.series, this._chartType, this._definition.dataset); + if (!this._definition.tooltip) { + this.tooltip = { + 'title': `{${this._definition.series[0].category.field}}`, + 'content': `{${this._definition.series[0].value.field}}` + }; + } + } + // Creates the HTML Div and styling if not already created if (this._definition.tooltip) { this._createTooltip(this._definition.tooltip.id); } - - if (this._definition.datasets && this._definition.series) { - this._definition.dataset = specUtils.convertDatasetsToDataset(this._definition.datasets, this._definition.series, this._chartType, this._definition.dataset); - } // Ensure we have required inputs or defaults let compiledMappings = specUtils.applyDefaultsToMappings(this._definition.dataset.mappings, this._definition.specification.inputs);