Skip to content

Commit

Permalink
rebase after changes
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck committed Jun 2, 2017
1 parent 76b8436 commit b4fe208
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 61 deletions.
4 changes: 1 addition & 3 deletions src/core_plugins/circos_vis/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"name": "circos_vis",
"version": "kibana",
"dependencies": {
}
"version": "kibana"
}
77 changes: 39 additions & 38 deletions src/core_plugins/circos_vis/public/vis_controller.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
7 changes: 4 additions & 3 deletions src/core_plugins/state_tracker/public/vis_controller.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
Expand Down
29 changes: 12 additions & 17 deletions src/core_plugins/waffle_chart/public/vis_controller.js
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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() {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b4fe208

Please sign in to comment.