예제 #1
0
def init_javascript(path='/static/custom/matta'):
    '''
    Returns the Javascript code needed to load matta libraries.

    In the IPython notebook this is loaded automatically by adding the output
    of this function to custom.js script.
    '''
    paths = {
        'd3': '{0}/d3.v3.min'.format(path),
        'wordcloud': '{0}/d3.layout.cloud'.format(path),
        'tile': '{0}/d3.geo.tile'.format(path),
        'sankey': '{0}/d3.sankey'.format(path),
        'matta': '{0}/matta'.format(path),
        'force_directed': '{0}/matta.force-directed'.format(path),
        'force_edge_bundling': '{0}/d3.ForceEdgeBundling'.format(path),
        'topojson': '{0}/topojson'.format(path),
        'leaflet': '{0}/leaflet-0.7.3/leaflet-src'.format(path),
        'colajs': '{0}/cola.v3.min'.format(path),
        'cartogram': '{0}/cartogram '.format(path),
    }

    template = '''
<script>
$(document).ready(function() {{
    if (!require.defined('matta')) {{
        require.config({{
          paths: {0}
        }});

        require(['matta'], function(matta) {{
            matta.add_css('{1}');
        }});
    }}
}});
</script>
<span class="label label-info">matta</span> Javascript code added.
        '''.format(_dump_json(paths), path  + '/matta.css')

    return HTML(template)
예제 #2
0
def init_javascript(path='/static/custom/matta'):
    '''
    Returns the Javascript code needed to load matta libraries.

    In the IPython notebook this is loaded automatically by adding the output
    of this function to custom.js script.
    '''
    paths = {
        'd3': '{0}/d3.v3.min'.format(path),
        'wordcloud': '{0}/d3.layout.cloud'.format(path),
        'tile': '{0}/d3.geo.tile'.format(path),
        'sankey': '{0}/d3.sankey'.format(path),
        'matta': '{0}/matta'.format(path),
        'force_directed': '{0}/matta.force-directed'.format(path),
        'force_edge_bundling': '{0}/d3.ForceEdgeBundling'.format(path),
        'topojson': '{0}/topojson'.format(path),
        'leaflet': '{0}/leaflet-0.7.3/leaflet-src'.format(path),
    }

    template = '''
<script>
$(document).ready(function() {{
    if (!require.defined('matta')) {{
        require.config({{
          paths: {0}
        }});

        require(['matta'], function(matta) {{
            matta.add_css('{1}');
        }});
    }}
}});
</script>
<span class="label label-info">matta</span> Javascript code added.
        '''.format(_dump_json(paths), path + '/matta.css')

    return HTML(template)
예제 #3
0
def dump_data(data, json_name):
    with open(json_name, 'w') as f:
        f.write(_dump_json(data))
예제 #4
0
def dump_data(data, json_name):
    with open(json_name, 'w') as f:
        f.write(_dump_json(data))