Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ELEMENTS-1718-BACKPORT: Fix reflow issue in overflow charts in analytics #885

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions ui/dataviz/nuxeo-document-distribution-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ import { I18nBehavior } from '../nuxeo-i18n-behavior.js';

#ex {
position: absolute;
top: 260px;
left: 305px;
width: 140px;
text-align: center;
z-index: 10;
Expand Down Expand Up @@ -491,7 +489,10 @@ import { I18nBehavior } from '../nuxeo-i18n-behavior.js';
return this.$.nx.request().then((request) =>
request
.execute(options)
.then(this._handleResponse.bind(this))
.then((res) => {
window.onresize = () => this._handleResponse(res);
this._handleResponse(res);
})
.catch(this._handleError.bind(this)),
);
}
Expand Down Expand Up @@ -539,7 +540,7 @@ import { I18nBehavior } from '../nuxeo-i18n-behavior.js';
}

_buildSunBurst(aggs) {
const aggregations = aggs.subLevel;
const aggregations = JSON.parse(JSON.stringify(aggs.subLevel));
aggregations.name = 'root';
aggregations.color = this._getColor(aggregations.name, this.chartHue, this.chartLuminosity);
aggregations.children = aggregations.buckets;
Expand All @@ -553,23 +554,35 @@ import { I18nBehavior } from '../nuxeo-i18n-behavior.js';
this._chartData = aggregations;

// Dimensions of sunburst.
const maxRadius = this.$.chart.offsetWidth / 2 - 20;
radius = Math.min(this.width, this.height) / 2;
let { width, height } = this;

if (radius > maxRadius) {
radius = maxRadius;
width = height = 2 * radius;
}

// Total size of all segments; we set this later, after loading the data.
this.totalSize = 0;

const svg = this.$.chart.querySelector('svg');
const textContainer = this.$.chart.querySelector('#ex');
if (svg) {
svg.parentNode.removeChild(svg);
}

vis = select(this.$.chart)
.append('svg:svg')
.attr('width', this.width)
.attr('height', this.height)
.attr('width', width)
.attr('height', height)
.append('svg:g')
.attr('id', 'container')
.attr('transform', `translate(${this.width / 2},${this.height / 2})`);
.attr('transform', `translate(${width / 2},${height / 2})`);

textContainer.style.width = `${140}px`;
textContainer.style.height = `${70}px`;
textContainer.style.transform = `translate(${width / 2 - 70}px, ${height / 2 - 35}px)`;

_partition = partition().size([2 * Math.PI, radius * radius]);

Expand Down
Loading