空圆圈 - ChartJS的折线图中只有点划线

时间:2017-11-14 14:21:12

标签: angular charts chart.js chartjs-2.6.0

如何在chartJS折线图中实现这一点?

enter image description here

1 个答案:

答案 0 :(得分:1)

以下是获取您所追求的点样式的示例:

  

可以找到折线图的点选项文档here

     

以下代码here

的codePen

HTML:

<html>
  <body>
    <div class="myChartDiv">
      <canvas id="myChart" width="600" height="400"></canvas>
    </div>
  </body>
</html>

JS:

new Chart(document.getElementById("myChart"), {
  type: "line",
  data: {
    labels: ["January", "February", "March", "April", "May", "June"],
    datasets: [
      {
        label: "My First Dataset",
        data: [20, 25, 22, 19, 31, 40],
        fill: true,
        borderColor: "rgb(75, 192, 192)",
        backgroundColor: "rgba(0,0,0,0.1)",
        borderWidth: 2,
        lineTension: 0,
        /* point options */
        pointBorderColor: "blue", // blue point border
        pointBackgroundColor: "white", // wite point fill
        pointBorderWidth: 1, // point border width
      }
    ]
  },
  options: {
    legend: {
      labels: {
        usePointStyle: true, // show legend as point instead of box
        fontSize: 10 // legend point size is based on fontsize
      }
    }
  }
});