diff --git a/src/core_plugins/circos_vis/package.json b/src/core_plugins/circos_vis/package.json index 81cf75e4ef8e41..f56ed57c80b08e 100644 --- a/src/core_plugins/circos_vis/package.json +++ b/src/core_plugins/circos_vis/package.json @@ -1,6 +1,4 @@ { "name": "circos_vis", - "version": "kibana", - "dependencies": { - } + "version": "kibana" } diff --git a/src/core_plugins/circos_vis/public/vis_controller.js b/src/core_plugins/circos_vis/public/vis_controller.js index 12c4cf905c288b..c69ec2ab365b89 100644 --- a/src/core_plugins/circos_vis/public/vis_controller.js +++ b/src/core_plugins/circos_vis/public/vis_controller.js @@ -1,59 +1,60 @@ -import Circos from 'circos/dist/circos'; +import Circos from 'circos'; class CircosVisController { - constructor(el) { + constructor(el, vis) { this.el = el; + this._vis = vis; } - render(vis, visData) { - this.vis = vis; + render(visData) { + this.visData = visData; if (this.circos) { this.destroy(); } - return new Promise(resolve => { - const width = this.el.offsetWidth; - const height = this.el.offsetHeight; - const radius = Math.min(width, height) / 20; - this.vis = vis; - this.circos = new Circos({ - container: this.el, - width: this.el.offsetWidth * 0.9, - height: this.el.offsetHeight * 0.9, - }); - this.circos.layout(visData.layout, { - gap: vis.params.layout.gap, - innerRadius: radius, - outerRadius: radius, - labels: { - display: vis.params.layout.showLabels, - radialOffset: vis.params.layout.offsetLabels - }, - ticks: { display: true, labels: false } - }); + const width = this.el.offsetWidth; + const height = this.el.offsetHeight; + const radius = Math.min(width, height) / 20; - visData.series.forEach((serie, i) => { - const seriesParams = vis.params.seriesParams[i]; - this.circos[seriesParams.type](`series-${i}`, serie, { - innerRadius: seriesParams.innerRadius, - outerRadius: seriesParams.outerRadius, - color: seriesParams.colorSchema, - tooltipContent: (datum) => { - return datum.value; - } - }); - }); + this.circos = new Circos({ + container: this.el, + width: this.el.offsetWidth * 0.9, + height: this.el.offsetHeight * 0.9, + }); - this.circos.render(); - resolve(true); + this.circos.layout(visData.layout, { + gap: this._vis.params.layout.gap, + innerRadius: radius, + outerRadius: radius, + labels: { + display: this._vis.params.layout.showLabels, + radialOffset: this._vis.params.layout.offsetLabels + }, + ticks: { display: true, labels: false } }); + + visData.series.forEach((serie, i) => { + const seriesParams = this._vis.params.seriesParams[i]; + this.circos[seriesParams.type](`series-${i}`, serie, { + innerRadius: seriesParams.innerRadius, + outerRadius: seriesParams.outerRadius, + color: seriesParams.colorSchema, + tooltipContent: (datum) => { + return datum.value; + } + }); + }); + + this.circos.render(); + + } resize() { if (!this.circos) return; - this.render(this.vis, this.visData); + this.render(this.visData); } destroy() { diff --git a/src/core_plugins/state_tracker/public/vis_controller.js b/src/core_plugins/state_tracker/public/vis_controller.js index 0c238414e6f561..aa9c825518aab5 100644 --- a/src/core_plugins/state_tracker/public/vis_controller.js +++ b/src/core_plugins/state_tracker/public/vis_controller.js @@ -1,11 +1,12 @@ class VisController { - constructor(el) { + constructor(el, vis) { this.el = el; + this._vis = vis; this._previousStates = []; } - render(vis, visData) { + render() { return new Promise(resolve => { const id = window.location.href; @@ -14,7 +15,7 @@ class VisController { }); if (!visited) { - const filters = vis.API.queryFilter.getFilters(); + const filters = this._vis.API.queryFilter.getFilters(); const display = JSON.stringify(filters); const state = { id: id, diff --git a/src/core_plugins/waffle_chart/public/vis_controller.js b/src/core_plugins/waffle_chart/public/vis_controller.js index ec07ee30304c41..61b243b7942e42 100644 --- a/src/core_plugins/waffle_chart/public/vis_controller.js +++ b/src/core_plugins/waffle_chart/public/vis_controller.js @@ -1,8 +1,9 @@ import d3 from 'd3'; class VisController { - constructor(el) { + constructor(el, vis) { this._container = el; + this._vis = vis; this._waffleContainer = document.createElement('div'); this._waffleContainer.setAttribute('class', 'waffle-waffle'); this._legendContainer = document.createElement('div'); @@ -11,22 +12,16 @@ class VisController { this._container.appendChild(this._legendContainer); } - render(vis, visData) { - - return new Promise((resolve) => { - + async render(visData) { + try { this._clear(); - - - try { - const label = vis.aggs[0].makeLabel() + ': ' + vis.aggs[1].makeLabel(); - const data = convertResponse(visData); - this._createWaffleVis(data, label); - } catch (e) { - //handle error - } - resolve(true); - }); + const label = this._vis.aggs[0].makeLabel() + ': ' + this._vis.aggs[1].makeLabel(); + const data = convertResponse(visData); + this._createWaffleVis(data, label); + } catch (e) { + //handle error + console.log(e); + } } _clear() { @@ -99,7 +94,7 @@ class VisController { }) .append('title') .text(function (d) { - return label + ' ' + data[d.groupIndex].key + ' | ' + d.value + ' , ' + d.units + '%'; + return label + ' ' + data[d.groupIndex].key + ' | ' + d.value + ' , ' + d.units + '%'; }); //add legend with categorical data