<legend id='72Cc1'><style id='72Cc1'><dir id='72Cc1'><q id='72Cc1'></q></dir></style></legend>
<tfoot id='72Cc1'></tfoot>
  • <small id='72Cc1'></small><noframes id='72Cc1'>

      <i id='72Cc1'><tr id='72Cc1'><dt id='72Cc1'><q id='72Cc1'><span id='72Cc1'><b id='72Cc1'><form id='72Cc1'><ins id='72Cc1'></ins><ul id='72Cc1'></ul><sub id='72Cc1'></sub></form><legend id='72Cc1'></legend><bdo id='72Cc1'><pre id='72Cc1'><center id='72Cc1'></center></pre></bdo></b><th id='72Cc1'></th></span></q></dt></tr></i><div id='72Cc1'><tfoot id='72Cc1'></tfoot><dl id='72Cc1'><fieldset id='72Cc1'></fieldset></dl></div>

        • <bdo id='72Cc1'></bdo><ul id='72Cc1'></ul>

        在chartjs的条形顶部添加图像

        Adding image on the top of bar in chartjs(在chartjs的条形顶部添加图像)

        <small id='nahwx'></small><noframes id='nahwx'>

      1. <legend id='nahwx'><style id='nahwx'><dir id='nahwx'><q id='nahwx'></q></dir></style></legend>

        <tfoot id='nahwx'></tfoot>

        1. <i id='nahwx'><tr id='nahwx'><dt id='nahwx'><q id='nahwx'><span id='nahwx'><b id='nahwx'><form id='nahwx'><ins id='nahwx'></ins><ul id='nahwx'></ul><sub id='nahwx'></sub></form><legend id='nahwx'></legend><bdo id='nahwx'><pre id='nahwx'><center id='nahwx'></center></pre></bdo></b><th id='nahwx'></th></span></q></dt></tr></i><div id='nahwx'><tfoot id='nahwx'></tfoot><dl id='nahwx'><fieldset id='nahwx'></fieldset></dl></div>
            <tbody id='nahwx'></tbody>
              <bdo id='nahwx'></bdo><ul id='nahwx'></ul>

                  本文介绍了在chartjs的条形顶部添加图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在我的网站上使用了不同的图表,这导致了一些问题,因此我们迁移到了 chartjs.一切正常,但我有一个在 chartjs 中找不到的要求.

                  I was using a different chart on my site which was causing some issues so we migrated to chartjs. Everything works fine but I have one requirement which I cannot find in chartjs.

                  在我正在开发的网站中,用户进行了评估,并根据评估结果显示图表.

                  In the site I am working on, the user gives an assessment and it shows the graph based on the assessment results.

                  所以在评估中,有一个问题你感觉恶化吗?"如果用户选择是,那么在图表中它会在该条上方显示一个图像,如下图所示.

                  So in the assessment, there is a question "Are you feeling exacerbation?" If the user selects yes then in the graph it shows an image above that bar like below image.

                  在图片中,您可以在两个条形上方看到E".

                  In the picture you can see "E" above the two bars.

                  我想在 chartjs 中实现同样的效果.是否可以?如果没有,那么你们能否建议一种方法来通知用户他们选择了恶化".

                  I want to achieve the same in chartjs. Is it possible? If not then can you guys suggest a way to notify the user that they have selected "exacerbation".

                  谢谢

                  推荐答案

                  您可以使用 chartjs-plugin-labels.

                  请查看以下可运行的代码片段:

                  Please have a look at the following runnable code snippet:

                  new Chart(document.getElementById('myChart'), {
                    type: 'bar',
                    data: {
                      labels: ['A', 'B', 'C', 'D'],
                      datasets: [{
                        label: 'My Dataset',
                        data: [25, 59, 80, 76],
                        fill: false,
                        backgroundColor: ['rgba(255, 99, 132, 0.2)', 'rgba(255, 159, 64, 0.2)', 'rgba(255, 205, 86, 0.2)', 'rgba(75, 192, 192, 0.2)'],
                        borderColor: ['rgb(255, 99, 132)', 'rgb(255, 159, 64)', 'rgb(255, 205, 86)', 'rgb(75, 192, 192)', 'rgb(54, 162, 235)'],
                        borderWidth: 1
                      }]
                    },
                    options: {
                      plugins: {
                        labels: {
                          render: 'image',
                          textMargin: 10,
                          images: [
                            {
                              src: 'https://i.stack.imgur.com/9EMtU.png',
                              width: 20,
                              height: 20
                            },
                            null, 
                            {
                              src: 'https://i.stack.imgur.com/9EMtU.png',
                              width: 20,
                              height: 20
                            },
                            null
                          ]
                        }
                      },
                      layout: {
                        padding: {
                          top: 30
                        }
                      },
                      legend: {
                        display: false
                      },
                      scales: {
                        yAxes: [{
                          ticks: {
                            beginAtZero: true
                          }
                        }]
                      }
                    }
                  });

                  canvas {
                    max-width: 300px;
                  }

                  <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js"></script>
                  <script src="https://cdn.jsdelivr.net/gh/emn178/chartjs-plugin-labels/src/chartjs-plugin-labels.js"></script>
                  <canvas id="myChart" width="10" height="6"></canvas>

                  这篇关于在chartjs的条形顶部添加图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ChartJS Version 3 - common legend for multiple line charts(ChartJS 版本 3 - 多个折线图的常用图例)
                  Charts.js scales yaxes ticks min max doesnt work(Charts.js 缩放 yaxes 刻度 min max 不起作用)
                  How to expand the slice of donut chart in chartjs?(如何在chartjs中扩展圆环图的切片?)
                  Chart.js yAxes Ticks stepSize not working (fiddle)(Chart.js yAxes Ticks stepSize 不起作用(小提琴))
                  Rounded corners on chartJS v.2 - bar charts (with negative values)(chartJS v.2 上的圆角 - 条形图(带负值))
                  How to hide value in Chart JS bar(如何在 Chart JS 栏中隐藏值)
                  1. <tfoot id='SW6QP'></tfoot>
                      <tbody id='SW6QP'></tbody>

                      • <bdo id='SW6QP'></bdo><ul id='SW6QP'></ul>
                        <legend id='SW6QP'><style id='SW6QP'><dir id='SW6QP'><q id='SW6QP'></q></dir></style></legend>

                      • <i id='SW6QP'><tr id='SW6QP'><dt id='SW6QP'><q id='SW6QP'><span id='SW6QP'><b id='SW6QP'><form id='SW6QP'><ins id='SW6QP'></ins><ul id='SW6QP'></ul><sub id='SW6QP'></sub></form><legend id='SW6QP'></legend><bdo id='SW6QP'><pre id='SW6QP'><center id='SW6QP'></center></pre></bdo></b><th id='SW6QP'></th></span></q></dt></tr></i><div id='SW6QP'><tfoot id='SW6QP'></tfoot><dl id='SW6QP'><fieldset id='SW6QP'></fieldset></dl></div>

                          <small id='SW6QP'></small><noframes id='SW6QP'>