<legend id='Xs2Jg'><style id='Xs2Jg'><dir id='Xs2Jg'><q id='Xs2Jg'></q></dir></style></legend>

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

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

      <bdo id='Xs2Jg'></bdo><ul id='Xs2Jg'></ul>
    <tfoot id='Xs2Jg'></tfoot>

      chart.js 图表上的叠加线

      Overlay Line on chart.js Graph(chart.js 图表上的叠加线)

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

            <tbody id='Vq14r'></tbody>

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

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

                本文介绍了chart.js 图表上的叠加线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想知道是否可以在 chart.js 图形(例如折线图)上叠加一条线?例如,在 x 轴上,一条水平线将在图上的值为 20 处绘制

                I was wondering if it was possible to overlay a line ontop of a chart.js graph, such as a line graph ? For example, on the x axis a horizontal line would be drawn at value 20 across the graph

                推荐答案

                我创建了一个名为叠加图表的东西,我已将它添加到我的chart.js 分支中(https://github.com/leighquince/Chart.js) 可以在这种情况下使用.它的工作原理与折线图或条形图相同,唯一的区别是您声明了一个名为 type 的额外属性,该属性可以是 'line''bar'.然后只需调用 new Chart(ctx).Overlay(data).

                I've created something called an overlay chart that i have added to my fork of chart.js (https://github.com/leighquince/Chart.js) that could be used in this situation. it works in the same was as a line or bar chart, only difference is you declare an extra property called type that can either be 'line' or 'bar'. Then just call new Chart(ctx).Overlay(data).

                因此,对于您的示例,您可以只使用条形图,然后提供另一个数据集(比我使用的颜色更好)来显示线条.

                So for your example you could just have your bar chart and then provided another data set (with some better colors than i have used) to show the line.

                var data = {
                  labels: ["January", "February", "March", "April", "May", "June", "July"],
                  datasets: [{
                    label: "My First dataset",
                    //new option, barline will default to bar as that what is used to create the scale
                    type: "line",
                    fillColor: "rgba(220,220,220,0.2)",
                    strokeColor: "rgba(0,0,0,0.6)",
                    pointColor: "rgba(0,0,0,0.6)",
                    pointStrokeColor: "#fff",
                    pointHighlightFill: "#fff",
                    pointHighlightStroke: "rgba(220,220,220,1)",
                    datasetFill:false,
                    data: [20, 20, 20, 20, 20, 20, 20]
                  }, {
                    label: "My First dataset",
                    //new option, barline will default to bar as that what is used to create the scale
                    type: "bar",
                    fillColor: "rgba(220,20,220,0.2)",
                    strokeColor: "rgba(220,20,220,1)",
                    pointColor: "rgba(220,20,220,1)",
                    pointStrokeColor: "#fff",
                    pointHighlightFill: "#fff",
                    pointHighlightStroke: "rgba(220,220,220,1)",
                    data: [32, 25, 33, 88, 12, 92, 33]
                  }]
                };
                var ctx = document.getElementById("canvas").getContext("2d");
                var chart = new Chart(ctx).Overlay(data, {
                  responsive: false
                });

                <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
                <script src="https://raw.githack.com/leighquince/Chart.js/master/Chart.js"></script>
                
                <canvas id="canvas" width="400"></canvas>

                这篇关于chart.js 图表上的叠加线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                在开发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 在一年的第一天返回前一年)

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

                    <tfoot id='OQnGI'></tfoot>

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