-
-
Notifications
You must be signed in to change notification settings - Fork 662
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
Creating Contribution Graph with only one value returns error #425
Comments
It's not just a single value. Using this data: Anyone know how I could extend the current class to fix this issue temporarily? (Edit OK filed a PR, but here's a temp solution): function mapValue(
x: number,
in_min: number,
in_max: number,
out_min: number,
out_max: number
) {
return ((x - in_min) * (out_max - out_min)) / (in_max - in_min) + out_min;
}
class Blah extends ContributionGraph {
getClassNameForIndex(index: number) {
if (this.state.valueCache[index]) {
if (this.state.valueCache[index].value) {
const count = this.state.valueCache[index].value[this.props.accessor];
if (count) {
console.log(this.state.minValue,this.state.maxValue);
const opacity = mapValue(
count,
this.state.maxValue === this.state.minValue ? 0: this.state.minValue,
isNaN(this.state.maxValue) ? 1 : this.state.maxValue,
0.15 + 0.05, // + 0.05 to make smaller values a bit more visible
1
);
console.log(this.state.minValue, this.state.maxValue, this.state.maxValue || this.state.minValue, opacity);
return this.props.chartConfig.color(opacity);
}
}
}
return this.props.chartConfig.color(0.15);
}
} |
If you create a contribution graph with only one date it will return: "rgba(255,82,82, NaN) is not a valid color. Probably due to the fact that opacity is compared with other values to be determined. In this case, I think it is possible to default count to 0 if no other record is provided.
The text was updated successfully, but these errors were encountered: