-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: labelFilter 参数与 labelFormatter 保持一致 (#4911)
* fix: refactor labelFilter to has same pramameters with labelFormatter * test: add test case
- Loading branch information
Showing
4 changed files
with
83 additions
and
17 deletions.
There are no files selected for viewing
Binary file added
BIN
+22.9 KB
__tests__/integration/snapshots/static/aaplLineBasicSampleLabelFilter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions
38
__tests__/plots/static/aapl-line-basic-sample-label-filter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { G2Spec } from '../../../src'; | ||
|
||
export function aaplLineBasicSampleLabelFilter(): G2Spec { | ||
return { | ||
type: 'line', | ||
data: { | ||
type: 'fetch', | ||
value: 'data/aapl.csv', | ||
}, | ||
encode: { | ||
x: 'date', | ||
y: 'close', | ||
}, | ||
transform: [ | ||
{ | ||
type: 'sample', | ||
thresholds: 100, | ||
strategy: 'lttb', | ||
}, | ||
], | ||
axis: { | ||
x: { | ||
labelFormatter: (d, i) => { | ||
return ( | ||
d.getFullYear().toString() + (i % 2 === 0 ? '(even)' : '(odd)') | ||
); | ||
}, | ||
}, | ||
y: { | ||
labelFilter: (d) => { | ||
return d % 100 === 0; | ||
}, | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
aaplLineBasicSampleLabelFilter.maxError = 100; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters