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

feat: migrate heatmap, horizon, iframe and markup #367

Merged
merged 2 commits into from
Apr 15, 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
18 changes: 17 additions & 1 deletion packages/superset-ui-demo/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const packages = readdirSync(basePath).filter(name => {
return stat.isSymbolicLink();
});

const PLUGIN_PACKAGES_PATH_REGEXP = new RegExp(
`${path.resolve(__dirname, '../../../plugins/(legacy-)*(plugin|preset)-')}.+/src`,
);

module.exports = {
addons: [
'@storybook/preset-typescript',
Expand All @@ -20,6 +24,17 @@ module.exports = {
'../storybook/stories/**/*Stories.[tj]sx',
],
webpackFinal: config => {

// Make sure babel is applied to the package src
// These are excluded by the default rule
// because they reside in node_modules
config.module.rules.push({
include: PLUGIN_PACKAGES_PATH_REGEXP,
exclude: /node_modules/,
test: /\.jsx?$/,
use: config.module.rules[0].use,
});

config.module.rules.push({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule only applies to typescript. but there are older packages that are jsx.

test: /\.tsx?$/,
use: [
Expand All @@ -30,7 +45,8 @@ module.exports = {
});

config.resolve.extensions.push('.ts', '.tsx');
// let webpack know where to find the source code

// Let webpack know where to find the source code
Object.assign(config.resolve.alias, {
...packages.reduce(
(acc, name) => ({
Expand Down
4 changes: 4 additions & 0 deletions packages/superset-ui-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
"@superset-ui/connection": "0.12.18",
"@superset-ui/legacy-plugin-chart-calendar": "0.12.18",
"@superset-ui/legacy-plugin-chart-chord": "0.12.18",
"@superset-ui/legacy-plugin-chart-heatmap": "^0.11.15",
"@superset-ui/legacy-plugin-chart-horizon": "^0.11.15",
"@superset-ui/legacy-plugin-chart-iframe": "^0.11.15",
"@superset-ui/legacy-plugin-chart-markup": "^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,85 @@
import React from 'react';
import { SuperChart } from '@superset-ui/chart';
import HeatmapChartPlugin from '@superset-ui/legacy-plugin-chart-heatmap';
import data from './data';

new HeatmapChartPlugin().configure({ key: 'heatmap' }).register();

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

export const basic = () => (
<SuperChart
chartType="heatmap"
width={400}
height={400}
formData={{
allColumnsX: 'source',
allColumnsY: 'target',
bottomMargin: 'auto',
canvasImageRendering: 'pixelated',
leftMargin: 'auto',
linearColorScheme: 'blue_white_yellow',
metric: 'sum__value',
normalized: false,
showLegend: true,
showPerc: true,
showValues: false,
sortXAxis: 'alpha_asc',
sortYAxis: 'alpha_asc',
xscaleInterval: '1',
yAxisBounds: [null, null],
yAxisFormat: '.3s',
yscaleInterval: '1',
}}
queryData={{
data: {
records: data,
extents: [0.1, 24.9],
},
}}
/>
);

export const withNullData = () => (
<SuperChart
chartType="heatmap"
width={400}
height={400}
formData={{
allColumnsX: 'source',
allColumnsY: 'target',
bottomMargin: 'auto',
canvasImageRendering: 'pixelated',
leftMargin: 'auto',
linearColorScheme: 'blue_white_yellow',
metric: 'sum__value',
normalized: false,
showLegend: true,
showPerc: true,
showValues: false,
sortXAxis: 'alpha_asc',
sortYAxis: 'alpha_asc',
xscaleInterval: '1',
yAxisBounds: [null, null],
yAxisFormat: '.3s',
yscaleInterval: '1',
}}
queryData={{
data: {
records: [
...data,
{
x: null,
y: 'Electricity and heat',
v: 25.9,
perc: 0.43,
rank: 1.0,
},
],
extents: [0.1, 24.9],
},
}}
/>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
export default [
{
x: 'Energy',
y: 'Electricity and heat',
v: 24.9,
perc: 1.0,
rank: 1.0,
},
{
x: 'Energy',
y: 'Industry',
v: 14.7,
perc: 0.5887096774193549,
rank: 0.9882352941176471,
},
{
x: 'Energy',
y: 'Transportation',
v: 14.3,
perc: 0.5725806451612905,
rank: 0.9764705882352941,
},
{
x: 'Deforestation',
y: 'Carbon Dioxide',
v: 10.9,
perc: 0.435483870967742,
rank: 0.9588235294117647,
},
{
x: 'Land Use Change',
y: 'Deforestation',
v: 10.9,
perc: 0.435483870967742,
rank: 0.9588235294117647,
},
{
x: 'Road',
y: 'Carbon Dioxide',
v: 10.5,
perc: 0.4193548387096775,
rank: 0.9352941176470588,
},
{
x: 'Transportation',
y: 'Road',
v: 10.5,
perc: 0.4193548387096775,
rank: 0.9352941176470588,
},
{
x: 'Residential Buildings',
y: 'Carbon Dioxide',
v: 10.2,
perc: 0.40725806451612906,
rank: 0.9176470588235294,
},
{
x: 'Energy',
y: 'Other Fuel Combustion',
v: 8.6,
perc: 0.342741935483871,
rank: 0.9058823529411765,
},
{
x: 'Other Industry',
y: 'Carbon Dioxide',
v: 6.6,
perc: 0.26209677419354843,
rank: 0.8941176470588236,
},
{
x: 'Commercial Buildings',
y: 'Carbon Dioxide',
v: 6.3,
perc: 0.25000000000000006,
rank: 0.8823529411764706,
},
{
x: 'Agriculture',
y: 'Livestock and Manure',
v: 5.4,
perc: 0.2137096774193549,
rank: 0.8705882352941177,
},
{
x: 'Agriculture',
y: 'Agriculture Soils',
v: 5.2,
perc: 0.20564516129032262,
rank: 0.8470588235294118,
},
{
x: 'Agriculture Soils',
y: 'Nitrous Oxide',
v: 5.2,
perc: 0.20564516129032262,
rank: 0.8470588235294118,
},
{
x: 'Oil and Gas Processing',
y: 'Methane',
v: 2.8,
perc: 0.10887096774193548,
rank: 0.6705882352941176,
},
{
x: 'Electricity and heat',
y: 'Other Industry',
v: 2.7,
perc: 0.10483870967741937,
rank: 0.6470588235294118,
},
{
x: 'Rail - Ship and Other Transport',
y: 'Carbon Dioxide',
v: 2.5,
perc: 0.09677419354838711,
rank: 0.6294117647058823,
},
{
x: 'Transportation',
y: 'Rail - Ship and Other Transport',
v: 2.5,
perc: 0.09677419354838711,
rank: 0.6294117647058823,
},
{
x: 'Electricity and heat',
y: 'T and D Losses',
v: 2.2,
perc: 0.08467741935483872,
rank: 0.6058823529411764,
},
{
x: 'T and D Losses',
y: 'Carbon Dioxide',
v: 2.2,
perc: 0.08467741935483872,
rank: 0.6058823529411764,
},
{
x: 'Electricity and heat',
y: 'Unallocated Fuel Combustion',
v: 2.0,
perc: 0.07661290322580645,
rank: 0.5882352941176471,
},
{
x: 'Industry',
y: 'Cement',
v: 1.9,
perc: 0.07258064516129033,
rank: 0.5764705882352941,
},
{
x: 'Other Fuel Combustion',
y: 'Unallocated Fuel Combustion',
v: 1.8,
perc: 0.0685483870967742,
rank: 0.5647058823529412,
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { SuperChart } from '@superset-ui/chart';
import HorizonChartPlugin from '@superset-ui/legacy-plugin-chart-horizon';
import data from './data';

new HorizonChartPlugin().configure({ key: 'horizon' }).register();

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

export const basic = () => (
<SuperChart
chartType="horizon"
width={400}
height={400}
queryData={{ data }}
formData={{
horizonColorScale: 'series',
seriesHeight: '25',
}}
/>
);
Loading