首页 > 解决方案 > 倒置显示chartjs的三角形pointStyle

问题描述

是否可以将pointStyle: 'triangle'Chart.js 倒置?

我已经在网上搜索了几个小时,试图找到如何反转三角形的解决方案,但就我的研究而言,似乎还没有解决方案(或者我可能只是看错了方向)。

我目前正在处理麻醉记录。这张图片是我的图表现在的样子。我想让红色三角形(收缩)倒置:

我的图表现在看起来像什么,我想让红色三角形(收缩)倒置

标签: angularjschart.js

解决方案


您可以使用点配置rotation的属性来控制点的绘制方式。

new Chart(document.getElementById("chart"), {
  type: "scatter",
  data: {
    datasets: [{
      pointStyle: 'triangle',
      rotation: 60,
      radius: 20, // just here to make the points very visible
      data: [{
        x: 1,
        y: 1
      }, {
        x: 2,
        y: 2
      }, {
        x: 3,
        y: 3
      }]
    }]
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.bundle.min.js"></script>
<canvas id="chart"></canvas>


推荐阅读