From 2b678fe336cb9911bbf87a2fa1f62556989d8a37 Mon Sep 17 00:00:00 2001 From: Ben Stoltz Date: Mon, 27 Feb 2017 18:01:38 -0500 Subject: [PATCH 1/3] Tooltips working for new chart spec --- site/source/partials/example-bar-url.hbs | 10 +++++----- src/cedar.js | 13 +++++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/site/source/partials/example-bar-url.hbs b/site/source/partials/example-bar-url.hbs index b4ad0426..125740ed 100644 --- a/site/source/partials/example-bar-url.hbs +++ b/site/source/partials/example-bar-url.hbs @@ -32,11 +32,11 @@ } ]; - - chart.tooltip = { - "title": "{Type}", - "content": "{Number_of_SUM} Students in {Type}" - } + // + // chart.tooltip = { + // "title": "{Type}", + // "content": "{Number_of_SUM} Students in {Type}" + // } //assign to the chart chart.datasets = datasets; diff --git a/src/cedar.js b/src/cedar.js index 874bf53b..a142cf64 100644 --- a/src/cedar.js +++ b/src/cedar.js @@ -440,14 +440,19 @@ 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); + this._definition.tooltip = { + 'title': `{${this._definition.series[0].category.field}}`, + 'content': `{${this._definition.series[0].value.field}}`, + 'id': `cedar-${Date.now()}` + }; + } + // 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); From 50a104cbce33a297e099403cd045ade4103edd4d Mon Sep 17 00:00:00 2001 From: Ben Stoltz Date: Tue, 28 Feb 2017 09:34:59 -0500 Subject: [PATCH 2/3] Tooltips added now only if tooltips are not supplied --- site/source/partials/example-bar-url.hbs | 10 +++++----- src/cedar.js | 12 +++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/site/source/partials/example-bar-url.hbs b/site/source/partials/example-bar-url.hbs index 125740ed..cedf508e 100644 --- a/site/source/partials/example-bar-url.hbs +++ b/site/source/partials/example-bar-url.hbs @@ -32,11 +32,11 @@ } ]; - // - // chart.tooltip = { - // "title": "{Type}", - // "content": "{Number_of_SUM} Students in {Type}" - // } + + chart.tooltip = { + "title": "{Type}", + "content": "{Number_of_SUM} Students in {Type}" + } //assign to the chart chart.datasets = datasets; diff --git a/src/cedar.js b/src/cedar.js index a142cf64..13f43145 100644 --- a/src/cedar.js +++ b/src/cedar.js @@ -442,11 +442,13 @@ 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); - this._definition.tooltip = { - 'title': `{${this._definition.series[0].category.field}}`, - 'content': `{${this._definition.series[0].value.field}}`, - 'id': `cedar-${Date.now()}` - }; + if (!this._definition.tooltip) { + this._definition.tooltip = { + 'title': `{${this._definition.series[0].category.field}}`, + 'content': `{${this._definition.series[0].value.field}}`, + 'id': `cedar-${Date.now()}` + }; + } } // Creates the HTML Div and styling if not already created From a06bbd92cba0b821e6e488618ec4a6dbe4661279 Mon Sep 17 00:00:00 2001 From: Ben Stoltz Date: Wed, 1 Mar 2017 16:06:38 -0500 Subject: [PATCH 3/3] this.tooltip rules --- src/cedar.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cedar.js b/src/cedar.js index 13f43145..f8cd5473 100644 --- a/src/cedar.js +++ b/src/cedar.js @@ -443,10 +443,9 @@ export default class Cedar { 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._definition.tooltip = { + this.tooltip = { 'title': `{${this._definition.series[0].category.field}}`, - 'content': `{${this._definition.series[0].value.field}}`, - 'id': `cedar-${Date.now()}` + 'content': `{${this._definition.series[0].value.field}}` }; } }