Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

feat(legacy-plugin-chart-country-map): migrate and replace india map #376

Merged
merged 6 commits into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions 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
1 change: 1 addition & 0 deletions packages/superset-ui-demo/package.json
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