Jump to content

Recommended Posts

Posted

Bom Dia Pessoal

Eu tenho um gráfico criado em chart.js só que não aparece o título, nem a "tooltip" tão interessante como uma versão antiga que tinha criado, apesar de o código ser quase igual.

Alguém tem ideia do que poderá ser?

  <script>
                        $.post("data.php",
                            function(data) {
                                console.log(data);
                                var mês = [];
                                var linha = [];
                                var tc = [];

                                for (var i in data) {
                                    linha.push(data[i].linha);
                                    mês.push(data[i].mês);
                                    tc.push(data[i].tc);
                                }

                                var data1 = {
                                    labels: mês,
                                    linha,
                                    tc,

                                    datasets: [{
                                        label: 'Bootleneck Linha',
                                        fillColor: "rgba(39, 93, 245, 0.56)",
                                        strokeColor: "rgba(39, 93, 245, 0.83)",
                                        highlightFill: "rgba(39, 93, 245, 0.83)",
                                        data: tc,
                                        mês,
                                        linha,
                                    }]
                                };

                                $.post("data2.php",
                                    function(data) {
                                        console.log(data);
                                        var mês = [];
                                        var linha = [];
                                        var tc = [];

                                        for (var i in data) {
                                            linha.push(data[i].linha);
                                            mês.push(data[i].mês);
                                            tc.push(data[i].tc);
                                        }


                                        var data2 = {
                                            labels: mês,
                                            tc,
                                            linha,

                                            datasets: [{
                                                label: 'Bootleneck Linha',
                                                fillColor: "rgba(245, 93, 93, 0.5)",
                                                strokeColor: "rgba(245, 93, 93, 1)",
                                                highlightFill: "rgba(245, 93, 93, 1)",
                                                data: tc,
                                            }]
                                        };

                                        var ctx = document.querySelector("#graph").getContext("2d");
                                        var myBarChart = new Chart(ctx).Bar(data1);

                                        $("#btn1").on("click", function() {
                                            var context1 = document.querySelector('#graph').getContext('2d');
                                            new Chart(context1).Bar(data1);
                                        });
                                        $("#btn2").on("click", function() {
                                            var context2 = document.querySelector('#graph').getContext('2d');
                                            new Chart(context2).Bar(data2);

                                        });

                                    });

                            });
                    </script>
 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.