Skip to content

Commit 149f1d0

Browse files
Add styling to the label in dot desity and hybrid maps
1 parent b539e64 commit 149f1d0

9 files changed

Lines changed: 65 additions & 54 deletions

File tree

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@undp/data-viz",
3-
"version": "2.1.7",
3+
"version": "2.1.9",
44
"main": "./dist/index.cjs",
55
"module": "./dist/index.js",
66
"browser": "./dist/index.umd.js",
@@ -470,7 +470,7 @@
470470
"peerDependencies": {
471471
"@dnd-kit/core": "^6.3.1",
472472
"@dnd-kit/modifiers": "^9.0.0",
473-
"@undp/design-system-react": "^1.5.3",
473+
"@undp/design-system-react": "^1.5.5",
474474
"ajv": "^8.17.1",
475475
"dom-to-svg": "^0.12.2",
476476
"file-saver": "^2.0.5",

src/App.tsx

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,35 @@
1-
import { A, H3, P } from '@undp/design-system-react/Typography';
21
import '@undp/design-system-react/style.css';
32
import './styles/styles.css';
3+
import { DotDensityMap } from './Components/Graphs/Maps/DotDensityMap';
44

55
function App() {
66
return (
7-
<div
8-
style={{
9-
height: '90vh',
10-
maxWidth: '712px',
11-
margin: '0 auto',
12-
padding: '2rem',
13-
display: 'flex',
14-
flexDirection: 'column',
15-
justifyContent: 'center',
16-
alignItems: 'center',
17-
}}
18-
>
19-
<img width='56' alt='undp-logo' src='/undp-logo-blue.svg' />
20-
<H3 style={{ textAlign: 'center', paddingTop: '24px' }}>UNDP Data Visualization Library</H3>
21-
<P style={{ textAlign: 'center' }}>
22-
This visualization library for react, developed by the United Nations Development Programme,
23-
offers various interactive visualizations such as graphs, maps, and animated charts. You can
24-
access the documentation{' '}
25-
<A href='https://dataviz.design.undp.org/' target='_blank' rel='noreferrer'>
26-
here
27-
</A>
28-
.
29-
</P>
30-
<P
31-
style={{
32-
textAlign: 'center',
33-
}}
34-
>
35-
For any feedback or inquiries, please feel free to reach out to us at{' '}
36-
<A href='mailto:data@undp.org' target='_blank' rel='noreferrer'>
37-
data@undp.org
38-
</A>
39-
</P>
40-
</div>
7+
<DotDensityMap
8+
data={[
9+
{
10+
lat: 20,
11+
long: 10,
12+
},
13+
{
14+
lat: 25,
15+
long: 26,
16+
},
17+
{
18+
lat: 0,
19+
long: 0,
20+
},
21+
{
22+
lat: 15,
23+
long: 5,
24+
},
25+
{
26+
lat: 10,
27+
long: 20,
28+
},
29+
]}
30+
onSeriesMouseClick={function YJ() {}}
31+
onSeriesMouseOver={function YJ() {}}
32+
/>
4133
);
4234
}
4335

src/Components/Graphs/BarGraph/SimpleBarGraph/Graph.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ export function VerticalGraph(props: Props) {
789789
className={cn(
790790
'graph-value text-sm',
791791
!valueColor && barColor.length > 1
792-
? ' fill-primary-gray-600 dark:fill-primary-gray-300'
792+
? 'fill-primary-gray-600 dark:fill-primary-gray-300'
793793
: '',
794794
classNames?.graphObjectValues,
795795
)}

src/Components/Graphs/Maps/DotDensityMap/Graph.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,19 +390,34 @@ export function Graph(props: Props) {
390390
initial: {
391391
opacity: 0,
392392
x: !radiusScale ? radius : radiusScale(d.radius || 0),
393+
fill:
394+
data.filter(el => el.color).length === 0
395+
? colors[0]
396+
: !d.color
397+
? Colors.gray
398+
: colors[colorDomain.indexOf(`${d.color}`)],
393399
},
394400
whileInView: {
395401
opacity: 1,
396402
x: !radiusScale ? radius : radiusScale(d.radius || 0),
397403
transition: { duration: animate.duration },
404+
fill:
405+
data.filter(el => el.color).length === 0
406+
? colors[0]
407+
: !d.color
408+
? Colors.gray
409+
: colors[colorDomain.indexOf(`${d.color}`)],
398410
},
399411
}}
400412
initial='initial'
401413
animate={isInView ? 'whileInView' : 'initial'}
402414
exit={{ opacity: 0, transition: { duration: animate.duration } }}
403415
y={0}
404-
className='fill-primary-gray-600 dark:fill-primary-gray-300 text-sm'
405-
style={{ textAnchor: 'start' }}
416+
className={cn('graph-value text-sm', classNames?.graphObjectValues)}
417+
style={{
418+
textAnchor: 'start',
419+
...(styles?.graphObjectValues || {}),
420+
}}
406421
dx={4}
407422
dy={5}
408423
>

src/Components/Graphs/Maps/DotDensityMap/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ interface Props {
4848
/** Color or array of colors for the circle */
4949
colors?: string | string[];
5050
/** Domain of colors for the graph */
51-
colorDomain: string[];
51+
colorDomain?: string[];
5252
/** Title for the color legend */
5353
colorLegendTitle?: string;
5454
/** Color for the areas where data is no available */

src/Components/Graphs/Maps/HybridMap/Graph.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,12 @@ export function Graph(props: Props) {
550550
animate={isInView ? 'whileInView' : 'initial'}
551551
exit={{ opacity: 0, transition: { duration: animate.duration } }}
552552
y={0}
553-
className='text-sm'
554-
style={{ textAnchor: 'start', fill: labelColor || '#000' }}
553+
className={cn('text-sm', classNames?.graphObjectValues)}
554+
style={{
555+
textAnchor: 'start',
556+
fill: labelColor || '#000',
557+
...(styles?.graphObjectValues || {}),
558+
}}
555559
dx={4}
556560
dy={5}
557561
>

src/stories/Graph+Maps+Charts/Maps/DotDensityMap.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ const meta: Meta<PagePropsAndCustomArgs> = {
244244
centerPoint={parseValue(centerPoint)}
245245
zoomTranslateExtend={parseValue(zoomTranslateExtend)}
246246
zoomScaleExtend={parseValue(zoomScaleExtend)}
247-
colorDomain={parseValue(colorDomain, [2, 4, 6, 8])}
247+
colorDomain={parseValue(colorDomain)}
248248
backgroundColor={
249249
backgroundColor === 'false' ? false : backgroundColor === 'true' ? true : backgroundColor
250250
}

src/stories/Graph+Maps+Charts/Maps/DotDensityMapAnimated.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ const meta: Meta<PagePropsAndCustomArgs> = {
292292
centerPoint={parseValue(centerPoint)}
293293
zoomTranslateExtend={parseValue(zoomTranslateExtend)}
294294
zoomScaleExtend={parseValue(zoomScaleExtend)}
295-
colorDomain={parseValue(colorDomain, [2, 4, 6, 8])}
295+
colorDomain={parseValue(colorDomain)}
296296
backgroundColor={
297297
backgroundColor === 'false' ? false : backgroundColor === 'true' ? true : backgroundColor
298298
}

0 commit comments

Comments
 (0)