Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new dashboard with video game sales #12162

Merged
merged 1 commit into from
Dec 22, 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
9 changes: 9 additions & 0 deletions superset/dashboards/commands/importers/v1/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ def update_id_refs(config: Dict[str, Any], chart_ids: Dict[str, int]) -> Dict[st
for old_id, value in metadata["expanded_slices"].items()
}

if "default_filters" in metadata:
Copy link
Member

Choose a reason for hiding this comment

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

nit: This switch type logic on update_id_refs if it grows (or even now) is asking for a small refactor IMO

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point!

default_filters = json.loads(metadata["default_filters"])
metadata["default_filters"] = json.dumps(
{
str(id_map[int(old_id)]): value
for old_id, value in default_filters.items()
}
)

# fix position
position = fixed.get("position", {})
for child in position.values():
Expand Down
8 changes: 6 additions & 2 deletions superset/datasets/commands/importers/v1/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@


type_map = {
"VARCHAR": String(),
"STRING": String(),
"TEXT": Text(),
"BIGINT": BigInteger(),
"FLOAT": Float(),
"FLOAT64": Float(),
"DOUBLE PRECISION": Float(),
"DATE": Date(),
"DOUBLE PRECISION": Float(precision=32),
"TEXT": Text(),
"DATETIME": DateTime(),
"TIMESTAMP WITHOUT TIME ZONE": DateTime(timezone=False),
"TIMESTAMP WITH TIME ZONE": DateTime(timezone=True),
}
Expand Down
78 changes: 78 additions & 0 deletions superset/examples/configs/charts/Games.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# 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.
slice_name: Games
viz_type: table
params:
adhoc_filters: []
all_columns:
- Name
- Global_Sales
- Platform
- Genre
- Publisher
- Year
color_pn: false
datasource: 21__table
granularity_sqla: Year
groupby:
- Name
include_search: true
metrics:
- aggregate: SUM
column:
column_name: Global_Sales
description: null
expression: null
filterable: true
groupby: true
id: 887
is_dttm: false
optionName: _col_Global_Sales
python_date_format: null
type: DOUBLE PRECISION
verbose_name: null
expressionType: SIMPLE
hasCustomLabel: false
isNew: false
label: SUM(Global_Sales)
optionName: metric_pkpvgdsf70d_pnqv77v0x2p
sqlExpression: null
order_by_cols:
- '["Global_Sales", false]'
order_desc: true
page_length: '15'
percent_metrics: []
queryFields:
groupby: groupby
metrics: metrics
query_mode: raw
row_limit: null
show_cell_bars: false
slice_id: 1394
table_filter: false
table_timestamp_format: smart_date
time_grain_sqla: P1D
time_range: No filter
time_range_endpoints:
- inclusive
- exclusive
url_params: {}
viz_type: table
cache_timeout: null
uuid: 2a5e562b-ab37-1b9b-1de3-1be4335c8e83
version: 1.0.0
dataset_uuid: 53d47c0c-c03d-47f0-b9ac-81225f808283
98 changes: 98 additions & 0 deletions superset/examples/configs/charts/Games_per_Genre.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# 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.
slice_name: Games per Genre
viz_type: treemap
params:
adhoc_filters: []
color_scheme: supersetColors
datasource: 1559__table
granularity_sqla: Year
groupby:
- Genre
label_colors:
'0': '#1FA8C9'
'1': '#454E7C'
'2600': '#666666'
3DO: '#B2B2B2'
3DS: '#D1C6BC'
Action: '#1FA8C9'
Adventure: '#454E7C'
DC: '#A38F79'
DS: '#8FD3E4'
Europe: '#5AC189'
Fighting: '#5AC189'
GB: '#FDE380'
GBA: '#ACE1C4'
GC: '#5AC189'
GEN: '#3CCCCB'
GG: '#EFA1AA'
Japan: '#FF7F44'
Microsoft Game Studios: '#D1C6BC'
Misc: '#FF7F44'
N64: '#1FA8C9'
NES: '#9EE5E5'
NG: '#A1A6BD'
Nintendo: '#D3B3DA'
North America: '#666666'
Other: '#E04355'
PC: '#EFA1AA'
PCFX: '#FDE380'
PS: '#A1A6BD'
PS2: '#FCC700'
PS3: '#3CCCCB'
PS4: '#B2B2B2'
PSP: '#FEC0A1'
PSV: '#FCC700'
Platform: '#666666'
Puzzle: '#E04355'
Racing: '#FCC700'
Role-Playing: '#A868B7'
SAT: '#A868B7'
SCD: '#8FD3E4'
SNES: '#454E7C'
Shooter: '#3CCCCB'
Simulation: '#A38F79'
Sports: '#8FD3E4'
Strategy: '#A1A6BD'
TG16: '#FEC0A1'
Take-Two Interactive: '#9EE5E5'
WS: '#ACE1C4'
Wii: '#A38F79'
WiiU: '#E04355'
X360: '#A868B7'
XB: '#D3B3DA'
XOne: '#FF7F44'
metrics:
- count
number_format: SMART_NUMBER
queryFields:
groupby: groupby
metrics: metrics
row_limit: null
time_range: No filter
time_range_endpoints:
- inclusive
- exclusive
treemap_ratio: 1.618033988749895
url_params:
preselect_filters: '{"1389": {"Platform": ["PS", "PS2", "PS3", "PS4"], "Genre":
null, "__time_range": "No filter"}}'
viz_type: treemap
cache_timeout: null
uuid: 0499bdec-0837-44f3-ae8a-8c670de81afd
version: 1.0.0
dataset_uuid: 53d47c0c-c03d-47f0-b9ac-81225f808283
120 changes: 120 additions & 0 deletions superset/examples/configs/charts/Games_per_Genre_over_time.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# 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.
slice_name: Games per Genre over time
viz_type: line
params:
adhoc_filters: []
annotation_layers: []
bottom_margin: auto
color_scheme: supersetColors
comparison_type: values
contribution: false
datasource: 21__table
granularity_sqla: Year
groupby:
- Genre
label_colors:
'0': '#1FA8C9'
'1': '#454E7C'
'2600': '#666666'
3DO: '#B2B2B2'
3DS: '#D1C6BC'
Action: '#1FA8C9'
Adventure: '#454E7C'
DC: '#A38F79'
DS: '#8FD3E4'
Europe: '#5AC189'
Fighting: '#5AC189'
GB: '#FDE380'
GBA: '#ACE1C4'
GC: '#5AC189'
GEN: '#3CCCCB'
GG: '#EFA1AA'
Japan: '#FF7F44'
Microsoft Game Studios: '#D1C6BC'
Misc: '#FF7F44'
N64: '#1FA8C9'
NES: '#9EE5E5'
NG: '#A1A6BD'
Nintendo: '#D3B3DA'
North America: '#666666'
Other: '#E04355'
PC: '#EFA1AA'
PCFX: '#FDE380'
PS: '#A1A6BD'
PS2: '#FCC700'
PS3: '#3CCCCB'
PS4: '#B2B2B2'
PSP: '#FEC0A1'
PSV: '#FCC700'
Platform: '#666666'
Puzzle: '#E04355'
Racing: '#FCC700'
Role-Playing: '#A868B7'
SAT: '#A868B7'
SCD: '#8FD3E4'
SNES: '#454E7C'
Shooter: '#3CCCCB'
Simulation: '#A38F79'
Sports: '#8FD3E4'
Strategy: '#A1A6BD'
TG16: '#FEC0A1'
Take-Two Interactive: '#9EE5E5'
WS: '#ACE1C4'
Wii: '#A38F79'
WiiU: '#E04355'
X360: '#A868B7'
XB: '#D3B3DA'
XOne: '#FF7F44'
left_margin: auto
line_interpolation: linear
metrics:
- count
order_desc: true
queryFields:
groupby: groupby
metrics: metrics
rich_tooltip: true
rolling_type: None
row_limit: null
show_brush: auto
show_legend: true
show_markers: false
slice_id: 3544
time_grain_sqla: null
time_range: No filter
time_range_endpoints:
- inclusive
- exclusive
url_params:
preselect_filters: '{"1389": {"Platform": ["PS", "PS2", "PS3", "PS4"], "Genre":
null, "__time_range": "No filter"}}'
viz_type: line
x_axis_format: smart_date
x_axis_label: Year Published
x_axis_showminmax: true
x_ticks_layout: auto
y_axis_bounds:
- null
- null
y_axis_format: SMART_NUMBER
y_axis_label: '# of Games Published'
y_axis_showminmax: true
cache_timeout: null
uuid: 0f8976aa-7bb4-40c7-860b-64445a51aaaf
version: 1.0.0
dataset_uuid: 53d47c0c-c03d-47f0-b9ac-81225f808283
Loading