pyxley.charts.mg package¶
Submodules¶
pyxley.charts.mg.axes module¶
-
class
pyxley.charts.mg.axes.Axes¶ Bases:
pyxley.charts.mg.mg.OptionHelperAxes object for metricgraphics.
This class is used to specify axes options for the metricsgraphics api. https://github.com/mozilla/metrics-graphics/wiki/Axes
-
get()¶ Retrieve options set by user.
-
logscale()¶ Set flag to log scale the y-axis.
-
set_inflator(value)¶ Set inflator value.
Parameters: value (float) – inflator value.
-
set_min_y_from_data(value)¶ Set flag to find the minimum y-value from the data.
-
set_small_text(value)¶ Set flag to show small text.
-
set_xformat(value)¶ Set the x-axis format.
-
set_xlabel(label)¶ Set x-axis label.
-
set_xlim(xlim)¶ Set x-axis limits.
Accepts a two-element list to set the x-axis limits.
Parameters: xlim (list) – lower and upper bounds
Raises: ValueError– xlim must contain two elementsValueError– Min must be less than max
-
set_xticks_count(value)¶ Set xticks counts.
-
set_xticks_length(value)¶ Set the length of the x-axis ticks.
-
set_xunits(value)¶ Set the units on the x-axis.
-
set_yformat(value)¶ Set the y-axis format.
-
set_ylabel(label)¶ Set y-axis label.
-
set_ylim(ylim)¶ Set y-axis limits.
Accepts a two-element list to set the y-axis limits.
Parameters: ylim (list) – lower and upper bounds
Raises: ValueError– ylim must contain two elementsValueError– Min must be less than max
-
set_yticks_count(value)¶ Set yticks counts.
-
set_yticks_length(value)¶ Set the length of the y-axis ticks.
-
set_yunits(value)¶ Set the units on the y-axis.
-
show_secondary_x_label(value)¶ Set flag to show secondary x label.
-
show_x_extended_ticks(value)¶ Set flag to show extended x-axis tick marks.
-
show_xaxis(value)¶ Set flag to show x-axis.
-
show_y_extended_ticks(value)¶ Set flag to show extended y-axis tick marks.
-
show_yaxis(value)¶ Set flag to show y-axis.
-
show_year_markers(value)¶ Set flag to show year markers.
-
xaxis_start_at_min(value)¶ Set flag to start x-axis at the min value.
-
pyxley.charts.mg.barchart module¶
-
class
pyxley.charts.mg.barchart.BarChart(df, figure, x, y, title='Bar Chart', description='Bar Chart', init_params={}, route_func=None)¶ Bases:
pyxley.charts.mg.mg.MGWrapper for MetricsGraphics Bar plot.
https://github.com/mozilla/metrics-graphics/wiki/Chart-Types The user must supply a Figure object. When a route_func is supplied, the dataframe and other options are ignored in favor of the endpoint function.
Parameters: - df (dataframe) – input data.
- figure (mg.Figure) – metricsgraphics figure object.
- x (str) – name of the column corresponding to the x-axis.
- y (str) – name of the column corresponding to the y-axis.
- title (str) – title of the figure.
- description (str) – description of the figure.
- init_params (dict) – parameters used to initialize the figure.
- route_func (function) – endpoint function.
-
static
to_json(df, x, y)¶ Format output for json response.
pyxley.charts.mg.figure module¶
-
class
pyxley.charts.mg.figure.Figure(url, chart_id)¶ Bases:
objectMetricsgraphics Figure class.
This class is a composition of Axes, Graphic, and Layout options.
Parameters: - url (str) – name of the endpoint to create.
- chart_id (str) – html element id.
-
get()¶ Return axes, graphics, and layout options.
pyxley.charts.mg.graphic module¶
-
class
pyxley.charts.mg.graphic.Graphic¶ Bases:
pyxley.charts.mg.mg.OptionHelperGraphic options for the metricsgraphics api.
This class contains all graphics options for the metricsgraphics api. https://github.com/mozilla/metrics-graphics/wiki/Graphic
-
add_baseline(value, label='baseline')¶
-
aggregate_rollover()¶
-
animate_on_load()¶
-
area(value=True)¶
-
as_list()¶ Set flag to automatically map the data to x and y accessors.
-
chart_type(value)¶ Set the MetricsGraphics chart type. Allowed charts are: line, histogram, point, and bar
Parameters: value (str) – chart type. Raises: ValueError– Not a valid chart type.
-
custom_line_color_map(values)¶ Set the custom line color map.
Parameters: values (list) – list of colors. Raises: TypeError– Custom line color map must be a list.
-
decimals(value)¶ Set the number of decimals to display.
-
error(value)¶ Set the error message.
-
format(value)¶ Set the format type. Allowed charts are: count or percentage
Parameters: value (str) – format type. Raises: ValueError– Not a valid format. Must be count or percentage.
-
full_height()¶ Use full height?
-
full_width()¶ Use full width?
-
get()¶ Get graphics options.
-
interpolate(value)¶ Set the interpolate type. See metricsgraphics documentation for interpolate types https://github.com/mozilla/metrics-graphics/wiki/List-of-Options
Parameters: value (str) – interpolate type. Raises: ValueError– Not a valid interpolation method.
-
interpolate_tension(value)¶ Set the interpolate tension.
Parameters: value (str) – interpolate type. Raises: ValueError– Tension must in [0, 1].
-
legend(values)¶ Set the legend labels.
Parameters: values (list) – list of labels. Raises: ValueError– legend must be a list of labels.
-
legend_target(value)¶ Set the legend target.
-
linked()¶ Link the charts?
-
linked_format(value)¶ Set the link format.
-
markers(values)¶ Set the markers.
Parameters: values (list) – list of marker objects. Raises: ValueError– Markers must be a list of objects.
-
max_data_size(value)¶ Set the max data size.
-
missing_text(value)¶ Set the text for missing graphics.
-
point_size(value)¶ Set the point size.
-
show_confidence_band(value)¶ Show confidence band? See metricsgraphics documentation :param value: strings :type value: list
Raises: TypeError– show_confidence_band must be a list of strings.
-
show_missing_background(value=True)¶ Display a background for missing graphics?
-
show_rollover_text(value=True)¶ Show rollover text?
-
show_tooltips(value=True)¶ Show tooltips?
-
target(value)¶ Set target.
-
transition_on_update(value=True)¶ Transition on update?
-
x_rug()¶
-
y_rug()¶
-
pyxley.charts.mg.histogram module¶
-
class
pyxley.charts.mg.histogram.Histogram(df, figure, column, bins, title='Histogram', description='Histogram', init_params={}, route_func=None)¶ Bases:
pyxley.charts.mg.mg.MGWrapper for MetricsGraphics Histogram plot.
https://github.com/mozilla/metrics-graphics/wiki/Histogram The user must supply a Figure object. When a route_func is supplied, the dataframe and other options are ignored in favor of the endpoint function.
Parameters: - df (dataframe) – input data.
- figure (mg.Figure) – metricsgraphics figure object.
- column (str) – name of the column to histogram.
- bins (int) – number of bins.
- title (str) – title of the figure.
- description (str) – description of the figure.
- init_params (dict) – parameters used to initialize the figure.
- route_func (function) – endpoint function.
-
static
to_json(df, column)¶ Format output for json response.
pyxley.charts.mg.layout module¶
-
class
pyxley.charts.mg.layout.Layout¶ Bases:
pyxley.charts.mg.mg.OptionHelperLayout options for the MetricsGraphics API.
https://github.com/mozilla/metrics-graphics/wiki/Layout
-
get()¶ Get layout options.
-
set_margin(top=40, bottom=30, left=50, right=10, buffer_size=8)¶ Set margin of the chart.
Parameters: - top (int) – size of top margin in pixels.
- bottom (int) – size of bottom margin in pixels.
- left (int) – size of left margin in pixels.
- right (int) – size of right margin in pixels.
- buffer_size (int) – buffer size in pixels between the chart and margins.
-
set_size(height=220, width=350, height_threshold=120, width_threshold=160)¶ Set the size of the chart.
Parameters: - height (int) – height in pixels.
- width (int) – width in pixels.
- height_threshold (int) – height threshold in pixels
- width_threshold (int) – width threshold in pixesls
-
pyxley.charts.mg.line_chart module¶
-
class
pyxley.charts.mg.line_chart.LineChart(df, figure, x, y, title='Line Chart', description='Line Chart', init_params={}, timeseries=False, route_func=None)¶ Bases:
pyxley.charts.mg.mg.MGWrapper for MetricsGraphics Line plot.
https://github.com/mozilla/metrics-graphics/wiki/Chart-Types The user must supply a Figure object. When a route_func is supplied, the dataframe and other options are ignored in favor of the endpoint function.
Parameters: - df (dataframe) – input data.
- figure (mg.Figure) – metricsgraphics figure object.
- x (str) – name of the column corresponding to the x-axis.
- y (list(str)) – name of the columns corresponding to the y-axis.
- title (str) – title of the figure.
- description (str) – description of the figure.
- init_params (dict) – parameters used to initialize the figure.
- timeseries (bool) – inidicates whether the plot is a timeseries.
- route_func (function) – endpoint function.
-
static
to_json(df, x, y, timeseries=False)¶ Format output for json response.
pyxley.charts.mg.mg module¶
-
class
pyxley.charts.mg.mg.MG(chart_id, url, params, api_route)¶ Bases:
pyxley.charts.charts.ChartBase class for MetricsGraphics API.
This class creates a MetricsGraphics component based on the supplied options. https://github.com/mozilla/metrics-graphics/wiki/List-of-Options
Parameters: - chart_id (str) – html element id.
- url (str) – name of the endpoint to create.
- params (dict) – parameters and options of the chart.
- api_route (function) – endpoint function.
-
class
pyxley.charts.mg.mg.OptionHelper¶ Bases:
objectOption Base class for the MetricsGraphics API.
-
set_boolean(option, value)¶ Set a boolean option.
Parameters: - option (str) – name of option.
- value (bool) – value of the option.
Raises: TypeError– Value must be a boolean.
-
set_float(option, value)¶ Set a float option.
Parameters: - option (str) – name of option.
- value (float) – value of the option.
Raises: TypeError– Value must be a float.
-
set_integer(option, value)¶ Set an integer option.
Parameters: - option (str) – name of option.
- value (int) – value of the option.
Raises: ValueError– Value must be an integer.
-
set_string(option, value)¶ Set a string option.
Parameters: - option (str) – name of option.
- value (str) – value of the option.
Raises: TypeError– Value must be a string.
-
pyxley.charts.mg.scatter_plot module¶
-
class
pyxley.charts.mg.scatter_plot.ScatterPlot(df, figure, x, y, title='Scatter Plot', description='Scatter Plot', init_params={}, route_func=None)¶ Bases:
pyxley.charts.mg.mg.MGWrapper for MetricsGraphics Scatter plot.
https://github.com/mozilla/metrics-graphics/wiki/Chart-Types The user must supply a Figure object. When a route_func is supplied, the dataframe and other options are ignored in favor of the endpoint function.
Parameters: - df (dataframe) – input data.
- figure (mg.Figure) – metricsgraphics figure object.
- x (str) – name of the column corresponding to the x-axis.
- y (str) – name of the column corresponding to the y-axis.
- title (str) – title of the figure.
- description (str) – description of the figure.
- init_params (dict) – parameters used to initialize the figure.
- route_func (function) – endpoint function.
-
static
to_json(df, x, y)¶ Format output for json response.