victory
victory copied to clipboard
Fix issues with scale type inference in `Scale.getScaleType`
Some issues came up in #2204 around this getType
function.
https://github.com/FormidableLabs/victory/blob/a314d8340a2461483742ffa457d4acc2a4413400/packages/victory-core/src/victory-util/scale.js#L113-L128
This function accepts a d3 scale function as an input and makes inferences about this function using the .method
property in order to return a string scale type. Updating the d3-scale
package changed some of the internals of these scales, which broke the string mapping for some scale types.
The temporary solution was to comment out the scales that aren't included in Victory's documentation, since the documented scales are still working.
However, it's worth re-evaluating why we are doing this conversion from a function back to a string, and whether there is a different approach that would accomplish the same goal without relying on the internals of these d3 scale functions. In the long run, I could see it making more sense to get the d3 scale function based on the props, and then pass the child components a function rather than a string scale type.
For ducktyping here are the keys used in [email protected]
:
{
"scaleBand": {
"type": "function",
"keys": [
"domain",
"range",
"copy",
"rangeRound",
"bandwidth",
"step",
"round",
"padding",
"paddingInner",
"paddingOuter",
"align"
]
},
"scaleDiverging": {
"type": "function",
"keys": [
"domain",
"clamp",
"interpolator",
"range",
"rangeRound",
"unknown",
"ticks",
"tickFormat",
"nice",
"copy"
]
},
"scaleDivergingLog": {
"type": "function",
"keys": [
"domain",
"clamp",
"interpolator",
"range",
"rangeRound",
"unknown",
"base",
"ticks",
"tickFormat",
"nice",
"copy"
]
},
"scaleDivergingPow": {
"type": "function",
"keys": [
"domain",
"clamp",
"interpolator",
"range",
"rangeRound",
"unknown",
"exponent",
"ticks",
"tickFormat",
"nice",
"copy"
]
},
"scaleDivergingSqrt": {
"type": "function",
"keys": [
"domain",
"clamp",
"interpolator",
"range",
"rangeRound",
"unknown",
"exponent",
"ticks",
"tickFormat",
"nice",
"copy"
]
},
"scaleDivergingSymlog": {
"type": "function",
"keys": [
"domain",
"clamp",
"interpolator",
"range",
"rangeRound",
"unknown",
"constant",
"ticks",
"tickFormat",
"nice",
"copy"
]
},
"scaleIdentity": {
"type": "function",
"keys": [
"invert",
"range",
"domain",
"unknown",
"copy",
"ticks",
"tickFormat",
"nice"
]
},
"scaleImplicit": {
"type": "object",
"keys": []
},
"scaleLinear": {
"type": "function",
"keys": [
"invert",
"domain",
"range",
"rangeRound",
"clamp",
"interpolate",
"unknown",
"copy",
"ticks",
"tickFormat",
"nice"
]
},
"scaleLog": {
"type": "function",
"keys": [
"invert",
"domain",
"range",
"rangeRound",
"clamp",
"interpolate",
"unknown",
"base",
"ticks",
"tickFormat",
"nice",
"copy"
]
},
"scaleOrdinal": {
"type": "function",
"keys": [
"domain",
"range",
"unknown",
"copy"
]
},
"scalePoint": {
"type": "function",
"keys": [
"domain",
"range",
"copy",
"rangeRound",
"bandwidth",
"step",
"round",
"padding",
"align"
]
},
"scalePow": {
"type": "function",
"keys": [
"invert",
"domain",
"range",
"rangeRound",
"clamp",
"interpolate",
"unknown",
"exponent",
"ticks",
"tickFormat",
"nice",
"copy"
]
},
"scaleQuantile": {
"type": "function",
"keys": [
"invertExtent",
"domain",
"range",
"unknown",
"quantiles",
"copy"
]
},
"scaleQuantize": {
"type": "function",
"keys": [
"domain",
"range",
"invertExtent",
"unknown",
"thresholds",
"copy",
"ticks",
"tickFormat",
"nice"
]
},
"scaleRadial": {
"type": "function",
"keys": [
"invert",
"domain",
"range",
"rangeRound",
"round",
"clamp",
"unknown",
"copy",
"ticks",
"tickFormat",
"nice"
]
},
"scaleSequential": {
"type": "function",
"keys": [
"domain",
"clamp",
"interpolator",
"range",
"rangeRound",
"unknown",
"ticks",
"tickFormat",
"nice",
"copy"
]
},
"scaleSequentialLog": {
"type": "function",
"keys": [
"domain",
"clamp",
"interpolator",
"range",
"rangeRound",
"unknown",
"base",
"ticks",
"tickFormat",
"nice",
"copy"
]
},
"scaleSequentialPow": {
"type": "function",
"keys": [
"domain",
"clamp",
"interpolator",
"range",
"rangeRound",
"unknown",
"exponent",
"ticks",
"tickFormat",
"nice",
"copy"
]
},
"scaleSequentialQuantile": {
"type": "function",
"keys": [
"domain",
"interpolator",
"range",
"quantiles",
"copy"
]
},
"scaleSequentialSqrt": {
"type": "function",
"keys": [
"domain",
"clamp",
"interpolator",
"range",
"rangeRound",
"unknown",
"exponent",
"ticks",
"tickFormat",
"nice",
"copy"
]
},
"scaleSequentialSymlog": {
"type": "function",
"keys": [
"domain",
"clamp",
"interpolator",
"range",
"rangeRound",
"unknown",
"constant",
"ticks",
"tickFormat",
"nice",
"copy"
]
},
"scaleSqrt": {
"type": "function",
"keys": [
"invert",
"domain",
"range",
"rangeRound",
"clamp",
"interpolate",
"unknown",
"exponent",
"ticks",
"tickFormat",
"nice",
"copy"
]
},
"scaleSymlog": {
"type": "function",
"keys": [
"invert",
"domain",
"range",
"rangeRound",
"clamp",
"interpolate",
"unknown",
"constant",
"ticks",
"tickFormat",
"nice",
"copy"
]
},
"scaleThreshold": {
"type": "function",
"keys": [
"domain",
"range",
"invertExtent",
"unknown",
"copy"
]
},
"scaleTime": {
"type": "function",
"keys": [
"invert",
"domain",
"range",
"rangeRound",
"clamp",
"interpolate",
"unknown",
"ticks",
"tickFormat",
"nice",
"copy"
]
},
"scaleUtc": {
"type": "function",
"keys": [
"invert",
"domain",
"range",
"rangeRound",
"clamp",
"interpolate",
"unknown",
"ticks",
"tickFormat",
"nice",
"copy"
]
},
"tickFormat": {
"type": "function",
"keys": [
"toString"
]
}
}
This issue is stale because it has been open for 90 days with no activity. If there is no activity in the next 7 days, the issue will be closed.
This issue was closed because it has been inactive for 7 days since being marked as stale. Please open a new issue if you believe you are encountering a related problem.