Guarantee data passed to react-native-chart-kit is not NaN

Related to #206.
This commit is contained in:
Brandon Presley 2024-02-09 12:58:19 +13:00
parent 4c065a027b
commit 89b62d69aa
4 changed files with 7 additions and 5 deletions

View File

@ -19,6 +19,8 @@ export default function AppLineChart({ labels, data }: ChartProps) {
color: () => colors.primary,
};
const validData = useMemo(() => data.map(d => isNaN(d) ? 0 : d), [data])
const pruned = useMemo(() => {
if (labels.length < 3) return labels;
const newPruned = [labels[0]];
@ -39,7 +41,7 @@ export default function AppLineChart({ labels, data }: ChartProps) {
labels: pruned,
datasets: [
{
data,
data: validData,
},
],
}}

View File

@ -23,7 +23,7 @@ export default function AppPieChart({ options }: { options: Option[] }) {
const data = options.map((option, index) => ({
name: option.label,
value: option.value,
value: isNaN(option.value) ? 0 : option.value,
color: pieChartColors[index],
legendFontColor: colors.onSurface,
legendFontSize: 15,

View File

@ -85,8 +85,8 @@ android {
applicationId "com.massive"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 36230
versionName "2.15"
versionCode 36231
versionName "2.16"
}
signingConfigs {
release {

View File

@ -1,6 +1,6 @@
{
"name": "massive",
"version": "2.15",
"version": "2.16",
"private": true,
"license": "GPL-3.0-only",
"scripts": {