Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
Scatter plot not showing anything chartjs needs some debugging

var ctx = document.getElementById("myChart");

var myChart = new Chart(ctx, {
  "type": "scatter",
  "data": {
    "datasets": [
      {
        "label": "EARRINGS",
        "data": [
          {
            "x": 13,
            "y": "19-07-2021"
          },
          {
            "x": 5,
            "y": "12-08-2021"
          }
        ],
        "showLine": true,
        "fill": false,
        "borderColor": "rgb(125,60,122)"
      },
      {
        "label": "RINGS",
        "data": [
          {
            "x": 4,
            "y": "09-08-2021"
          },
          {
            "x": 1,
            "y": "06-08-2021"
          },
          {
            "x": 9,
            "y": "12-08-2021"
          }
        ],
        "showLine": true,
        "fill": false,
        "borderColor": "rgb(125,60,122)"
      },
      {
        "label": "BANGLES",
        "data": [
          {
            "x": 2,
            "y": "06-08-2021"
          },
          {
            "x": 1,
            "y": "12-08-2021"
          }
        ],
        "showLine": true,
        "fill": false,
        "borderColor": "rgb(125,60,122)"
      },
      {
        "label": "NECKLACES",
        "data": [
          {
            "x": 1,
            "y": "12-08-2021"
          }
        ],
        "showLine": true,
        "fill": false,
        "borderColor": "rgb(125,60,122)"
      }
    ]
  },
  "options": {
    "scales": {
      "x": {
        "title": {
          "display": true,
          "text": "Date"
        },
        "ticks": {
          "precision": 0,
          "maxTicksLimit": 9
        }
      },
      "y": {
        "title": {
          "display": true,
          "text": "No of Trials"
        },
        "ticks": {
          "precision": 0
        }
      }
    }
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js"></script>
<canvas id="myChart"></canvas>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

2 things, dont use an outdated version of the lib since your config wont work and the y scale is a linear scale by default so if you want to use strings you need to specify it as a category scale

var ctx = document.getElementById("myChart");

var myChart = new Chart(ctx, {
  "type": "scatter",
  "data": {
    "datasets": [
      {
        "label": "EARRINGS",
        "data": [
          {
            "x": 13,
            "y": "19-07-2021"
          },
          {
            "x": 5,
            "y": "12-08-2021"
          }
        ],
        "showLine": true,
        "fill": false,
        "borderColor": "rgb(125,60,122)"
      },
      {
        "label": "RINGS",
        "data": [
          {
            "x": 4,
            "y": "09-08-2021"
          },
          {
            "x": 1,
            "y": "06-08-2021"
          },
          {
            "x": 9,
            "y": "12-08-2021"
          }
        ],
        "showLine": true,
        "fill": false,
        "borderColor": "rgb(125,60,122)"
      },
      {
        "label": "BANGLES",
        "data": [
          {
            "x": 2,
            "y": "06-08-2021"
          },
          {
            "x": 1,
            "y": "12-08-2021"
          }
        ],
        "showLine": true,
        "fill": false,
        "borderColor": "rgb(125,60,122)"
      },
      {
        "label": "NECKLACES",
        "data": [
          {
            "x": 1,
            "y": "12-08-2021"
          }
        ],
        "showLine": true,
        "fill": false,
        "borderColor": "rgb(125,60,122)"
      }
    ]
  },
  "options": {
    "scales": {
      "x": {
        "title": {
          "display": true,
          "text": "Date"
        },
        "ticks": {
          "precision": 0,
          "maxTicksLimit": 9
        }
      },
      "y": {
        type: 'category',
        "title": {
          "display": true,
          "text": "No of Trials"
        },
        "ticks": {
          "precision": 0
        }
      }
    }
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.5.1/chart.js"></script>
<canvas id="myChart"></canvas>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda