Reference

Base Classes

Django-Plottings is intended to work in a similar manner of the Django class based views by subclassing and overriding methods that provide the functionality required to build the plots.

The commom methods to be subclassed are:

  • get_plot_data(): That contain all the logic required to provide plotter_function with data.

  • get_plot_options(): That provide the plotting function with extra parameters for customizing the way the plot is built.

  • plotter_function(data, **options): That gets the data and the parameters and returns a figure object ready to be dumped in the formats required by the building class.

View Classes

These classes are a mixture of Django views and Plottings base object so parameters are added to the class by the setup() method and accesible from the class instance.

They work as other class based view by passing the to the path() function calling the as_view() method.

PNGPlotView

class plottings.PNGPlotView(**kwargs)

A Django View class that returns a PNG graphic file as HttpResponse payload.

classmethod as_view(**initkwargs)

Main entry point for a request-response process.

buffer_class

alias of BytesIO

get(request, *args, **kwargs)

This methods generates the GET response.

get_disposition()

Override this method if you want to dinamically set the content disposition of the HttpResponse object.

get_encoding()

Override this method if you want to dinamically set the encoding of the generated file.

get_filename()

Override this method if you want to dinamically set the name of the file generated from the figure when the disposition is attachment.

get_filetype()

Override this method to dinamically set the file format of the generated file.

get_headers(buffer)

Returns a dict of parameters to be used as headers of the response object. Override it to provide extend the values it contains.

get_image()

Returns a in memory file object with the plot image.

get_mimetype()

Override this method if you want to dinamically set the mimetype of the generated file.

get_plot_data()

Override this method to provide data to plotter_function() method.

get_plot_options()

Override this method to provide the plotter function with extra parameters to customize the graphical generation.

get_save_options()

Override this method to provide get_image function with extra parameters to set file properties.

head(request, *args, **kwargs)

This methods generates the HEAD response.

http_response_class

alias of HttpResponse

options(request, *args, **kwargs)

Handle responding to requests for the OPTIONS HTTP verb.

static plotter_function(data, **options)

Override this method with an statically linked function that returns a Matplotlib figure to be lately used to render the plot in given file formats.

Data:

A data structure that contains the information to be graphically modeled by the plotter function.

Options:

A dict of parameters used to customize the image rendering.

process_image(image_buffer)

Override this method to add modifications to the image such as watermarks before caching.

setup(request, *args, **kwargs)

Initialize attributes shared by all view methods.

SVGZPlotView

class plottings.SVGZPlotView(**kwargs)

A Django View class that returns a SVGZ graphic file as HttpResponse payload.

classmethod as_view(**initkwargs)

Main entry point for a request-response process.

buffer_class

alias of BytesIO

get(request, *args, **kwargs)

This methods generates the GET response.

get_disposition()

Override this method if you want to dinamically set the content disposition of the HttpResponse object.

get_encoding()

Override this method if you want to dinamically set the encoding of the generated file.

get_filename()

Override this method if you want to dinamically set the name of the file generated from the figure when the disposition is attachment.

get_filetype()

Override this method to dinamically set the file format of the generated file.

get_headers(buffer)

Returns a dict of parameters to be used as headers of the response object. Override it to provide extend the values it contains.

get_image()

Returns a in memory file object with the plot image.

get_mimetype()

Override this method if you want to dinamically set the mimetype of the generated file.

get_plot_data()

Override this method to provide data to plotter_function() method.

get_plot_options()

Override this method to provide the plotter function with extra parameters to customize the graphical generation.

get_save_options()

Override this method to provide get_image function with extra parameters to set file properties.

head(request, *args, **kwargs)

This methods generates the HEAD response.

http_response_class

alias of HttpResponse

options(request, *args, **kwargs)

Handle responding to requests for the OPTIONS HTTP verb.

static plotter_function(data, **options)

Override this method with an statically linked function that returns a Matplotlib figure to be lately used to render the plot in given file formats.

Data:

A data structure that contains the information to be graphically modeled by the plotter function.

Options:

A dict of parameters used to customize the image rendering.

process_image(image_buffer)

Override this method to add modifications to the image such as watermarks before caching.

setup(request, *args, **kwargs)

Initialize attributes shared by all view methods.

File Classes

