pycrossword  0.4
Pure-Python implementation of a crossword puzzle generator and editor
Functions
pycross.utils.graphs Namespace Reference

Functions

def data_from_dict (data, panda=True, xy=True)
 Converts a Python dictionary into a pandas DataFrame or altair NamedData More...
 
def data_from_url (url)
 Loads data from a URL into an altair UrlData object. More...
 
def data_from_array (array)
 Loads data from an array (list) into an altair InlineData object. More...
 
def make_chart (data, mark_type='point', mark_props={}, x_title='x', x_props={}, y_title='y', y_props={}, color='x:N', shape='x:N', text_col=None, text_props={}, other_axes_and_channels={}, interactive=True, scale_factor=1.0, svg=False, save_file='chart.html', on_save=None)
 Constructs an Altair graph from user data optionally saving it to an HTML file. More...
 

Function Documentation

◆ data_from_array()

def pycross.utils.graphs.data_from_array (   array)

Loads data from an array (list) into an altair InlineData object.

Parameters
arraylist data values
Returns
altair InlineData object

◆ data_from_dict()

def pycross.utils.graphs.data_from_dict (   data,
  panda = True,
  xy = True 
)

Converts a Python dictionary into a pandas DataFrame or altair NamedData

Parameters
pandabool True to convert to a pandas DataFrame object; False to convert to a NamedData object
xybool if True, the data dict will be aggregated into a dict with 2 keys: x: all keys and y: all values; e.g. if data is originally:
{'a':}
it will be transformed into:
```{'x': ['a', 'b', 'c'], 'y': [1, 2, 3]
Returns
DataFrame|NamedData converted object

◆ data_from_url()

def pycross.utils.graphs.data_from_url (   url)

Loads data from a URL into an altair UrlData object.

Parameters
urlstr URL string
Returns
altair UrlData object

◆ make_chart()

def pycross.utils.graphs.make_chart (   data,
  mark_type = 'point',
  mark_props = {},
  x_title = 'x',
  x_props = {},
  y_title = 'y',
  y_props = {},
  color = 'x:N',
  shape = 'x:N',
  text_col = None,
  text_props = {},
  other_axes_and_channels = {},
  interactive = True,
  scale_factor = 1.0,
  svg = False,
  save_file = 'chart.html',
  on_save = None 
)

Constructs an Altair graph from user data optionally saving it to an HTML file.

Parameters
dataDataFrame|NamedData source data
mark_typestr graph mark type, any of: 'area', 'bar', 'circle', 'geoshape', 'image', 'line', 'point', 'rect', 'rule', 'square', 'text', 'tick', 'boxplot', 'errorband', 'errorbar'
mark_propsdict property dictionary for the marks
x_titlestr label for the horizontal axis
x_propsdict property dictionary for the horizontal axis
y_titlestr label for the vertical axis
y_propsdict property dictionary for the vertical axis
colorstr|dict graph color settings
shapestr|dict graph shape settings
text_colstr text labels for the marks
text_propsdict proprties of the text labels
other_axes_and_channelsdict additional axes / channels
interactivebool whether the chart is interactive or static
scale_factorfloat scale (zoom) factor for graph
svgbool whether to use the SVG (vector image) renderer
save_filestr path to output file (HTML)
on_savecallable callback function called when the chart has been saved to the file; takes one argument – the output file path