From bf6e1ba25a60d268507de5d81670e257cb1024c0 Mon Sep 17 00:00:00 2001 From: Michael Chadwick Date: Thu, 16 Jan 2025 08:22:01 -0800 Subject: [PATCH] merged new animation loading code --- .../src/components/simple-chart-donut.js | 28 +++++++++++-------- .../src/components/simple-chart-pie.js | 28 +++++++++++-------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/ember-simple-charts/src/components/simple-chart-donut.js b/ember-simple-charts/src/components/simple-chart-donut.js index 57bb498f..34924e0f 100644 --- a/ember-simple-charts/src/components/simple-chart-donut.js +++ b/ember-simple-charts/src/components/simple-chart-donut.js @@ -19,6 +19,10 @@ export default class SimpleChartDonut extends Component { } get isLoading() { + if (this.args.isIcon) { + return false; + } + return !this.loadingPromise || this.loadingData.isPending; } @@ -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') diff --git a/ember-simple-charts/src/components/simple-chart-pie.js b/ember-simple-charts/src/components/simple-chart-pie.js index 467b8962..6bdbb476 100644 --- a/ember-simple-charts/src/components/simple-chart-pie.js +++ b/ember-simple-charts/src/components/simple-chart-pie.js @@ -19,6 +19,10 @@ export default class SimpleChartPie extends Component { } get isLoading() { + if (this.args.isIcon) { + return false; + } + return !this.loadingPromise || this.loadingData.isPending; } @@ -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')