mirror of
https://github.com/apache/superset.git
synced 2026-04-18 15:44:57 +00:00
fix(explore): pie chart label bugs (#13052)
This commit is contained in:
847
superset-frontend/package-lock.json
generated
847
superset-frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -65,34 +65,34 @@
|
||||
"@babel/runtime-corejs3": "^7.12.5",
|
||||
"@data-ui/sparkline": "^0.0.84",
|
||||
"@emotion/core": "^10.0.35",
|
||||
"@superset-ui/chart-controls": "^0.17.5",
|
||||
"@superset-ui/core": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-calendar": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-chord": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-country-map": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-event-flow": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-force-directed": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-heatmap": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-histogram": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-horizon": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-map-box": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-paired-t-test": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-parallel-coordinates": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-partition": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-pivot-table": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-rose": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-sankey": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-sankey-loop": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-sunburst": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-treemap": "^0.17.5",
|
||||
"@superset-ui/legacy-plugin-chart-world-map": "^0.17.5",
|
||||
"@superset-ui/legacy-preset-chart-big-number": "^0.17.5",
|
||||
"@superset-ui/chart-controls": "^0.17.8",
|
||||
"@superset-ui/core": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-calendar": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-chord": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-country-map": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-event-flow": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-force-directed": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-heatmap": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-histogram": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-horizon": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-map-box": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-paired-t-test": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-parallel-coordinates": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-partition": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-pivot-table": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-rose": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-sankey": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-sankey-loop": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-sunburst": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-treemap": "^0.17.8",
|
||||
"@superset-ui/legacy-plugin-chart-world-map": "^0.17.8",
|
||||
"@superset-ui/legacy-preset-chart-big-number": "^0.17.8",
|
||||
"@superset-ui/legacy-preset-chart-deckgl": "^0.4.1",
|
||||
"@superset-ui/legacy-preset-chart-nvd3": "^0.17.5",
|
||||
"@superset-ui/plugin-chart-echarts": "^0.17.6",
|
||||
"@superset-ui/plugin-chart-table": "^0.17.6",
|
||||
"@superset-ui/plugin-chart-word-cloud": "^0.17.5",
|
||||
"@superset-ui/preset-chart-xy": "^0.17.5",
|
||||
"@superset-ui/legacy-preset-chart-nvd3": "^0.17.8",
|
||||
"@superset-ui/plugin-chart-echarts": "^0.17.8",
|
||||
"@superset-ui/plugin-chart-table": "^0.17.8",
|
||||
"@superset-ui/plugin-chart-word-cloud": "^0.17.8",
|
||||
"@superset-ui/preset-chart-xy": "^0.17.8",
|
||||
"@vx/responsive": "^0.0.195",
|
||||
"abortcontroller-polyfill": "^1.1.9",
|
||||
"antd": "^4.9.4",
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Row, Col, FormControl } from 'react-bootstrap';
|
||||
import { t, getChartMetadataRegistry } from '@superset-ui/core';
|
||||
import { Behavior, t, getChartMetadataRegistry } from '@superset-ui/core';
|
||||
import { useDynamicPluginContext } from 'src/components/DynamicPlugins';
|
||||
import { Tooltip } from 'src/common/components/Tooltip';
|
||||
import Modal from 'src/common/components/Modal';
|
||||
@@ -166,7 +166,10 @@ const VizTypeControl = props => {
|
||||
const filterString = filter.toLowerCase();
|
||||
|
||||
const filteredTypes = DEFAULT_ORDER.filter(type => registry.has(type))
|
||||
.filter(type => !registry.get(type).isNativeFilter)
|
||||
.filter(type => {
|
||||
const behaviors = registry.get(type)?.behaviors || [];
|
||||
return behaviors.includes(Behavior.CROSS_FILTER) || !behaviors.length;
|
||||
})
|
||||
.map(type => ({
|
||||
key: type,
|
||||
value: registry.get(type),
|
||||
@@ -174,7 +177,10 @@ const VizTypeControl = props => {
|
||||
.concat(
|
||||
registry
|
||||
.entries()
|
||||
.filter(entry => !entry.value.isNativeFilter)
|
||||
.filter(entry => {
|
||||
const behaviors = entry.value?.behaviors || [];
|
||||
return behaviors.includes(Behavior.CROSS_FILTER) || !behaviors.length;
|
||||
})
|
||||
.filter(({ key }) => !typesWithDefaultOrder.has(key)),
|
||||
)
|
||||
.filter(entry => entry.value.name.toLowerCase().includes(filterString));
|
||||
|
||||
@@ -39,7 +39,12 @@ export default function AntdRangeFilter(props: AntdPluginFilterRangeProps) {
|
||||
const handleChange = (value: [number, number]) => {
|
||||
const [lower, upper] = value;
|
||||
|
||||
setExtraFormData(getRangeExtraFormData(col, lower, upper));
|
||||
setExtraFormData({
|
||||
extraFormData: getRangeExtraFormData(col, lower, upper),
|
||||
currentState: {
|
||||
value,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { t, ChartMetadata, ChartPlugin } from '@superset-ui/core';
|
||||
import { Behavior, ChartMetadata, ChartPlugin, t } from '@superset-ui/core';
|
||||
import buildQuery from './buildQuery';
|
||||
import controlPanel from './controlPanel';
|
||||
import transformProps from './transformProps';
|
||||
@@ -27,7 +27,7 @@ export default class AntdRangeFilterPlugin extends ChartPlugin {
|
||||
const metadata = new ChartMetadata({
|
||||
name: t('Range filter plugin'),
|
||||
description: 'Range filter plugin using AntD',
|
||||
isNativeFilter: true,
|
||||
behaviors: [Behavior.CROSS_FILTER, Behavior.NATIVE_FILTER],
|
||||
thumbnail,
|
||||
});
|
||||
|
||||
|
||||
@@ -67,14 +67,12 @@ export default function AntdPluginFilterSelect(
|
||||
const emptyFilter =
|
||||
enableEmptyFilter && !inverseSelection && resultValue?.length === 0;
|
||||
setExtraFormData({
|
||||
// @ts-ignore
|
||||
extraFormData: getSelectExtraFormData(
|
||||
col,
|
||||
resultValue,
|
||||
emptyFilter,
|
||||
inverseSelection,
|
||||
),
|
||||
// @ts-ignore (add to superset-ui/core)
|
||||
currentState: {
|
||||
value: resultValue,
|
||||
},
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { t, ChartMetadata, ChartPlugin } from '@superset-ui/core';
|
||||
import { Behavior, ChartMetadata, ChartPlugin, t } from '@superset-ui/core';
|
||||
import buildQuery from './buildQuery';
|
||||
import controlPanel from './controlPanel';
|
||||
import transformProps from './transformProps';
|
||||
@@ -27,7 +27,7 @@ export default class AntdFilterSelectPlugin extends ChartPlugin {
|
||||
const metadata = new ChartMetadata({
|
||||
name: t('Select filter plugin'),
|
||||
description: 'Select filter plugin using AntD',
|
||||
isNativeFilter: true,
|
||||
behaviors: [Behavior.CROSS_FILTER, Behavior.NATIVE_FILTER],
|
||||
thumbnail,
|
||||
});
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ params:
|
||||
metric: count
|
||||
number_format: SMART_NUMBER
|
||||
outerRadius: 69
|
||||
pie_label_type: key
|
||||
label_type: key
|
||||
queryFields:
|
||||
groupby: groupby
|
||||
metric: metrics
|
||||
|
||||
@@ -38,7 +38,7 @@ params:
|
||||
metric: count
|
||||
number_format: SMART_NUMBER
|
||||
outerRadius: 69
|
||||
pie_label_type: key
|
||||
label_type: key
|
||||
queryFields:
|
||||
groupby: groupby
|
||||
metric: metrics
|
||||
|
||||
@@ -30,7 +30,7 @@ params:
|
||||
metric: count
|
||||
number_format: SMART_NUMBER
|
||||
outerRadius: 69
|
||||
pie_label_type: key
|
||||
label_type: key
|
||||
queryFields:
|
||||
groupby: groupby
|
||||
metric: metrics
|
||||
|
||||
@@ -58,7 +58,7 @@ params:
|
||||
sqlExpression: null
|
||||
number_format: SMART_NUMBER
|
||||
outerRadius: 67
|
||||
pie_label_type: key
|
||||
label_type: key
|
||||
queryFields:
|
||||
groupby: groupby
|
||||
metric: metrics
|
||||
|
||||
@@ -49,7 +49,7 @@ params:
|
||||
sqlExpression: null
|
||||
number_format: SMART_NUMBER
|
||||
outerRadius: 65
|
||||
pie_label_type: key
|
||||
label_type: key
|
||||
queryFields:
|
||||
groupby: groupby
|
||||
metric: metrics
|
||||
|
||||
@@ -38,7 +38,7 @@ params:
|
||||
metric: count
|
||||
number_format: SMART_NUMBER
|
||||
outerRadius: 69
|
||||
pie_label_type: key
|
||||
label_type: key
|
||||
queryFields:
|
||||
groupby: groupby
|
||||
metric: metrics
|
||||
|
||||
@@ -29,7 +29,7 @@ params:
|
||||
metric: count
|
||||
number_format: SMART_NUMBER
|
||||
outerRadius: 61
|
||||
pie_label_type: key
|
||||
label_type: key
|
||||
queryFields:
|
||||
groupby: groupby
|
||||
metric: metrics
|
||||
|
||||
@@ -38,7 +38,7 @@ params:
|
||||
metric: count
|
||||
number_format: SMART_NUMBER
|
||||
outerRadius: 69
|
||||
pie_label_type: key
|
||||
label_type: key
|
||||
queryFields:
|
||||
groupby: groupby
|
||||
metric: metrics
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
# 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.
|
||||
"""rename pie label type
|
||||
|
||||
Revision ID: 41ce8799acc3
|
||||
Revises: e11ccdd12658
|
||||
Create Date: 2021-02-10 12:32:27.385579
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "41ce8799acc3"
|
||||
down_revision = "e11ccdd12658"
|
||||
|
||||
import json
|
||||
|
||||
from alembic import op
|
||||
from sqlalchemy import and_, Column, Integer, String, Text
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
|
||||
from superset import db
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
class Slice(Base):
|
||||
"""Declarative class to do query in upgrade"""
|
||||
|
||||
__tablename__ = "slices"
|
||||
id = Column(Integer, primary_key=True)
|
||||
viz_type = Column(String(250))
|
||||
params = Column(Text)
|
||||
|
||||
|
||||
def upgrade():
|
||||
bind = op.get_bind()
|
||||
session = db.Session(bind=bind)
|
||||
|
||||
slices = (
|
||||
session.query(Slice)
|
||||
.filter(and_(Slice.viz_type == "pie", Slice.params.like("%pie_label_type%")))
|
||||
.all()
|
||||
)
|
||||
changes = 0
|
||||
for slc in slices:
|
||||
try:
|
||||
params = json.loads(slc.params)
|
||||
pie_label_type = params.pop("pie_label_type", None)
|
||||
if pie_label_type:
|
||||
changes += 1
|
||||
params["label_type"] = pie_label_type
|
||||
slc.params = json.dumps(params, sort_keys=True)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print(f"Parsing params for slice {slc.id} failed.")
|
||||
pass
|
||||
|
||||
session.commit()
|
||||
session.close()
|
||||
print(f"Updated {changes} pie chart labels.")
|
||||
|
||||
|
||||
def downgrade():
|
||||
bind = op.get_bind()
|
||||
session = db.Session(bind=bind)
|
||||
|
||||
slices = (
|
||||
session.query(Slice)
|
||||
.filter(and_(Slice.viz_type == "pie", Slice.params.like("%label_type%")))
|
||||
.all()
|
||||
)
|
||||
changes = 0
|
||||
for slc in slices:
|
||||
try:
|
||||
params = json.loads(slc.params)
|
||||
label_type = params.pop("label_type", None)
|
||||
if label_type:
|
||||
changes += 1
|
||||
params["pie_label_type"] = label_type
|
||||
slc.params = json.dumps(params, sort_keys=True)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print(f"Parsing params for slice {slc.id} failed.")
|
||||
pass
|
||||
|
||||
session.commit()
|
||||
session.close()
|
||||
print(f"Updated {changes} pie chart labels.")
|
||||
Reference in New Issue
Block a user