-
Notifications
You must be signed in to change notification settings - Fork 15
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
AG-12655 Skip unordered category animations #2947
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,52 @@ export class CategoryAxis< | |
@Validate(RATIO, { optional: true }) | ||
paddingOuter?: number; | ||
|
||
private domainOrderedToNormalizedDomain(seriesDomain: any[], normalizedDomain: any[]) { | ||
let normalizedIndex = -1; | ||
for (let seriesIndex = 0; seriesIndex < seriesDomain.length; seriesIndex += 1) { | ||
const value = seriesDomain[seriesIndex]; | ||
const normalizedNextIndex = normalizedDomain.indexOf(value); | ||
|
||
if (normalizedNextIndex === -1) { | ||
// All subsequent values must be extending (i.e. appending to) the normalized domain | ||
normalizedIndex = Number.MAX_SAFE_INTEGER; | ||
jacobp100 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else if (normalizedNextIndex <= normalizedIndex) { | ||
return false; | ||
} else { | ||
normalizedIndex = normalizedNextIndex; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
private categoryAnimatable = true; | ||
protected override calculateDomain() { | ||
let normalizedDomain: any[] = []; | ||
|
||
let categoryAnimatable = true; | ||
for (const series of this.boundSeries) { | ||
if (!this.includeInvisibleDomains && !series.isEnabled()) continue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's to match the original logic - in case this value ever changes |
||
|
||
const seriesDomain = series.getDomain(this.direction); | ||
|
||
categoryAnimatable &&= this.domainOrderedToNormalizedDomain(seriesDomain, normalizedDomain); | ||
|
||
normalizedDomain = this.normaliseDataDomain([...normalizedDomain, ...seriesDomain]).domain; | ||
} | ||
|
||
this.setDomain(normalizedDomain); | ||
this.categoryAnimatable = categoryAnimatable; | ||
} | ||
|
||
override update() { | ||
super.update(); | ||
|
||
if (!this.categoryAnimatable) { | ||
this.moduleCtx.animationManager.skip(); | ||
} | ||
} | ||
|
||
override normaliseDataDomain(d: Array<string | object>) { | ||
const domain = []; | ||
const uniqueValues = new Set(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use
Infinity
to keep consistent with similar logic in our codebase