dtale.dash_application package¶
Subpackages¶
Submodules¶
dtale.dash_application.charts module¶
-
dtale.dash_application.charts.
bar_builder
(data, x, y, axes_builder, wrapper, cpg=False, barmode='group', barsort=None, **kwargs)[source]¶ Builder function for plotly.graph_objects.Surface
Parameters: - data (dict) – raw data to be represented within surface chart
- x (str) – column to use for the X-Axis
- y (list of str) – columns to use for the Y-Axes
- axes_builder (func) – function for building axis configurations
- wrapper (func) – wrapper function returned by
dtale.charts.utils.chart_wrapper()
- group (list of str or str) – column(s) to use for grouping
- agg (str) – points to a specific function that can be applied to :func: pandas.core.groupby.DataFrameGroupBy. Possible values are: count, first, last mean, median, min, max, std, var, mad, prod, sum
Returns: surface chart
Return type:
-
dtale.dash_application.charts.
build_axes
(data_id, x, axis_inputs, mins, maxs, z=None, agg=None)[source]¶ Returns helper function for building axis configurations against a specific y-axis.
Parameters: - data_id (str) – identifier of data to build axis configurations against
- x (str) – column to be used as x-axis of chart
- axis_inputs (dict) – current settings for y-axis limits
- mins (dict) – minimums for all columns involved in chart
- maxs – maximums for all columns invloved in chart
- maxs – dict
- z (str, optional) – column to use for the Z-Axis
- agg (str, optional) – specific aggregation that can be applied to y or z axes. Possible values are: count, first, last mean, median, min, max, std, var, mad, prod, sum. This is included in label of axis it is being applied to.
Returns: handler function to be applied against each y-axis used in chart
Return type: func
-
dtale.dash_application.charts.
build_chart
(data_id=None, **inputs)[source]¶ - Factory method that forks off into the different chart building methods (heatmaps are handled separately)
- line
- bar
- scatter
- pie
- wordcloud
- 3D scatter
- surface
Parameters: - data_id (str) – identifier of data to build axis configurations against
- inputs – Optional keyword arguments containing the following information: - x: column to be used as x-axis of chart - y: column to be used as y-axis of chart - z: column to use for the Z-Axis - agg: points to a specific function that can be applied to :func: pandas.core.groupby.DataFrameGroupBy
Returns: plotly chart object(s)
Return type: type of (dash_core_components.Graph, dict)
-
dtale.dash_application.charts.
build_figure_data
(data_id, chart_type=None, query=None, x=None, y=None, z=None, group=None, agg=None, window=None, rolling_comp=None, **kwargs)[source]¶ Builds chart figure data for loading into dash:dash_core_components.Graph <dash-core-components/graph> components
Parameters: - data_id (str) – integer string identifier for a D-Tale process’s data
- chart_type (str) – type of chart (line, bar, pie, scatter…)
- query (str, optional) – pandas dataframe query string
- x (str) – column to use for the X-Axis
- y (list of str) – columns to use for the Y-Axes
- z (str, optional) – column to use for the Z-Axis
- group (list of str or str, optional) – column(s) to use for grouping
- agg (str, optional) – specific aggregation that can be applied to y or z axes. Possible values are: count, first, last mean, median, min, max, std, var, mad, prod, sum. This is included in label of axis it is being applied to.
- window (int, optional) – number of days to include in rolling aggregations
- rolling_comp (str, optional) – computation to use in rolling aggregations
- kwargs (dict) – optional keyword arguments, here in case invalid arguements are passed to this function
Returns: dictionary of series data, min/max ranges of columns used in chart
Return type:
-
dtale.dash_application.charts.
build_grouped_bars_with_multi_yaxis
(series_cfgs, y)[source]¶ This generator is a hack for the lack of support plotly has for sorting plotly.graph_objects.Bar charts by an axis other than ‘y’. This also helps with issues around displaying multiple y-axis.
Parameters: - series_cfgs (list of dict) – configurations for all the series within a bar chart
- y (list of str) – columns to use for the Y-Axes
Returns: updated series configurations
Type: generator
-
dtale.dash_application.charts.
build_layout
(cfg)[source]¶ Wrapper function for plotly.graph_objects.Layout
Parameters: cfg (dict) – layout configuration Returns: layout object Return type: plotly.graph_objects.Layout
-
dtale.dash_application.charts.
build_series_name
(y, chart_per_group=False)[source]¶ - Builds a helper function to build a name for a series in a chart.
- (y=’a,b,c’, chart_per_group=False, sub_y=’a’, group=’d’) => ‘d/a’
- (y=’a,b,c’, chart_per_group=True, sub_y=’a’, group=’d’) => ‘a’
- (y=’a,b,c’, chart_per_group=False, sub_y=’a’, group=’all’) => ‘a’
Parameters: - y (list of str) – columns to use for the Y-Axes
- chart_per_group (bool) – True if charts are split by groups, False if all are contained within one chart
Returns: helper function for building series names based off y-axis & group values
Return type: func
-
dtale.dash_application.charts.
build_spaced_ticks
(ticktext)[source]¶ plotly/dash doesn’t have particularly good tick position handling so in order to handle this on our end we’ll take the list of tick labels and depending on how large that list is we’ll build a configuration which will show a smaller group of ticks evenly spaced.
Parameters: ticktext (list) – list of tick labels Returns: tick configuration Return type: dict
-
dtale.dash_application.charts.
build_title
(x, y, group=None, z=None, agg=None)[source]¶ - Helper function to build chart titles based on the inputs for x, y, z, group & aggregation.
- (x=’a’, y=’b’) => ‘b by a’
- (x=’a’, y=[‘b’,’c’]) => ‘b, c by a’
- (x=’a’, y=’b’, z=’c’) => ‘b by a weighted by c’
- (x=’a’, y=’b’, group=’d’) => ‘d - b by a’
- (x=’a’, y=’b’, agg=’corr’) => ‘b by a (Correlation)’
- (x=’a’, y=’b’, z=’c’, agg=’sum’) => ‘b by a weighted by c (Sum)’
Parameters: - x (str) – column to use for the X-Axis
- y (list of str) – columns to use for the Y-Axes
- group (list of str or str, optional) – column(s) to use for grouping
- z (str, optional) – column to use for the Z-Axis
- agg (str, optional) – specific aggregation that can be applied to y or z axes. Possible values are: count, first, last mean, median, min, max, std, var, mad, prod, sum. This is included in label of axis it is being applied to.
Returns: chart title
Return type:
-
dtale.dash_application.charts.
chart_wrapper
(data_id, data, url_params=None)[source]¶ Wrapper function which will wrap each plotly/dash chart with a link to view the chart in a separate popup
Parameters: - data_id (str) – identifier of data to build axis configurations against
- data – data generated by
dtale.charts.utils.build_chart()
- url_params – parameters to be encoded within popup link
Returns: dash components wrapped in div with popup link
Return type:
-
dtale.dash_application.charts.
cpg_chunker
(charts, columns=2)[source]¶ Helper function to break a list of charts up into rows of two. If there is only one chart it will only return one row with the chart occupying the full width.
Parameters: - charts (list of dash_core_components.Groph) – chart objects
- columns (int) – how many columns each row of charts should have (default: 2)
Returns: list of rows by columns if more than one chart is input otherwise simply return the chart
-
dtale.dash_application.charts.
heatmap_builder
(data_id, **inputs)[source]¶ Builder function for plotly.graph_objects.Heatmap
Parameters: - data_id (str) – integer string identifier for a D-Tale process’s data
- inputs (dict) – Optional keyword arguments containing the following information: - x: column to be used as x-axis of chart - y: column to be used as y-axis of chart - z: column to use for the Z-Axis - agg: points to a specific function that can be applied to :func: pandas.core.groupby.DataFrameGroupBy
Returns: heatmap
Return type:
-
dtale.dash_application.charts.
line_builder
(data, x, y, axes_builder, wrapper, cpg=False, **inputs)[source]¶ Builder function for plotly.graph_objects.Scatter(mode=’lines’)
Parameters: - data (dict) – raw data to be represented within line chart
- x (str) – column to use for the X-Axis
- y (list of str) – columns to use for the Y-Axes
- axes_builder (func) – function for building axis configurations
- wrapper (func) – wrapper function returned by
dtale.charts.utils.chart_wrapper()
- cpg (bool) – True if charts are split by groups, False if all are contained within one chart
- inputs (dict) – Optional keyword arguments containing information about which aggregation (if any) has been used
Returns: line chart
Return type:
-
dtale.dash_application.charts.
pie_builder
(data, x, y, wrapper, **inputs)[source]¶ Builder function for plotly.graph_objects.Pie
Parameters: - data (dict) – raw data to be represented within surface chart
- x (str) – column to use for the X-Axis
- y (list of str) – columns to use for the Y-Axes
- wrapper (func) – wrapper function returned by
dtale.charts.utils.chart_wrapper()
- inputs (dict) – Optional keyword arguments containing information about which aggregation (if any) has been used
Returns: pie chart
Return type:
-
dtale.dash_application.charts.
scatter_builder
(data, x, y, axes_builder, wrapper, group=None, z=None, agg=None)[source]¶ Builder function for plotly.graph_objects.Scatter
Parameters: - data (dict) – raw data to be represented within scatter chart
- x (str) – column to use for the X-Axis
- y (list of str) – columns to use for the Y-Axes
- axes_builder (func) – function for building axis configurations
- wrapper (func) – wrapper function returned by
dtale.charts.utils.chart_wrapper()
- z (str) – column to use for the Z-Axis
- group (list of str or str) – column(s) to use for grouping
- agg (str) – points to a specific function that can be applied to :func: pandas.core.groupby.DataFrameGroupBy. Possible values are: count, first, last mean, median, min, max, std, var, mad, prod, sum
Returns: scatter chart
Return type:
-
dtale.dash_application.charts.
surface_builder
(data, x, y, z, axes_builder, wrapper, agg=None)[source]¶ Builder function for plotly.graph_objects.Surface
Parameters: - data (dict) – raw data to be represented within surface chart
- x (str) – column to use for the X-Axis
- y (list of str) – columns to use for the Y-Axes
- z (str) – column to use for the Z-Axis
- axes_builder (func) – function for building axis configurations
- wrapper (func) – wrapper function returned by
dtale.charts.utils.chart_wrapper()
- group (list of str or str) – column(s) to use for grouping
- agg (str) – points to a specific function that can be applied to :func: pandas.core.groupby.DataFrameGroupBy. Possible values are: count, first, last mean, median, min, max, std, var, mad, prod, sum
Returns: surface chart
Return type:
dtale.dash_application.layout module¶
-
dtale.dash_application.layout.
bar_input_style
(**inputs)[source]¶ Sets display CSS property for bar chart inputs
-
dtale.dash_application.layout.
base_layout
(github_fork, **kwargs)[source]¶ Base layout to be returned by
dtale.dash_application.views.DtaleDash.interpolate_index()
Parameters: Returns: HTML
Return type:
-
dtale.dash_application.layout.
build_cols
(cols, dtypes)[source]¶ Helper function to add additional column entries for columns of type datetime so that users can make use of different frequencies of dates. For example, hour, weekday, month, quarter, year
Parameters: - cols (list of strings) – columns in dataframe
- dtypes (dict) – datatypes of columns in dataframe
Returns: generator or columns + any additional (datetime column + frequency) options
-
dtale.dash_application.layout.
build_error
(error, tb)[source]¶ Returns error/traceback information in standard component with styling
Parameters: Returns: error component
Return type:
-
dtale.dash_application.layout.
build_input
(label, input, className='col-auto', **kwargs)[source]¶ Helper function to build a standard label/input component in dash.
Parameters: Returns: dash components for label/input
Return type:
-
dtale.dash_application.layout.
build_input_options
(df, **inputs)[source]¶ Builds dropdown options for (X, Y, Z, Group, Barsort & Y-Axis Ranges) with filtering based on currently selected values for the following inputs: x, y, z, group.
-
dtale.dash_application.layout.
build_option
(value, label=None)[source]¶ Returns value/label inputs in a dictionary for use in dash_core_components.Dropdown
-
dtale.dash_application.layout.
build_selections
(*args)[source]¶ simple helper function to build a single level list of values based on variable number of inputs which could be equal to None.
-
dtale.dash_application.layout.
build_tab
(label, value, **kwargs)[source]¶ Builds a dash_core_components.Tab with standard styling settings.
-
dtale.dash_application.layout.
charts_layout
(df, settings, **inputs)[source]¶ Builds main dash inputs with dropdown options populated with the columns of the dataframe associated with the page. Inputs included are: chart tabs, query, x, y, z, group, aggregation, rolling window/computation, chart per group toggle, bar sort, bar mode, y-axis range editors
Parameters: - df (
pandas.DataFrame
) – dataframe to drive the charts built on page - settings – global settings associated with this dataframe (contains properties like “query”)
Returns: dash markup
- df (
-
dtale.dash_application.layout.
show_chart_per_group
(**inputs)[source]¶ Boolean function to determine whether “Chart Per Group” toggle should be displayed or not
dtale.dash_application.views module¶
-
class
dtale.dash_application.views.
DtaleDash
(*args, **kwargs)[source]¶ Bases:
dash.dash.Dash
Wrapper class to dash.Dash to allow for abstraction of global state used for building the default layout. Additional state include stylesheets, JS files and styling for github demos.
-
dtale.dash_application.views.
add_dash
(server)[source]¶ Adds dash support to main D-Tale Flask process.
Parameters: server ( flask.Flask
) – main D-Tale Flask processReturns: server with dash added Return type: flask.Flask
-
dtale.dash_application.views.
chart_url_params
(search)[source]¶ Builds chart parameters by parsing the query string from main URL
Parameters: - search – URL querystring
- search – str
Returns: dictionary of parsed querystring key/values
Return type:
-
dtale.dash_application.views.
get_data_id
(pathname)[source]¶ Parses data ID from query path (ex: ‘foo/bar/1’ => ‘1’)
-
dtale.dash_application.views.
get_url_parser
()[source]¶ Returns URL parser based on whether Python 2 or 3 is being used.
-
dtale.dash_application.views.
init_callbacks
(dash_app)[source]¶ Dynamically adds dash callbacks to dash-wrapped flask server
Parameters: dash_app ( flask.Flask
) – flask server with dash support enabledReturns: flask server with dash callbacks added Return type: flask.Flask