Click here to Skip to main content
15,564,342 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
const data = {
    labels: ['15/10/22', '16/10/22', '17/10/22','18/10/22'], //pegar do banco de dados (todos os dias)
    datasets: [{
      label: 'WL',
      data: [18, 20, 6, 12], //pegar do banco de dados
      backgroundColor: 'rgba(255,99,132)',
      borderColor:'rgba(255,99,132)',
      borderWidth: 3,
    },
    {
        label:'PlayersOn',
        data: [45, 35, 37, 30],
         backgroundColor: 'rgba(0,255,255)',
        borderColor:'rgba(0,255,255)',
        borderWidth: 3
    },
    {
        label:'Policia',
        data: [10, 10, 10, 24],
         backgroundColor: 'rgba(255,15,15)',
        borderColor:'rgba(255,15,15)',
        borderWidth: 3
    },
    {
        label:'HorasOn',
        data: [1, 45, 15, 36 ],
         backgroundColor: 'rgba(255,255,0)',
        borderColor:'rgba(255,255,0)',
        borderWidth: 3
    }
]
  };

  
  const config = {
    //TIPO DO GRAFIO//
    type: 'bar',
    data,
    options: {
        plugins: {
            subtitle: {
                display: true,
                text: 'Grafico em dias', 
            },
        },
    }
  };

  // definicao da variavel
  const myChart = new Chart(
    document.getElementById('myChart'),
    config
  );


What I have tried:

tentei mudar a biblioteca do head for body but don't
Posted
Updated 21-Oct-22 23:15pm
Comments
Please write your question in english.
VANESSA OLIVEIRA 21-Oct-22 15:56pm    
how do i convert this code to jquery?
I tried to change the library from head to body library but it didn't work
And, I'm Sorry. I dont speak english very well
Member 15627495 22-Oct-22 2:22am    
your code show us a --> json array <- , containing datas with few levels.
Richard Deeming 24-Oct-22 5:55am    
Why? What's the benefit of taking working Javascript code, and rewriting it to add a dependency on large and probably unnecessary library?

With modern browsers, the argument for using jQuery is rapidly disappearing. It's only really useful if you're using third-party plugins which require it.

You Might Not Need jQuery[^]

There really is no conversion.

jQuery is a library for javascript that makes writing javascript easier.

Your "conversion" is to rewrite you javascript code, using jQuery methods where appropriate.
 
Share this answer
 
Quote:
how do i convert this code to jquery?
I tried to change the library from head to body library but it didn't work
And, I'm Sorry. I dont speak english very well
The only thing that can be converted is the below code.
JavaScript
document.getElementById('myChart')

This can be written in jQuery as below.
JavaScript
$('#myChart')
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900