refactor(monorepo): move superset-ui to superset(stage 2) (#17552)

This commit is contained in:
Yongjie Zhao
2021-11-30 08:29:57 +08:00
committed by GitHub
parent bfba4f1689
commit 3c41ff68a4
1315 changed files with 27755 additions and 15167 deletions

View File

@@ -0,0 +1,35 @@
<!--
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.
-->
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [0.18.0](https://github.com/apache-superset/superset-ui/compare/v0.17.87...v0.18.0) (2021-08-30)
**Note:** Version bump only for package @superset-ui/legacy-plugin-chart-parallel-coordinates
## [0.17.61](https://github.com/apache-superset/superset-ui/compare/v0.17.60...v0.17.61) (2021-07-02)
**Note:** Version bump only for package @superset-ui/legacy-plugin-chart-parallel-coordinates

View File

@@ -0,0 +1,54 @@
<!--
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-ui/legacy-plugin-chart-parallel-coordinates
[![Version](https://img.shields.io/npm/v/@superset-ui/legacy-plugin-chart-parallel-coordinates.svg?style=flat-square)](https://www.npmjs.com/package/@superset-ui/legacy-plugin-chart-parallel-coordinates)
[![David (path)](https://img.shields.io/david/apache-superset/superset-ui-plugins.svg?path=packages%2Fsuperset-ui-legacy-plugin-chart-parallel-coordinates&style=flat-square)](https://david-dm.org/apache-superset/superset-ui-plugins?path=packages/superset-ui-legacy-plugin-chart-parallel-coordinates)
This plugin provides Parallel Coordinates 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 ParallelCoordinatesChartPlugin from '@superset-ui/legacy-plugin-chart-parallel-coordinates';
new ParallelCoordinatesChartPlugin()
.configure({ key: 'parallel-coordinates' })
.register();
```
Then use it via `SuperChart`. See
[storybook](https://apache-superset.github.io/superset-ui-plugins/?selectedKind=plugin-chart-parallel-coordinates)
for more details.
```js
<SuperChart
chartType="parallel-coordinates"
width={600}
height={600}
formData={...}
queriesData={[{
data: {...},
}]}
/>
```

View File

@@ -0,0 +1,39 @@
{
"name": "@superset-ui/legacy-plugin-chart-parallel-coordinates",
"version": "0.18.25",
"description": "Superset Legacy Chart - Parallel Coordinates",
"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.git"
},
"keywords": [
"superset"
],
"author": "Superset",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/apache-superset/superset-ui/issues"
},
"homepage": "https://github.com/apache-superset/superset-ui#readme",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@superset-ui/chart-controls": "0.18.25",
"@superset-ui/core": "0.18.25",
"d3": "^3.5.17",
"prop-types": "^15.7.2"
},
"peerDependencies": {
"react": "^16.13.1"
}
}

View File

@@ -0,0 +1,129 @@
/**
* 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.
*/
/* eslint-disable react/sort-prop-types */
import d3 from 'd3';
import PropTypes from 'prop-types';
import { getSequentialSchemeRegistry } from '@superset-ui/core';
import parcoords from './vendor/parcoords/d3.parcoords';
import divgrid from './vendor/parcoords/divgrid';
import './vendor/parcoords/d3.parcoords.css';
const propTypes = {
// Standard tabular data [{ fieldName1: value1, fieldName2: value2 }]
data: PropTypes.arrayOf(PropTypes.object),
width: PropTypes.number,
height: PropTypes.number,
colorMetric: PropTypes.string,
includeSeries: PropTypes.bool,
linearColorScheme: PropTypes.string,
metrics: PropTypes.arrayOf(PropTypes.string),
series: PropTypes.string,
showDatatable: PropTypes.bool,
};
function ParallelCoordinates(element, props) {
const {
data,
width,
height,
colorMetric,
includeSeries,
linearColorScheme,
metrics,
series,
showDatatable,
} = props;
const cols = includeSeries ? [series].concat(metrics) : metrics;
const ttypes = {};
ttypes[series] = 'string';
metrics.forEach(v => {
ttypes[v] = 'number';
});
const colorScale = colorMetric
? getSequentialSchemeRegistry()
.get(linearColorScheme)
.createLinearScale(d3.extent(data, d => d[colorMetric]))
: () => 'grey';
const color = d => colorScale(d[colorMetric]);
const container = d3
.select(element)
.classed('superset-legacy-chart-parallel-coordinates', true);
container.selectAll('*').remove();
const effHeight = showDatatable ? height / 2 : height;
const div = container
.append('div')
.style('height', `${effHeight}px`)
.classed('parcoords', true);
const chart = parcoords()(div.node())
.width(width)
.color(color)
.alpha(0.5)
.composite('darken')
.height(effHeight)
.data(data)
.dimensions(cols)
.types(ttypes)
.render()
.createAxes()
.shadows()
.reorderable()
.brushMode('1D-axes');
if (showDatatable) {
// create data table, row hover highlighting
const grid = divgrid();
container
.append('div')
.style('height', `${effHeight}px`)
.datum(data)
.call(grid)
.classed('parcoords grid', true)
.selectAll('.row')
.on({
mouseover(d) {
chart.highlight([d]);
},
mouseout: chart.unhighlight,
});
// update data table on brush event
chart.on('brush', d => {
d3.select('.grid')
.datum(d)
.call(grid)
.selectAll('.row')
.on({
mouseover(dd) {
chart.highlight([dd]);
},
mouseout: chart.unhighlight,
});
});
}
}
ParallelCoordinates.displayName = 'ParallelCoordinates';
ParallelCoordinates.propTypes = propTypes;
export default ParallelCoordinates;

View File

@@ -0,0 +1,47 @@
/**
* 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.
*/
import React from 'react';
import { styled, reactify } from '@superset-ui/core';
import PropTypes from 'prop-types';
import Component from './ParallelCoordinates';
const ReactComponent = reactify(Component);
const ParallelCoordianes = ({ className, ...otherProps }) => (
<div className={className}>
<ReactComponent {...otherProps} />
</div>
);
ParallelCoordianes.propTypes = {
className: PropTypes.string.isRequired,
};
export default styled(ParallelCoordianes)`
.superset-legacy-chart-parallel-coordinates {
div.grid {
overflow: auto;
div.row {
&:hover {
background-color: #ccc;
}
}
}
}
`;

View File

@@ -0,0 +1,80 @@
/**
* 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.
*/
import { t } from '@superset-ui/core';
import { ControlPanelConfig, sections } from '@superset-ui/chart-controls';
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
{
label: t('Query'),
expanded: true,
controlSetRows: [
['series'],
['metrics'],
['secondary_metric'],
['adhoc_filters'],
['limit', 'row_limit'],
['timeseries_limit_metric'],
[
{
name: 'order_desc',
config: {
type: 'CheckboxControl',
label: t('Sort Descending'),
default: true,
description: t('Whether to sort descending or ascending'),
},
},
],
],
},
{
label: t('Options'),
expanded: true,
controlSetRows: [
[
{
name: 'show_datatable',
config: {
type: 'CheckboxControl',
label: t('Data Table'),
default: false,
renderTrigger: true,
description: t('Whether to display the interactive data table'),
},
},
{
name: 'include_series',
config: {
type: 'CheckboxControl',
label: t('Include Series'),
renderTrigger: true,
default: false,
description: t('Include series name as an axis'),
},
},
],
['linear_color_scheme'],
],
},
],
};
export default config;

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

View File

@@ -0,0 +1,45 @@
/**
* 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.
*/
import { t, ChartMetadata, ChartPlugin } from '@superset-ui/core';
import transformProps from './transformProps';
import thumbnail from './images/thumbnail.png';
import controlPanel from './controlPanel';
const metadata = new ChartMetadata({
category: t('Ranking'),
credits: ['https://syntagmatic.github.io/parallel-coordinates'],
description: t(
'Plots the individual metrics for each row in the data vertically and links them together as a line. This chart is useful for comparing multiple metrics across all of the samples or rows in the data.',
),
name: t('Parallel Coordinates'),
tags: [t('Coordinates'), t('Directional'), t('Legacy'), t('Relational')],
thumbnail,
useLegacyApi: true,
});
export default class ParallelCoordinatesChartPlugin extends ChartPlugin {
constructor() {
super({
loadChart: () => import('./ReactParallelCoordinates'),
metadata,
transformProps,
controlPanel,
});
}
}

View File

@@ -0,0 +1,44 @@
/**
* 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.
*/
export default function transformProps(chartProps) {
const { width, height, formData, queriesData } = chartProps;
const {
includeSeries,
linearColorScheme,
metrics,
secondaryMetric,
series,
showDatatable,
} = formData;
return {
width,
height,
data: queriesData[0].data,
includeSeries,
linearColorScheme,
metrics: metrics.map(m => m.label || m),
colorMetric:
secondaryMetric && secondaryMetric.label
? secondaryMetric.label
: secondaryMetric,
series,
showDatatable,
};
}

View File

@@ -0,0 +1,79 @@
/* [LICENSE TBD] */
.parcoords svg,
.parcoords canvas {
font-size: 12px;
position: absolute;
}
.parcoords > canvas {
pointer-events: none;
}
.parcoords text.label {
font: 100%;
font-size: 12px;
cursor: drag;
}
.parcoords rect.background {
fill: transparent;
}
.parcoords rect.background:hover {
fill: rgba(120, 120, 120, 0.2);
}
.parcoords .resize rect {
fill: rgba(0, 0, 0, 0.1);
}
.parcoords rect.extent {
fill: rgba(255, 255, 255, 0.25);
stroke: rgba(0, 0, 0, 0.6);
}
.parcoords .axis line,
.parcoords .axis path {
fill: none;
stroke: #222;
shape-rendering: crispEdges;
}
.parcoords canvas {
opacity: 1;
-moz-transition: opacity 0.3s;
-webkit-transition: opacity 0.3s;
-o-transition: opacity 0.3s;
}
.parcoords canvas.faded {
opacity: 0.25;
}
.parcoords {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-color: white;
}
/* data table styles */
.parcoords .row,
.parcoords .header {
clear: left;
font-size: 12px;
line-height: 18px;
height: 18px;
margin: 0px;
}
.parcoords .row:nth-child(odd) {
background: rgba(0, 0, 0, 0.05);
}
.parcoords .header {
font-weight: bold;
}
.parcoords .cell {
float: left;
overflow: hidden;
white-space: nowrap;
width: 100px;
height: 18px;
}
.parcoords .col-0 {
width: 180px;
}

View File

@@ -0,0 +1,77 @@
/* [LICENSE TBD] */
/* eslint-disable */
// from http://bl.ocks.org/3687826
export default function (config) {
var columns = [];
var dg = function (selection) {
if (columns.length == 0) columns = d3.keys(selection.data()[0][0]);
// header
selection
.selectAll('.header')
.data([true])
.enter()
.append('div')
.attr('class', 'header');
var header = selection.select('.header').selectAll('.cell').data(columns);
header
.enter()
.append('div')
.attr('class', function (d, i) {
return 'col-' + i;
})
.classed('cell', true);
selection.selectAll('.header .cell').text(function (d) {
return d;
});
header.exit().remove();
// rows
var rows = selection.selectAll('.row').data(function (d) {
return d;
});
rows.enter().append('div').attr('class', 'row');
rows.exit().remove();
var cells = selection
.selectAll('.row')
.selectAll('.cell')
.data(function (d) {
return columns.map(function (col) {
return d[col];
});
});
// cells
cells
.enter()
.append('div')
.attr('class', function (d, i) {
return 'col-' + i;
})
.classed('cell', true);
cells.exit().remove();
selection.selectAll('.cell').text(function (d) {
return d;
});
return dg;
};
dg.columns = function (_) {
if (!arguments.length) return columns;
columns = _;
return this;
};
return dg;
}

View File

@@ -0,0 +1,26 @@
{
"compilerOptions": {
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "src",
"allowJs": false
},
"exclude": [
"lib",
"test"
],
"extends": "../../tsconfig.json",
"include": [
"src/**/*",
"types/**/*",
"../../types/**/*"
],
"references": [
{
"path": "../../packages/superset-ui-chart-controls"
},
{
"path": "../../packages/superset-ui-core"
}
]
}