tw2.jit / tw2 / jit / samples /

The default branch has multiple heads

""" Samples of how to use tw2.jit

Each class exposed in the widgets submodule has an accompanying Demo<class>
widget here with some parameters filled out.

The demos implemented here are what is displayed in the tw2.devtools

from tw2.core.resources import JSSymbol

from tw2.jit.widgets import AreaChart
from tw2.jit.samples.samples_data import AreaChartJSONSampleData
class DemoAreaChart(AreaChart):
    """ This is the only sample that loads its data asynchronously """
    offset = 0
    labelOffset = 15
    showAggregates = True
    showLabels = True
    type = 'stacked'
    Label = {
        'type': 'Native',
        'size': 15,
        'family': 'Arial',
        'color': 'white'
    Tips = {
        'enable': True,
        'onShow' : JSSymbol(src="""
        (function(tip, elem) {
            tip.innerHTML = "<b>" + + "</b>: $" + elem.value + " per year income (adjusted for inflation)";

    from tw2.core.jsonify import jsonify
    def request(cls, req):
        return AreaChartJSONSampleData
    base_url = '/area_chart_data/'

import tw2.core as twc

from tw2.jit.widgets import BarChart
from tw2.jit.samples.samples_data import BarChartJSONSampleData
class DemoBarChart(BarChart):
    data = BarChartJSONSampleData

from tw2.jit.widgets import PieChart
from tw2.jit.samples.samples_data import PieChartJSONSampleData
class DemoPieChart(PieChart):
    data = PieChartJSONSampleData
    sliceOffset = 5 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.