-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Library] Allow stat var <> color mapping to be set by users (#2919)
Adds an optional "colors" attribute to each of the chart web components, to allow the user to set specific colors for the stat vars being plotted. Any CSS valid color value is allowed. Changes made: * `colors` attribute is added to each chart web component * the corresponding tile gets color added as a chart option * some cleanup of attributes/props -- resorted to alphabetical order * Examples and docs are updated Examples: ``` <datacommons-bar title="Median income by gender of select US states (grouped)" comparisonVariables="Median_Income_Person_15OrMoreYears_Male_WithIncome Median_Income_Person_15OrMoreYears_Female_WithIncome" comparisonPlaces="geoId/01 geoId/02 geoId/04 geoId/05" colors="#4287f5 #f542a4" ></datacommons-bar> ``` ![Screenshot 2023-07-11 at 1 37 09 PM](https://github.com/datacommonsorg/website/assets/4034366/36f6b322-639a-436e-94f0-c2442d7b050e) For the maps, providing up to three colors are supported (will ignore colors past the first three): For a single color, we get a luminance based color scale ``` <datacommons-map title="Population" place="country/USA" childPlaceType="State" variable="Count_Person" colors="red" ></datacommons-map> ``` ![Screenshot 2023-07-11 at 1 17 05 PM](https://github.com/datacommonsorg/website/assets/4034366/01eadecd-2f1b-4467-a611-fb8ac2853f34) For two colors, we get a diverging color scale ``` <datacommons-map title="Population" place="country/USA" childPlaceType="State" variable="Count_Person" colors="blue red" ></datacommons-map> ``` ![Screenshot 2023-07-11 at 1 16 40 PM](https://github.com/datacommonsorg/website/assets/4034366/9196c6af-a1f0-49ee-be4d-d1232bd69940) For three colors, we have [min, mean, max] mapping: ``` <datacommons-map title="Population" place="country/USA" childPlaceType="State" variable="Count_Person" colors="blue purple red" ></datacommons-map> ``` ![Screenshot 2023-07-11 at 1 17 27 PM](https://github.com/datacommonsorg/website/assets/4034366/64d66b55-ad7b-4777-a038-a5d60b150b9d)
- Loading branch information
Showing
16 changed files
with
335 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.