Skip to content

Commit

Permalink
Merge pull request #8263 from infor-design/8164-pie-bordered-widget
Browse files Browse the repository at this point in the history
8164 - Pie with Bordered Class
  • Loading branch information
tmcconechy committed Dec 20, 2023
2 parents b555bdf + 0cdb9e0 commit 16b7b03
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 5 deletions.
64 changes: 64 additions & 0 deletions app/views/components/donut/test-bordered.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

<div class="row">
<div class="two-thirds column" style="min-width: 360px !important; max-width: 360px !important;">
<div class="widget bordered">
<div class="widget-header">
<h2 class="widget-title">Donut Chart Title</h2>
</div>
<div class="widget-content">
<div id="pie-donut-example" class="chart-container">
</div>
</div>
</div>
</div>
</div>


<script>
$('body').on('initialized', function () {

var donutData = [{
data: [{
name: 'Component A',
value: 18,
attributes: [
{ name: 'id', value: 'comp-a' },
{ name: 'data-automation-id', value: 'comp-a-automation-id' }
]
}, {
name: 'Component B',
value: 44,
attributes: [
{ name: 'id', value: 'comp-b' },
{ name: 'data-automation-id', value: 'comp-b-automation-id' }
]
}, {
name: 'Component C',
value: 32,
attributes: [
{ name: 'id', value: 'comp-c' },
{ name: 'data-automation-id', value: 'comp-c-automation-id' }
]
}, {
name: 'Component D',
value: 6,
attributes: [
{ name: 'id', value: 'comp-d' },
{ name: 'data-automation-id', value: 'comp-c-automation-id' }
]
}],
centerLabel: 'Donut Chart'
}];

$('#pie-donut-example').chart(
{
type: 'donut',
dataset: donutData,
showLegend: true,
legendPlacement: 'bottom'
}).on('selected', function (e, args) {
console.log(args);
});

});
</script>
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- `[Dropdown]` Fixed a bug where list is broken when empty icon is in the first option. ([#8105](https://github.com/infor-design/enterprise/issues/8105))
- `[Message]` Fixed success icon alignment in message header. ([#8240](https://github.com/infor-design/enterprise/issues/8240))
- `[Pager]` Fixed double call on update pager when using keydown. ([#8156](https://github.com/infor-design/enterprise/issues/8156))
- `[Pie/Donut]` Fixed rendering issues when having bordered class in the widget. ([#8164](https://github.com/infor-design/enterprise/issues/8164))
- `[Personalization]` Removed box shadow on selected tabs. ([#8086](https://github.com/infor-design/enterprise/issues/8086))
- `[Searchfield]` Fixed styling issues in RTL. ([#6982](https://github.com/infor-design/enterprise/issues/6982))

Expand Down
15 changes: 11 additions & 4 deletions src/components/charts/_charts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

.chart-legend.is-bottom {
.chart-legend-item.is-one-line {
margin: 10px 44px 0 100px !important;
margin: 0 auto !important;
padding: 0 2px 1px;

+ .list-button {
margin-top: 9px;
margin-top: 3px;
}
}
}
Expand Down Expand Up @@ -51,7 +51,7 @@
display: flex;
flex-direction: row;
flex-wrap: wrap;
padding-left: 30px;
justify-content: center;

.chart-legend-item.is-two-column {
display: flex;
Expand Down Expand Up @@ -563,7 +563,7 @@

// RTL Styles
html[dir='rtl'] {
.chart-legend {
.chart-legend:not(.is-bottom) {
margin-left: inherit;
margin-right: 55px;

Expand All @@ -579,6 +579,13 @@ html[dir='rtl'] {
}
}

.chart-legend.is-bottom {
.chart-legend-color {
margin-left: 10px;
margin-right: 0;
}
}

.completion-chart {
.icon-error {
left: -20px;
Expand Down
6 changes: 6 additions & 0 deletions src/components/charts/charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,12 @@ charts.addLegend = function (series, chartType, settings, container) {
menu: popupList
});

const widgetHeight = $(container).parents('.widget').height();
const widgetHeader = $($(container).parents('.widget').children().get(0)).height();
const widgetContent = $($(container).parents('.widget').children().get(1)).height();
const additionalPadding = (widgetHeight - (widgetHeader + widgetContent)) / 2;
legend.css('padding-top', `${additionalPadding}px`);

listButton.on('selected', (e, args) => {
const idx = $(args[0]).attr('index-id').match(regex)[1];
charts.handleElementClick(idx, this, series, settings, container);
Expand Down
8 changes: 7 additions & 1 deletion src/components/pie/pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ Pie.prototype = {
const self = this;
const s = this.settings;

// Fixing Angular Issue for Async Dataset
if (this.element.data('emptymessage') && s.dataset.length > 0) {
this.element.data('emptymessage').destroy();
}

self.svg = d3.select(this.element[0])
.append('svg');

Expand All @@ -160,14 +165,15 @@ Pie.prototype = {
this.element.addClass(`has-${s.legendPlacement}-legend`);
}

const hasParentBordered = this.element.parents('.widget').hasClass('bordered');
const w = parseInt(this.element.width(), 10);
let h = parseInt(this.element.height(), 10);

const dims = {
height: h,
width: w
};
dims.isSmallView = dims.width < 360;
dims.isSmallView = dims.width - (hasParentBordered ? 2 : 0) < 360;
const legendBotOnSingleWidget = s.legendPlacement === 'bottom' &&
dims.isSmallView && !s.showMobile;

Expand Down

0 comments on commit 16b7b03

Please sign in to comment.