11import * as React from 'react' ;
22import Box from '@mui/material/Box' ;
33import Stack from '@mui/material/Stack' ;
4+ import Typography from '@mui/material/Typography' ;
45import ToggleButtonGroup from '@mui/material/ToggleButtonGroup' ;
56import ToggleButton from '@mui/material/ToggleButton' ;
7+ import { interpolateBlues } from 'd3-scale-chromatic' ;
68import { feature as topojsonFeature } from 'topojson-client' ;
79import countriesTopology from 'world-atlas/countries-110m.json' ;
810import { Unstable_ChartsGeoDataProviderPremium as ChartsGeoDataProviderPremium } from '@mui/x-charts-premium/ChartsGeoDataProviderPremium' ;
@@ -16,14 +18,14 @@ import {
1618
1719import { internetUsageByCountry } from '../dataset/internetUsageByCountry' ;
1820import { withCountryCodeAsName , countryData } from '../dataset/countryData' ;
19- import { blue } from '@mui/material/colors' ;
2021
2122const countries = withCountryCodeAsName (
2223 topojsonFeature ( countriesTopology , 'countries' ) ,
2324) ;
2425
2526const data = Object . keys ( countryData ) . map ( ( code ) => ( {
26- name : countryData [ code ] . country ,
27+ name : code ,
28+ label : countryData [ code ] . country ,
2729 colorValue : internetUsageByCountry [ code ] ,
2830} ) ) ;
2931
@@ -43,6 +45,9 @@ export default function ColorScaleMapShape() {
4345 < ToggleButton value = "continuous" > continuous</ ToggleButton >
4446 < ToggleButton value = "piecewise" > piecewise</ ToggleButton >
4547 </ ToggleButtonGroup >
48+ < Typography variant = "body2" component = "h6" sx = { { textAlign : 'end' } } >
49+ Share of the population using the Internet in 2020
50+ </ Typography >
4651 < Box sx = { { width : '100%' } } >
4752 < ChartsGeoDataProviderPremium
4853 geoData = { countries }
@@ -73,7 +78,7 @@ export default function ColorScaleMapShape() {
7378 : {
7479 type : 'piecewise' ,
7580 thresholds : [ 25 , 50 , 75 ] ,
76- colors : [ blue [ 100 ] , blue [ 300 ] , blue [ 500 ] , blue [ 700 ] ] ,
81+ colors : [ 0.25 , 0.5 , 0.75 , 1 ] . map ( interpolateBlues ) ,
7782 } ,
7883 } ,
7984 ] }
@@ -84,7 +89,7 @@ export default function ColorScaleMapShape() {
8489 </ ChartsSurface >
8590 < ChartsTooltip trigger = "item" />
8691 { colorMap === 'continuous' ? (
87- < ContinuousColorLegend axisDirection = "z" />
92+ < ContinuousColorLegend axisDirection = "z" sx = { { maxWidth : 150 } } />
8893 ) : (
8994 < PiecewiseColorLegend axisDirection = "z" direction = "horizontal" />
9095 ) }
0 commit comments