These two classes are intended to be initiallized and then to proceed to call the get_file() method that returns a Django file object ready to be assigned to a Django ImageField for saving and storing the data in a media folder.

PNGPlotToFile

class plottings.PNGPlotToFile

This class is used to create a Django a File object storing a PNG plot.

buffer_class

alias of BytesIO

file_class

alias of File

get_file()

This method returns a Django file object ready to be assigned to an ImageField.

get_filename()

Override this method to dinamically change the name of the file object created by the get_file() method.

get_filetype()

Override this method to dinamically set the file format of the generated file.

get_image()

Returns a in memory file object with the plot image.

get_plot_data()

Override this method to provide data to plotter_function() method.

get_plot_options()

Override this method to provide the plotter function with extra parameters to customize the graphical generation.

get_save_options()

Override this method to provide get_image function with extra parameters to set file properties.

static plotter_function(data, **options)

Override this method with an statically linked function that returns a Matplotlib figure to be lately used to render the plot in given file formats.

Data:

A data structure that contains the information to be graphically modeled by the plotter function.

Options:

A dict of parameters used to customize the image rendering.

process_image(image_buffer)

Override this method to add modifications to the image such as watermarks before caching.

SVGZPlotToFile

class plottings.SVGZPlotToFile

This class is used to create a Django a File object storing an SVGZ plot.

buffer_class

alias of BytesIO

file_class

alias of File

get_file()

This method returns a Django file object ready to be assigned to an ImageField.

get_filename()

Override this method to dinamically change the name of the file object created by the get_file() method.

get_filetype()

Override this method to dinamically set the file format of the generated file.

get_image()

Returns a in memory file object with the plot image.

get_plot_data()

Override this method to provide data to plotter_function() method.

get_plot_options()

Override this method to provide the plotter function with extra parameters to customize the graphical generation.

get_save_options()

Override this method to provide get_image function with extra parameters to set file properties.

static plotter_function(data, **options)

Override this method with an statically linked function that returns a Matplotlib figure to be lately used to render the plot in given file formats.

Data:

A data structure that contains the information to be graphically modeled by the plotter function.

Options:

A dict of parameters used to customize the image rendering.

process_image(image_buffer)

Override this method to add modifications to the image such as watermarks before caching.

Value Classes

Both classes work the same way: first initialization of the class for then call the get_value() method that returns a variable intended to be passed to the Django Template System to render the webpage with the image included.

PNGBase64PlotToValue

class plottings.PNGBase64PlotToValue

This class is used to dump a PNG figure encoded in Base64 format into a variable ready to be passed to the template engine to render it in a webpage.

buffer_class

alias of BytesIO

get_filetype()

Override this method to dinamically set the file format of the generated file.

get_image()

Returns a in memory file object with the plot image.

get_plot_data()

Override this method to provide data to plotter_function() method.

get_plot_options()

Override this method to provide the plotter function with extra parameters to customize the graphical generation.

get_save_options()

Override this method to provide get_image function with extra parameters to set file properties.

get_value()

Add the returned value of this method to the context dictionary that is passed to render the template.

static plotter_function(data, **options)

Override this method with an statically linked function that returns a Matplotlib figure to be lately used to render the plot in given file formats.

Data:

A data structure that contains the information to be graphically modeled by the plotter function.

Options:

A dict of parameters used to customize the image rendering.

process_image(image_buffer)

Override this method to add modifications to the image such as watermarks before caching.

SVGPlotToValue

class plottings.SVGPlotToValue

This class is used to create a SVG figure into a variable ready to be passed to the template engine to render it in a webpage.

buffer_class

alias of StringIO

get_filetype()

Override this method to dinamically set the file format of the generated file.

get_image()

Returns a in memory file object with the plot image.

get_plot_data()

Override this method to provide data to plotter_function() method.

get_plot_options()

Override this method to provide the plotter function with extra parameters to customize the graphical generation.

get_save_options()

Override this method to provide get_image function with extra parameters to set file properties.

get_value()

Add the returned value of this method to the context dictionary that is passed to render the template.

static plotter_function(data, **options)

Override this method with an statically linked function that returns a Matplotlib figure to be lately used to render the plot in given file formats.

Data:

A data structure that contains the information to be graphically modeled by the plotter function.

Options:

A dict of parameters used to customize the image rendering.

process_image(image_buffer)

Override this method to add modifications to the image such as watermarks before caching.