Problems with the template to generate a graphic using highcharts with bottle

0

I am working with the framwork bottle for the first time, I want to generate a pie chart using highcharts , for it I pull the data by means of a query in a database SQL-Server , then I transform them to Json , this is my code:

@route('/prueba_grafico')
def index():
    c.execute("exec insumo_medico")
    result = c.fetchall()
    for raw in result:
        cant_total = str(raw[0])
        cant_desabastecidos = str(raw[1])
        cant_normal = str(raw[2])
        cant_sobre_stock = str(raw[3])

    parametros = {
        'chart': {
            'plotBackgroundColor': None,
            'plotBorderWidth': None,
            'plotShadow': False,
            'type': 'pie'
        },
        'title': {
            'text': 'ESTADO DE STOCK DE MEDICAMENTOS'
        },
        'tooltip': {
            'pointFormat': '{series.name}: <b>{point.y:.1f}</b>'
        },
        'plotOptions': {
            'pie': {
                'allowPointSelect': True,
                'cursor': 'pointer',
                'dataLabels': {
                    'enabled': True,
                    'format': '<b>{point.name}</b>: {point.percentage:.1f} %',
                }
            }
        },
        'series': [{
            'name': 'Brands',
            'colorByPoint': 'true',
            'data': [{
                'name': 'Insumos Medicos Desabastecidos',
                'y': cant_desabastecidos,
                'sliced': 'true',
                'selected': 'true'
            }, {
                'name': 'Insumos Medicos NormoStock',
                'y': cant_normal
            }, {
                'name': 'Insumos Medicos SobreStock',
                'y': cant_sobre_stock
            }, ]
        }]
    };
    row = json.dumps(parametros)

    output = template('grafic_prueba.html', dict(rows=row))

    return (output)

and this is the code in my template

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>

<script type="text/javascript">
    $(document).ready(function() {
        var parametros = JSON.parse((rows));
        $('#container').highcharts(parametros);
    });
</script>
<h1>Registros</h1>
    <table id="myTable" class="tablesorter">
    <thead>
    </thead>
    </table>

It is not generating a particular error, however, the graph is not showing me, I have worked with web2py but doing it with bottle is new for me.

    
asked by Fernando M. Goycochea 30.05.2018 в 23:53
source

0 answers