-
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: update legend component inferring strategies (#4906)
* fix: add extra rules to avoid unexcept component inferring * refactor: update legend inferring config
- Loading branch information
Showing
8 changed files
with
282 additions
and
113 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,19 @@ | ||
import { G2Spec } from '../../../src'; | ||
|
||
export function bodyPointScatterPlot(): G2Spec { | ||
return { | ||
type: 'point', | ||
data: { | ||
type: 'fetch', | ||
value: 'data/body.json', | ||
}, | ||
encode: { | ||
x: 'height', | ||
y: 'weight', | ||
size: 'weight', | ||
color: 'red', | ||
}, | ||
}; | ||
} | ||
|
||
bodyPointScatterPlot.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,237 @@ | ||
// [legend type, [channels, scale type][][]] | ||
type InferStrategy = [string, [string, string][][]]; | ||
|
||
/** | ||
* @examples | ||
* ✅ | ||
* color - `discrete`, shape - `constant` | ||
* legendCategory.rule[27] is matched | ||
* | ||
* ❎ | ||
* shape - `discrete`, size - `constant` | ||
* There are no rules to match | ||
* | ||
*/ | ||
export const LEGEND_INFER_STRATEGIES: InferStrategy[] = [ | ||
[ | ||
'legendCategory', | ||
[ | ||
[ | ||
['color', 'discrete'], | ||
['opacity', 'discrete'], | ||
['shape', 'discrete'], | ||
['size', 'constant'], | ||
], | ||
[ | ||
['color', 'discrete'], | ||
['opacity', 'constant'], | ||
['shape', 'discrete'], | ||
['size', 'constant'], | ||
], | ||
[ | ||
['color', 'discrete'], | ||
['opacity', 'discrete'], | ||
['shape', 'constant'], | ||
['size', 'constant'], | ||
], | ||
[ | ||
['color', 'discrete'], | ||
['opacity', 'constant'], | ||
['shape', 'constant'], | ||
['size', 'constant'], | ||
], | ||
[ | ||
['color', 'constant'], | ||
['opacity', 'discrete'], | ||
['shape', 'discrete'], | ||
['size', 'constant'], | ||
], | ||
[ | ||
['color', 'constant'], | ||
['opacity', 'constant'], | ||
['shape', 'discrete'], | ||
['size', 'constant'], | ||
], | ||
[ | ||
['color', 'constant'], | ||
['opacity', 'discrete'], | ||
['shape', 'constant'], | ||
['size', 'constant'], | ||
], | ||
[ | ||
['color', 'discrete'], | ||
['shape', 'discrete'], | ||
['size', 'constant'], | ||
], | ||
[ | ||
['color', 'discrete'], | ||
['opacity', 'discrete'], | ||
['shape', 'discrete'], | ||
], | ||
[ | ||
['color', 'discrete'], | ||
['opacity', 'discrete'], | ||
['size', 'constant'], | ||
], | ||
[ | ||
['color', 'discrete'], | ||
['opacity', 'constant'], | ||
['shape', 'discrete'], | ||
], | ||
[ | ||
['color', 'discrete'], | ||
['opacity', 'constant'], | ||
['size', 'constant'], | ||
], | ||
[ | ||
['color', 'discrete'], | ||
['shape', 'constant'], | ||
['size', 'constant'], | ||
], | ||
[ | ||
['color', 'discrete'], | ||
['opacity', 'discrete'], | ||
['shape', 'constant'], | ||
], | ||
[ | ||
['color', 'discrete'], | ||
['opacity', 'constant'], | ||
['shape', 'constant'], | ||
], | ||
[ | ||
['color', 'constant'], | ||
['shape', 'discrete'], | ||
['size', 'constant'], | ||
], | ||
[ | ||
['color', 'constant'], | ||
['opacity', 'discrete'], | ||
['shape', 'discrete'], | ||
], | ||
[ | ||
['color', 'constant'], | ||
['opacity', 'discrete'], | ||
['size', 'constant'], | ||
], | ||
[ | ||
['color', 'constant'], | ||
['opacity', 'constant'], | ||
['shape', 'discrete'], | ||
], | ||
// [ | ||
// ['color', 'constant'], | ||
// ['opacity', 'constant'], | ||
// ['size', 'constant'], | ||
// ], | ||
// [ | ||
// ['color', 'constant'], | ||
// ['shape', 'constant'], | ||
// ['size', 'constant'], | ||
// ], | ||
[ | ||
['color', 'constant'], | ||
['opacity', 'discrete'], | ||
['shape', 'constant'], | ||
], | ||
[ | ||
['color', 'discrete'], | ||
['shape', 'discrete'], | ||
], | ||
[ | ||
['color', 'discrete'], | ||
['size', 'constant'], | ||
], | ||
[ | ||
['color', 'discrete'], | ||
['opacity', 'discrete'], | ||
], | ||
[ | ||
['color', 'discrete'], | ||
['opacity', 'constant'], | ||
], | ||
[ | ||
['color', 'discrete'], | ||
['shape', 'constant'], | ||
], | ||
[ | ||
['color', 'constant'], | ||
['shape', 'discrete'], | ||
], | ||
[ | ||
['color', 'constant'], | ||
['size', 'constant'], | ||
], | ||
[ | ||
['color', 'constant'], | ||
['opacity', 'discrete'], | ||
], | ||
// [ | ||
// ['color', 'constant'], | ||
// ['opacity', 'constant'], | ||
// ], | ||
// [ | ||
// ['color', 'constant'], | ||
// ['shape', 'constant'], | ||
// ], | ||
[['color', 'discrete']], | ||
// [['color', 'constant']], | ||
], | ||
], | ||
[ | ||
'legendContinuousSize', | ||
[ | ||
[ | ||
['color', 'continuous'], | ||
['opacity', 'continuous'], | ||
['size', 'continuous'], | ||
], | ||
[ | ||
['color', 'constant'], | ||
['opacity', 'continuous'], | ||
['size', 'continuous'], | ||
], | ||
[ | ||
['color', 'continuous'], | ||
['size', 'continuous'], | ||
], | ||
[ | ||
['color', 'constant'], | ||
['size', 'continuous'], | ||
], | ||
], | ||
], | ||
[ | ||
'legendContinuousBlockSize', | ||
[ | ||
[ | ||
['color', 'distribution'], | ||
['opacity', 'distribution'], | ||
['size', 'distribution'], | ||
], | ||
[ | ||
['color', 'distribution'], | ||
['size', 'distribution'], | ||
], | ||
], | ||
], | ||
[ | ||
'legendContinuousBlock', | ||
[ | ||
[ | ||
['color', 'distribution'], | ||
['opacity', 'continuous'], | ||
], | ||
[['color', 'distribution']], | ||
], | ||
], | ||
[ | ||
'legendContinuous', | ||
[ | ||
[ | ||
['color', 'continuous'], | ||
['opacity', 'continuous'], | ||
], | ||
[['color', 'continuous']], | ||
], | ||
], | ||
]; |
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
Oops, something went wrong.