首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JS图表suggestedMin suggestedMax不工作

JS图表suggestedMin suggestedMax不工作
EN

Stack Overflow用户
提问于 2021-09-06 16:36:15
回答 1查看 24关注 0票数 1

我是JSCharts的新手,我有两个图表,但它们的大小不同,我如何才能使它们的大小相同?我在折线图中尝试了suggestedMin和suggestedMax,但它仍然从0开始Y刻度。另外,我想要确保两个封闭的图形是相同的高度,线条应该是气泡图。

代码语言:javascript
复制
<script>
  var areachart = document.getElementById("lineprices").getContext("2d");
  const historic_mean = JSON.parse("{{historic_mean|escapejs}}");
  const historic_max = JSON.parse("{{historic_max|escapejs}}");
  const historic_min = JSON.parse("{{historic_min|escapejs}}");
  const historic_dates = JSON.parse("{{historic_dates|escapejs}}");
  console.log("historic_mean", historic_mean);
  console.log("historic_max", historic_max);
  console.log("historic_min", historic_min);
  console.log("historic_dates", historic_dates);

  var configareachart = new Chart(areachart, {
    type: "line",
    data: {
      labels: historic_dates,
      datasets: [
        {
          label: "My First dataset",
          borderWidth: "2",
          borderColor: "#5B92FF",
          backgroundColor: "rgba(0, 0, 0, 0)",
          data: historic_max,
        },
        {
          label: "My Second dataset",
          borderWidth: "2",
          borderColor: "#F85778",
          backgroundColor: "rgba(0, 0, 0, 0)",
          data: historic_mean,
        },
        {
          label: "My Third dataset",
          borderWidth: "2",
          borderColor: "#1FC96E",
          backgroundColor: "rgba(0, 0, 0, 0)",
          data: historic_min,
        },
      ],
    },
    options: {
      responsive: true,
      maintainAspectRatio: false,
      elements: {
        point: {
          radius: 0,
        },
      },
      title: {
        display: false,
        text: "Chart.js Line Chart - Stacked Area",
      },
      tooltips: {
        mode: "index",
      },
      hover: {
        mode: "index",
      },
      legend: {
        display: false,
      },
      scales: {
        xAxes: [
          {
            ticks: {
              display: true,
              fontColor: "#90b5ff",
            },
            scaleLabel: {
              display: false,
              labelString: "Month",
            },
          },
        ],
        yAxes: [
          {
            ticks: {
              display: true,
              fontColor: "#90b5ff",
              suggestedMin: 10000,
              suggestedMax: 100000,
              stepValue: 5000,
            },
          },
        ],
      },
    },
  });
</script>

EN

回答 1

Stack Overflow用户

发布于 2021-09-06 16:59:38

显然,不要使用

代码语言:javascript
复制
responsive: true,
maintainAspectRatio: false,
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69077825

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档