跳到主要内容

Chart Parameters

Chart parameters are stored as a JSON encoded string in the slices.params column and are often referenced throughout the code as form-data. Currently the form-data is neither versioned nor typed as thus is somewhat free-formed. Note in the future there may be merit in using something like JSON Schema to both annotate and validate the JSON object in addition to using a Mypy TypedDict (introduced in Python 3.8) for typing the form-data in the backend. This section serves as a potential primer for that work.

The following tables provide a non-exhaustive list of the various fields which can be present in the JSON object grouped by the Explorer pane sections. These values were obtained by extracting the distinct fields from a legacy deployment consisting of tens of thousands of charts and thus some fields may be missing whilst others may be deprecated.

Note not all fields are correctly categorized. The fields vary based on visualization type and may appear in different sections depending on the type. Verified deprecated columns may indicate a missing migration and/or prior migrations which were unsuccessful and thus future work may be required to clean up the form-data.

Datasource & Chart Type

FieldTypeNotes
database_namestringDeprecated?
datasourcestring<datasouce_id>__<datasource_type>
datasource_idstringDeprecated? See datasource
datasource_namestringDeprecated?
datasource_typestringDeprecated? See datasource
viz_typestringThe Visualization Type widget

Time

FieldTypeNotes
druid_time_originstringThe Druid Origin widget
granularitystringThe Druid Time Granularity widget
granularity_sqlastringThe SQLA Time Column widget
time_grain_sqlastringThe SQLA Time Grain widget
time_rangestringThe Time range widget

GROUP BY

FieldTypeNotes
metricsarray(string)See Query section
order_asc-See Query section
row_limit-See Query section
timeseries_limit_metric-See Query section

NOT GROUPED BY

FieldTypeNotes
order_by_colsarray(string)The Ordering widget
row_limit-See Query section

Y Axis 1

FieldTypeNotes
metric-The Left Axis Metric widget. See Query section
y_axis_format-See Y Axis section

Y Axis 2

FieldTypeNotes
metric_2-The Right Axis Metric widget. See Query section

Query

FieldTypeNotes
adhoc_filtersarray(object)The Filters widget
extra_filtersarray(object)Another pathway to the Filters widget.
It is generally used to pass dashboard filter parameters to a chart.
It can be used for appending additional filters to a chart that has been saved with its own filters on an ad-hoc basis if the chart is being used as a standalone widget.

For implementation examples see : utils test.py
For insight into how superset processes the contents of this parameter see: exploreUtils/index.js
columnsarray(string)The Breakdowns widget
groupbyarray(string)The Group by or Series widget
limitnumberThe Series Limit widget
metric
metric_2
metrics
percent_mertics
secondary_metric
size
x
y
string,object,array(string),array(object)The metric(s) depending on the visualization type
order_ascbooleanThe Sort Descending widget
row_limitnumberThe Row limit widget
timeseries_limit_metricobjectThe Sort By widget

The metric (or equivalent) and timeseries_limit_metric fields are all composed of either metric names or the JSON representation of the AdhocMetric TypeScript type. The adhoc_filters is composed of the JSON represent of the AdhocFilter TypeScript type (which can comprise of columns or metrics depending on whether it is a WHERE or HAVING clause). The all_columns, all_columns_x, columns, groupby, and order_by_cols fields all represent column names.

Chart Options

FieldTypeNotes
color_pickerobjectThe Fixed Color widget
label_colorsobjectThe Color Scheme widget
normalizedbooleanThe Normalized widget

Y Axis

FieldTypeNotes
y_axis_2_labelN/ADeprecated?
y_axis_formatstringThe Y Axis Format widget
y_axis_zeroN/ADeprecated?

Note the y_axis_format is defined under various section for some charts.

Other

FieldTypeNotes
color_schemestring

Unclassified

FieldTypeNotes
add_to_dashN/A
codeN/A
collapsed_fieldsetsN/A
comparison typeN/A
country_fieldtypeN/A
default_filtersN/A
entityN/A
expanded_slicesN/A
filter_immune_slice_fieldsN/A
filter_immune_slicesN/A
flt_col_0N/A
flt_col_1N/A
flt_eq_0N/A
flt_eq_1N/A
flt_op_0N/A
flt_op_1N/A
goto_dashN/A
import_timeN/A
labelN/A
linear_color_schemeN/A
new_dashboard_nameN/A
new_slice_nameN/A
num_period_compareN/A
period_ratio_typeN/A
permN/A
rdo_saveN/A
refresh_frequencyN/A
remote_idN/A
resample_fillmethodN/A
resample_howN/A
rose_area_proportionN/A
save_to_dashboard_idN/A
schemaN/A
seriesN/A
show_bubblesN/A
slice_nameN/A
timed_refresh_immune_slicesN/A
useridN/A