Skip to content

Commit

Permalink
merged new animation loading code
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchadwick committed Jan 16, 2025
1 parent fd403b8 commit bf6e1ba
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
28 changes: 16 additions & 12 deletions ember-simple-charts/src/components/simple-chart-donut.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export default class SimpleChartDonut extends Component {
}

get isLoading() {
if (this.args.isIcon) {
return false;
}

return !this.loadingPromise || this.loadingData.isPending;
}

Expand Down Expand Up @@ -80,19 +84,19 @@ export default class SimpleChartDonut extends Component {
.attr('stroke', '#FFFFFF')
.attr('fill', (d) => color(d.data.data));

this.loadingPromise = chart
.selectAll('path.slicepath')
.transition()
.ease(easeLinear)
.duration(500)
.attrTween('d', (b) => {
b.innerRadius = 0;
const i = interpolate({ startAngle: 0, endAngle: 0 }, b);
return (p) => createArc(i(p));
})
.end();

if (!isIcon) {
this.loadingPromise = chart
.selectAll('path.slicepath')
.transition()
.ease(easeLinear)
.duration(500)
.attrTween('d', (b) => {
b.innerRadius = 0;
const i = interpolate({ startAngle: 0, endAngle: 0 }, b);
return (p) => createArc(i(p));
})
.end();

const text = chart
.selectAll('.slice')
.append('text')
Expand Down
28 changes: 16 additions & 12 deletions ember-simple-charts/src/components/simple-chart-pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export default class SimpleChartPie extends Component {
}

get isLoading() {
if (this.args.isIcon) {
return false;
}

return !this.loadingPromise || this.loadingData.isPending;
}

Expand Down Expand Up @@ -77,19 +81,19 @@ export default class SimpleChartPie extends Component {
.attr('stroke', '#FFFFFF')
.attr('fill', (d) => color(d.data.data));

this.loadingPromise = chart
.selectAll('path.slicepath')
.transition()
.ease(easeLinear)
.duration(500)
.attrTween('d', (b) => {
b.innerRadius = 0;
const i = interpolate({ startAngle: 0, endAngle: 0 }, b);
return (p) => createArc(i(p));
})
.end();

if (!isIcon) {
this.loadingPromise = chart
.selectAll('path.slicepath')
.transition()
.ease(easeLinear)
.duration(500)
.attrTween('d', (b) => {
b.innerRadius = 0;
const i = interpolate({ startAngle: 0, endAngle: 0 }, b);
return (p) => createArc(i(p));
})
.end();

const text = chart
.selectAll('.slice')
.append('text')
Expand Down

0 comments on commit bf6e1ba

Please sign in to comment.