JSP Highcharts AND JAVASCRIPT

Asked

Viewed 94 times

1

Good morning I’m making a chart using the Highcharts library, I implemented it in a static way to perform the tests, but now I need to pass the information from the database to him. I read and saw that there are several ways, by XML, by Json. I wanted to know if anyone has used this library and what would be the best way to make this implementation.

I am using JSP with servelt I have already set the list that I will use in the graph as a parameter.

<!-- SCRIPT GRAFICO -->
    <script type="text/javascript">
    var chart = Highcharts.chart('grafico', {
        chart : {
            type : 'column'
        },
        title : {
            text : ' '
        },
        xAxis : {
            categories : [ '06/2016', '07/2016', '08/2016', '09/2016',
                    '10/2016', '11/2016', '12/2016', '01/2017', '02/2017',
                    '03/2017', '04/2017', '05/2017' ],
            labels : {
                x : -10
            }
        },
        yAxis : {
            allowDecimals : false,
            title : {
                text : 'Valor em Reais'
            }
        },
        series : [ {
            name : 'Meses',
            data : [ 113.56, 240.22, 132.22, 215, 326.33, 214.89, 223.45,
                    134.12, 99.23, 119.89, 221.34, 226.12 ]
        } ],
        responsive : {
            rules : [ {
                condition : {
                    maxWidth : 500
                },
                chartOptions : {
                    legend : {
                        align : 'center',
                        verticalAlign : 'bottom',
                        layout : 'horizontal'
                    },
                    yAxis : {
                        labels : {
                            align : 'left',
                            x : 0,
                            y : -5
                        },
                        title : {
                            text : null
                        }
                    },
                    subtitle : {
                        text : null
                    },
                    credits : {
                        enabled : false
                    }
                }
            } ]
        }
    });
</script>




<!--Método Servelt -->
    List<Registros_leitura_medicao> lista_leitura = new Registros_leitura_medicaoDao()
                        .findAll(resp.getCliente().getCodigo().doubleValue(), resp.getBloco(), resp.getUnidade());
                request.setAttribute("lista_leitura", lista_leitura);

                RequestDispatcher dispatcher = request.getRequestDispatcher("principal.jsp");
                dispatcher.forward(request, response);
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.