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

Commit

Permalink
feat(legacy-plugin-chart-partition): migrate from another repo
Browse files Browse the repository at this point in the history
  • Loading branch information
kristw committed Apr 15, 2020
1 parent 52e7119 commit 1ab9fea
Show file tree
Hide file tree
Showing 12 changed files with 777 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/superset-ui-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@superset-ui/legacy-plugin-chart-markup": "^0.11.15",
"@superset-ui/legacy-plugin-chart-paired-t-test": "^0.11.15",
"@superset-ui/legacy-plugin-chart-parallel-coordinates": "^0.11.15",
"@superset-ui/legacy-plugin-chart-partition": "^0.11.15",
"@superset-ui/legacy-plugin-chart-sankey": "^0.11.15",
"@superset-ui/legacy-plugin-chart-sunburst": "^0.11.15",
"@superset-ui/legacy-plugin-chart-table": "0.12.18",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import { SuperChart } from '@superset-ui/chart';
import PartitionChartPlugin from '@superset-ui/legacy-plugin-chart-partition';
import data from './data';
import dummyDatasource from '../../../shared/dummyDatasource';

new PartitionChartPlugin().configure({ key: 'partition' }).register();

export default {
title: 'Legacy Chart Plugins|legacy-plugin-chart-partition',
};

export const basic = () => (
<SuperChart
chartType="partition"
width={400}
height={400}
datasource={dummyDatasource}
queryData={{ data }}
formData={{
colorScheme: 'd3Category10',
dateTimeFormat: '%Y-%m-%d',
equalDateSize: true,
groupby: ['region', 'country_code'],
logScale: false,
metrics: ['sum__SP_POP_TOTL'],
numberFormat: '.3s',
partitionLimit: '5',
partitionThreshold: '0.05',
richTooltip: true,
timeSeriesOption: 'not-time',
}}
/>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
export default [
{
name: 'World',
val: 165709793794.0,
children: [
{
name: 'East Asia & Pacific',
val: 74157936990.0,
children: [
{
name: 'CHN',
val: 58345455000.0,
children: [],
},
{
name: 'IDN',
val: 9357861231.0,
children: [],
},
{
name: 'JPN',
val: 6454620759.0,
children: [],
},
],
},
{
name: 'Europe & Central Asia',
val: 7667188460.0,
children: [
{
name: 'RUS',
val: 7667188460.0,
children: [],
},
],
},
{
name: 'Latin America & Caribbean',
val: 7752058955.0,
children: [
{
name: 'BRA',
val: 7752058955.0,
children: [],
},
],
},
{
name: 'North America',
val: 13604468357.0,
children: [
{
name: 'USA',
val: 13604468357.0,
children: [],
},
],
},
{
name: 'South Asia',
val: 57268340539.0,
children: [
{
name: 'BGD',
val: 5549261462.0,
children: [],
},
{
name: 'IND',
val: 46023037597.0,
children: [],
},
{
name: 'PAK',
val: 5696041480.0,
children: [],
},
],
},
{
name: 'Sub-Saharan Africa',
val: 5259800493.0,
children: [
{
name: 'NGA',
val: 5259800493.0,
children: [],
},
],
},
],
},
];
32 changes: 32 additions & 0 deletions plugins/legacy-plugin-chart-partition/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## @superset-ui/legacy-plugin-chart-partition

[![Version](https://img.shields.io/npm/v/@superset-ui/legacy-plugin-chart-partition.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/legacy-plugin-chart-partition.svg?style=flat-square)
[![David (path)](https://img.shields.io/david/apache-superset/superset-ui-plugins.svg?path=packages%2Fsuperset-ui-legacy-plugin-chart-partition&style=flat-square)](https://david-dm.org/apache-superset/superset-ui-plugins?path=packages/superset-ui-legacy-plugin-chart-partition)

This plugin provides Partition for Superset.

### Usage

Configure `key`, which can be any `string`, and register the plugin. This `key` will be used to lookup this chart throughout the app.

```js
import PartitionChartPlugin from '@superset-ui/legacy-plugin-chart-partition';

new PartitionChartPlugin()
.configure({ key: 'partition' })
.register();
```

Then use it via `SuperChart`. See [storybook](https://apache-superset.github.io/superset-ui-plugins/?selectedKind=plugin-chart-partition) for more details.

```js
<SuperChart
chartType="partition"
width={600}
height={600}
formData={...}
queryData={{
data: {...},
}}
/>
```
42 changes: 42 additions & 0 deletions plugins/legacy-plugin-chart-partition/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "@superset-ui/legacy-plugin-chart-partition",
"version": "0.11.15",
"description": "Superset Legacy Chart - Partition",
"sideEffects": [
"*.css"
],
"main": "lib/index.js",
"module": "esm/index.js",
"files": [
"esm",
"lib"
],
"repository": {
"type": "git",
"url": "git+https://github.com/apache-superset/superset-ui-plugins.git"
},
"keywords": [
"superset"
],
"author": "Superset",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/apache-superset/superset-ui-plugins/issues"
},
"homepage": "https://github.com/apache-superset/superset-ui-plugins#readme",
"publishConfig": {
"access": "public"
},
"dependencies": {
"d3": "^3.5.17",
"d3-hierarchy": "^1.1.8",
"prop-types": "^15.6.2"
},
"peerDependencies": {
"@superset-ui/chart": "^0.12.0",
"@superset-ui/color": "^0.12.0",
"@superset-ui/number-format": "^0.12.0",
"@superset-ui/time-format": "^0.12.0",
"@superset-ui/translation": "^0.12.0"
}
}
64 changes: 64 additions & 0 deletions plugins/legacy-plugin-chart-partition/src/Partition.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
.superset-legacy-chart-partition {
position: relative;
}

.superset-legacy-chart-partition .chart {
display: block;
margin: auto;
font-size: 11px;
}

.superset-legacy-chart-partition rect {
stroke: #eee;
fill: #aaa;
fill-opacity: 0.8;
transition: fill-opacity 180ms linear;
cursor: pointer;
}

.superset-legacy-chart-partition rect:hover {
fill-opacity: 1;
}

.superset-legacy-chart-partition g text {
font-weight: bold;
fill: rgba(0, 0, 0, 0.8);
}

.superset-legacy-chart-partition g:hover text {
fill: rgba(0, 0, 0, 1);
}

.superset-legacy-chart-partition .partition-tooltip {
position: absolute;
top: 0;
left: 0;
opacity: 0;
padding: 5px;
pointer-events: none;
background-color: rgba(255, 255, 255, 0.75);
border-radius: 5px;
}

.partition-tooltip td {
padding-left: 5px;
font-size: 11px;
}
Loading

0 comments on commit 1ab9fea

Please sign in to comment.