Skip to content

Commit

Permalink
Fix donut chart
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafasaifee42 committed Oct 30, 2024
1 parent 6473e50 commit 8a3b2e4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@undp-data/undp-visualization-library",
"version": "0.1.33",
"version": "0.1.34",
"main": "./dist/index.umd.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
12 changes: 5 additions & 7 deletions src/Components/Graphs/DonutChart/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { UNDPColorModule } from '../../ColorPalette';
import { numberFormattingFunction } from '../../../Utils/numberFormattingFunction';

interface Props {
mainText?: string | { indicator: string; suffix?: string; prefix?: string };
mainText?: string | { label: string; suffix?: string; prefix?: string };
radius: number;
colors: string[];
subNote?: string;
Expand Down Expand Up @@ -94,12 +94,10 @@ export function Graph(props: Props) {
>
{typeof mainText === 'string'
? mainText
: data.findIndex(d => d.label === mainText.indicator) !==
-1
: data.findIndex(d => d.label === mainText.label) !== -1
? numberFormattingFunction(
data[
data.findIndex(d => d.label === mainText.indicator)
].size,
data[data.findIndex(d => d.label === mainText.label)]
.size,
mainText.prefix,
mainText.suffix,
)
Expand Down Expand Up @@ -134,7 +132,7 @@ export function Graph(props: Props) {
color: UNDPColorModule[mode || 'light'].grays.black,
}}
>
{mainText.indicator}
{mainText.label}
</p>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Graphs/DonutChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { UNDPColorModule } from '../../ColorPalette';
import { checkIfNullOrUndefined } from '../../../Utils/checkIfNullOrUndefined';

interface Props {
mainText?: string | { indicator: string; suffix?: string; prefix?: string };
mainText?: string | { label: string; suffix?: string; prefix?: string };
data: DonutChartDataType[];
colors?: string[];
graphTitle?: string;
Expand Down

0 comments on commit 8a3b2e4

Please sign in to comment.