<commit_before>import random
import string
import json

from django.template.loader import render_to_string


random_letter = lambda: random.choice(string.ascii_letters)

DEFAULT_HEIGHT = 300
DEFAULT_WIDTH = 600


class BaseChart(object):
    def __init__(self, data_source, html_id=None,
                 width=None, height=None,
                 options={}, *args, **kwargs):
        self.data_source = data_source
        self.html_id = html_id or "".join([random_letter()
                                          for el in range(10)])

        self.heigth = height or DEFAULT_HEIGHT
        self.width = width or DEFAULT_WIDTH

    def get_data_json(self):
        return json.dumps(self.get_data())

    def get_data(self):
        return self.data_source.get_data()

    def get_html_id(self):
        return self.html_id

    def as_html(self):
        context = {"data": self.get_data(), "chart": self}
        return render_to_string(self.get_template(), context)<commit_msg>added a couple of attributes and methods to BaseChart<commit_after>import random
import string
import json

from django.template.loader import render_to_string


random_letter = lambda: random.choice(string.ascii_letters)

DEFAULT_HEIGHT = 300
DEFAULT_WIDTH = 600


class BaseChart(object):
    def __init__(self, data_source, html_id=None,
                 width=None, height=None,
                 options={}, *args, **kwargs):
        self.data_source = data_source
        self.html_id = html_id or "".join([random_letter()
                                          for el in range(10)])

        self.height = height or DEFAULT_HEIGHT
        self.width = width or DEFAULT_WIDTH
        self.options = options
        self.header = data_source.get_header()

    def get_data(self):
        return self.data_source.get_data()

    def get_data_json(self):
        return json.dumps(self.get_data())

    def get_options_json(self):
        return json.dumps(self.options)

    def get_html_id(self):
        return self.html_id

    def as_html(self):
        context = {"data": self.get_data(), "chart": self}
        return render_to_string(self.get_template(), context)
{'fraction_non_alphanumeric': 0.0953262378528459, 'fraction_numerical': 0.007403979639055993, 'mean_word_length': 2.645868465430017, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7428439', 'n_tokens_mistral': 653, 'n_tokens_neox': 618, 'n_words': 151}