Skip to content

Commit

Permalink
feat(legacy-plugin-chart-country-map): migrate and replace india map (a…
Browse files Browse the repository at this point in the history
…pache#376)

* feat(legacy-plugin-chart-country-map): migrate and replace india map with smaller file

* fix: lint

* chore: move files

* docs: update storybook

* docs: wire storybook

* fix: lint
  • Loading branch information
kristw authored and zhaoyongjie committed Nov 17, 2021
1 parent 70baa99 commit 07b1a28
Show file tree
Hide file tree
Showing 47 changed files with 320 additions and 2,108,830 deletions.
28 changes: 12 additions & 16 deletions superset-frontend/temporary_superset_ui/superset-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,19 @@ Current master: https://superset-ui.now.sh/
| [@superset-ui/generator-superset](https://github.com/apache-superset/superset-ui/tree/master/packages/superset-ui-generator-superset) | [![Version](https://img.shields.io/npm/v/@superset-ui/generator-superset.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/generator-superset.svg?style=flat-square) |
| [@superset-ui/number-format](https://github.com/apache-superset/superset-ui/tree/master/packages/superset-ui-number-format) | [![Version](https://img.shields.io/npm/v/@superset-ui/number-format.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/number-format.svg?style=flat-square) |
| [@superset-ui/query](https://github.com/apache-superset/superset-ui/tree/master/packages/superset-ui-query) | [![Version](https://img.shields.io/npm/v/@superset-ui/query.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/query.svg?style=flat-square) |
| [@superset-ui/style](https://github.com/apache-superset/superset-ui/tree/master/packages/superset-ui-style) | [![Version](https://img.shields.io/npm/v/@superset-ui/style.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/style.svg?style=flat-square) |
| [@superset-ui/style](https://github.com/apache-superset/superset-ui/tree/master/packages/superset-ui-style) | [![Version](https://img.shields.io/npm/v/@superset-ui/style.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/style.svg?style=flat-square) |
| [@superset-ui/time-format](https://github.com/apache-superset/superset-ui/tree/master/packages/superset-ui-time-format) | [![Version](https://img.shields.io/npm/v/@superset-ui/time-format.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/time-format.svg?style=flat-square) |
| [@superset-ui/translation](https://github.com/apache-superset/superset-ui/tree/master/packages/superset-ui-translation) | [![Version](https://img.shields.io/npm/v/@superset-ui/translation.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/translation.svg?style=flat-square) |


### Chart plugin packages

`@superset-ui/legacy-*` packages are extracted from the classic
[Apache Superset](https://github.com/apache/incubator-superset) and converted into plugins. These
packages are extracted with minimal changes (almost as-is). They also depend on legacy API
(`viz.py`) to function.


| Package | Version |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Package | Version |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [@superset-ui/legacy-preset-chart-big-number](https://github.com/apache-superset/superset-ui/tree/master/plugins/legacy-preset-chart-big-number) | [![Version](https://img.shields.io/npm/v/@superset-ui/legacy-preset-chart-big-number.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/legacy-preset-chart-big-number.svg?style=flat-square) |
| [@superset-ui/legacy-preset-chart-nvd3](https://github.com/apache-superset/superset-ui/tree/master/plugins/legacy-preset-chart-nvd3) | [![Version](https://img.shields.io/npm/v/@superset-ui/legacy-preset-chart-nvd3.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/legacy-preset-chart-nvd3.svg?style=flat-square) |
| [@superset-ui/legacy-plugin-chart-calendar](https://github.com/apache-superset/superset-ui/tree/master/plugins/legacy-plugin-chart-calendar) | [![Version](https://img.shields.io/npm/v/@superset-ui/legacy-plugin-chart-calendar.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/legacy-plugin-chart-calendar.svg?style=flat-square) |
Expand All @@ -71,18 +69,16 @@ packages are extracted with minimal changes (almost as-is). They also depend on
| [@superset-ui/legacy-plugin-chart-word-cloud](https://github.com/apache-superset/superset-ui/tree/master/plugins/legacy-plugin-chart-word-cloud) | [![Version](https://img.shields.io/npm/v/@superset-ui/legacy-plugin-chart-word-cloud.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/legacy-plugin-chart-word-cloud.svg?style=flat-square) |
| [@superset-ui/legacy-plugin-chart-world-map](https://github.com/apache-superset/superset-ui/tree/master/plugins/legacy-plugin-chart-world-map) | [![Version](https://img.shields.io/npm/v/@superset-ui/legacy-plugin-chart-world-map.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/legacy-plugin-chart-world-map.svg?style=flat-square) |

`@superset-ui/plugin-*` packages are newer and higher quality in general. A key difference that they
do not depend on `viz.py` (which contain visualization-specific python code) and interface with
`/api/v1/query/`, a new generic endpoint instead meant to serve all visualizations, instead. Also
should be written in Typescript.

`@superset-ui/plugin-*` packages are newer and higher quality in general.
A key difference that they do not depend on `viz.py` (which contain visualization-specific python code)
and interface with `/api/v1/query/`, a new generic endpoint instead meant to serve all visualizations, instead.
Also should be written in Typescript.

| Package | Version | Note |
| ------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ |
| [@superset-ui/plugin-chart-word-cloud](https://github.com/apache-superset/superset-ui/tree/master/plugins/plugin-chart-word-cloud) | [![Version](https://img.shields.io/npm/v/@superset-ui/plugin-chart-word-cloud.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/plugin-chart-word-cloud.svg?style=flat-square) | |
| [@superset-ui/plugin-chart-table](https://github.com/apache-superset/superset-ui/tree/master/plugins/plugin-chart-table) | [![Version](https://img.shields.io/npm/v/@superset-ui/plugin-chart-table.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/plugin-chart-table.svg?style=flat-square) | |
| [@superset-ui/preset-chart-xy](https://github.com/apache-superset/superset-ui/tree/master/plugins/preset-chart-xy) | [![Version](https://img.shields.io/npm/v/@superset-ui/preset-chart-xy.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/preset-chart-xy.svg?style=flat-square) | |

| Package | Version | Note |
| ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---- |
| [@superset-ui/plugin-chart-word-cloud](https://github.com/apache-superset/superset-ui/tree/master/plugins/plugin-chart-word-cloud) | [![Version](https://img.shields.io/npm/v/@superset-ui/plugin-chart-word-cloud.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/plugin-chart-word-cloud.svg?style=flat-square) | |
| [@superset-ui/plugin-chart-table](https://github.com/apache-superset/superset-ui/tree/master/plugins/plugin-chart-table) | [![Version](https://img.shields.io/npm/v/@superset-ui/plugin-chart-table.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/plugin-chart-table.svg?style=flat-square) | |
| [@superset-ui/preset-chart-xy](https://github.com/apache-superset/superset-ui/tree/master/plugins/preset-chart-xy) | [![Version](https://img.shields.io/npm/v/@superset-ui/preset-chart-xy.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/preset-chart-xy.svg?style=flat-square) | |

## Contribution and development guide

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@superset-ui/color": "0.12.19",
"@superset-ui/connection": "0.12.19",
"@superset-ui/legacy-plugin-chart-calendar": "0.12.20",
"@superset-ui/legacy-plugin-chart-country-map": "^0.11.15",
"@superset-ui/legacy-plugin-chart-chord": "0.12.20",
"@superset-ui/legacy-plugin-chart-force-directed": "^0.11.15",
"@superset-ui/legacy-plugin-chart-heatmap": "0.12.20",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* eslint-disable no-magic-numbers */
import React from 'react';
import { SuperChart } from '@superset-ui/chart';
import CountryMapChartPlugin from '@superset-ui/legacy-plugin-chart-country-map';
import countries from '@superset-ui/legacy-plugin-chart-country-map/esm/countries';
import { withKnobs, select } from '@storybook/addon-knobs';
import data from './data';

new CountryMapChartPlugin().configure({ key: 'country-map' }).register();

export default {
title: 'Legacy Chart Plugins|legacy-plugin-chart-country-map',
decorators: [withKnobs],
};

export const basic = () => (
<SuperChart
chartType="country-map"
width={400}
height={400}
queryData={{ data }}
formData={{
linearColorScheme: 'schemeRdYlBu',
numberFormat: '.3s',
selectCountry: select('Country', Object.keys(countries!), 'france', 'country'),
}}
/>
);
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ function CountryMap(element, props) {
.classed('text-layer', true)
.attr('transform', `translate(${width / 2}, 45)`);
const bigText = textLayer.append('text').classed('big-text', true);
const resultText = textLayer
.append('text')
.classed('result-text', true)
.attr('dy', '1em');
const resultText = textLayer.append('text').classed('result-text', true).attr('dy', '1em');

let centered;

Expand Down Expand Up @@ -149,10 +146,7 @@ function CountryMap(element, props) {
// Darken color
let c = colorFn(d);
if (c !== 'none') {
c = d3
.rgb(c)
.darker()
.toString();
c = d3.rgb(c).darker().toString();
}
d3.select(this).style('fill', c);
selectAndDisplayNameOfRegion(d);
Expand Down
Loading

0 comments on commit 07b1a28

Please sign in to comment.