Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update base.py #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion graphos/renderers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.template.loader import render_to_string
from ..exceptions import GraphosException
from ..utils import DEFAULT_HEIGHT, DEFAULT_WIDTH, get_random_string, JSONEncoderForHTML
from ..utils import DEFAULT_POSITION, DEFAULT_HEIGHT, DEFAULT_WIDTH, get_random_string, JSONEncoderForHTML
from ..encoders import GraphosEncoder


Expand All @@ -16,11 +16,15 @@ def __init__(self, data_source, html_id=None,
"""
: param data_source: :type graphos.sources.base.BaseDataSource subclass instance.
: param html_id: :type string: Id of the div where you would like chart to be rendered
: param html_class: :type string: Class of the div where you apply style for render the chart
: param position: :type string: Position type of the chart div
: param width: :type integer: Width of the chart div
: param height: :type integer: Height of the chart div
"""
self.data_source = data_source
self.html_id = html_id or get_random_string()
self.html_class = html_class or ""
self.position = position or DEFAULT_POSITION
self.height = height or DEFAULT_HEIGHT
self.width = width or DEFAULT_WIDTH
# options could be an object, a list, a dictionary or a nested object or probably anything.
Expand Down Expand Up @@ -57,6 +61,9 @@ def get_js_template(self):

def get_html_id(self):
return self.html_id

def get_html_class(self):
return self.html_class

def get_context_data(self):
return self.context_data
Expand Down