svg.charts.graph¶
svg.charts.graph
The base module for svg.charts classes.
Classes¶
-
class
svg.charts.graph.Graph(config={})¶ Base object for generating SVG Graphs
Synopsis
This class is only used as a superclass of specialized charts. Do not attempt to use this class directly, unless creating a new chart type.
For examples of how to subclass this class, see the existing specific subclasses, such as svn.charts.Pie.
- svg.charts.bar
- svg.charts.line
- svg.charts.pie
- svg.charts.plot
- svg.charts.time_series
-
add_data(conf)¶ Add data to the graph object. May be called several times to add additional data sets.
conf should be a dictionary including ‘data’ and ‘title’ keys
-
add_defs(defs)¶ Override and place code to add defs here. TODO: what are defs?
-
add_popup(x, y, label)¶ Add pop-up information to a point on the graph.
-
burn()¶ Process the template with the data and config which has been set and return the resulting SVG.
Raises ValueError when no data set has been added to the graph object.
-
calculate_bottom_margin()¶ Calculate the margin in pixels below the plot area, setting border_bottom.
-
calculate_left_margin()¶ Calculates the margin to the left of the plot area, setting border_left.
-
calculate_right_margin()¶ Calculate the margin in pixels to the right of the plot area, setting border_right.
-
calculate_top_margin()¶ Calculate the margin in pixels above the plot area, setting border_top.
-
clear_data()¶ This method removes all data from the object to create a new graph with the same config options.
-
draw_graph()¶ The central logic for drawing the graph.
Sets self.graph (the ‘g’ element in the SVG root)
-
draw_titles()¶ Draws the graph title and subtitle
-
draw_x_guidelines(label_height, count)¶ Draw the X-axis guidelines
-
draw_x_labels()¶ Draw the X axis labels
-
draw_y_guidelines(label_height, count)¶ Draw the Y-axis guidelines
-
draw_y_labels()¶ Draw the Y axis labels
-
get_stylesheet_resources()¶ Get the stylesheets for this instance
-
make_datapoint_text(x, y, value, style=None)¶ Add text for a datapoint
-
max_y_label_width_px()¶ Calculate the width of the widest Y label. This will be the character height if the Y labels are rotated.
-
parse_css()¶ Take a .css file (classes only please) and parse it into a dictionary of class/style pairs.
-
render_inline_styles()¶ Hard-code the styles into the SVG XML if style sheets are not used.
-
start_svg()¶ Base SVG Document Creation
-
x_label_offset(width)¶ Return an offset for drawing the x label. Currently returns 0.
-
y_label_offset(height)¶ Return an offset for drawing the y label. Currently returns 0.