<bdo id='SLcfk'></bdo><ul id='SLcfk'></ul>

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

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

        ChartJS 条形图,带有对应于每个条形图的图例

        ChartJS bar chart with legend which corresponds to each bar(ChartJS 条形图,带有对应于每个条形图的图例)

              <tbody id='0XpJG'></tbody>

              • <bdo id='0XpJG'></bdo><ul id='0XpJG'></ul>

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

                  <small id='0XpJG'></small><noframes id='0XpJG'>

                • <legend id='0XpJG'><style id='0XpJG'><dir id='0XpJG'><q id='0XpJG'></q></dir></style></legend>

                • 本文介绍了ChartJS 条形图,带有对应于每个条形图的图例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试了解其条形图上的 ChartJS 文档.它对我来说没有意义,因为顶部的标签在某种意义上看起来好像它只适用于第一个条形(基于颜色),而在另一种意义上,整个图表(它是唯一的标签不在工具提示中,它在前面和中间)

                  I'm trying to understand the ChartJS documentation on their bar chart. It doesn't make a log of sense to me as the label at the top in once sense looks as though it applies to just the first bar (based on color) and in another sense, the entire chart (it is the only label that's not in a tooltip and it is front and center)

                  我一直在努力让它更像他们的折线图,它显示了一个带有标签的图例和一个与图表上的每条线相关的彩色方块.(他们没有多线图的例子,但它确实像这样工作).

                  I've been struggling to make it more like their line chart, which shows a legend with a label and a colored square related to each line on the chart. (they haven't got an example of a multiline chart, but it does work like this).

                  数据对象中的标签属性被转换为栏旁边的值,例如 labels: ['36%', '10%', '18%', '34%', '0%', '2%']

                  The labels property within the data object gets translated to the value next to the bar, eg labels: ['36%', '10%', '18%', '34%', '0%', '2%']

                  我想在顶部有一个图例,表明水色是苹果,灰色是橙色,绿色是梨等,但我最接近的是提供 data.datasets 一个对象数组并制作标签和数组,这只会导致条形组,例如 here.

                  I want a legend at the top that indicates the aqua color is apples, the grey is oranges, the green is pears, etc, but the closest I've come is providing data.datasets an array of objects and making labels and array, which only results in groups of bars, like the example here.

                  推荐答案

                  这样做的方法是在数据集中创建多个项目,每个项目只有一个类别的数据.您可以拥有一个名为 stock 的顶级标签,然后为每种类型创建单独的数据集.

                  The way to do this, to create multiple items in the datasets, each having data for only one category. You can have one top level label called stock and then create the individual data-sets for each type.

                  // create a chart.
                  const ctx = canvas.getContext("2d");
                  const chart = new Chart(ctx, {
                     type: "horizontalBar",
                     data: {
                        labels: ["Stock"],
                        datasets: [{
                           label: "Apples",
                           backgroundColor: "#AF7",
                           data: [Math.random() * 100],
                        },{
                           label: "Oranges",
                           backgroundColor: "#FA4",
                           data: [Math.random() * 100],
                        },{
                           label: "Mangos",
                           backgroundColor: "#FF7",
                           data: [Math.random() * 100],
                        },{
                           label: "Avocados",
                           backgroundColor: "#2A7",
                           data: [Math.random() * 100],
                        }]
                     },
                     options: {
                            responsive: false,
                            legend: { position: 'top'},
                            title: { display: true, text: 'Fruit in stock'}
                        }
                  });

                  <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
                  <canvas id=canvas height=200 width=500></canvas>

                  这篇关于ChartJS 条形图,带有对应于每个条形图的图例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)
                  getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)
                  • <bdo id='yeh2L'></bdo><ul id='yeh2L'></ul>

                  • <legend id='yeh2L'><style id='yeh2L'><dir id='yeh2L'><q id='yeh2L'></q></dir></style></legend>
                  • <small id='yeh2L'></small><noframes id='yeh2L'>

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

                      1. <tfoot id='yeh2L'></tfoot>