• <tfoot id='EN6Am'></tfoot>

    • <bdo id='EN6Am'></bdo><ul id='EN6Am'></ul>
  • <small id='EN6Am'></small><noframes id='EN6Am'>

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

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

        如何在 Chart.js 中为条形图和折线图添加第二个 Y 轴?

        How to add second Y-axis for Bar and Line chart in Chart.js?(如何在 Chart.js 中为条形图和折线图添加第二个 Y 轴?)
            <tbody id='Sdu1T'></tbody>
          <tfoot id='Sdu1T'></tfoot>
            <legend id='Sdu1T'><style id='Sdu1T'><dir id='Sdu1T'><q id='Sdu1T'></q></dir></style></legend>

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

            • <bdo id='Sdu1T'></bdo><ul id='Sdu1T'></ul>

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

                1. 本文介绍了如何在 Chart.js 中为条形图和折线图添加第二个 Y 轴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试在 Chart.js 中添加双 Y 轴以进行两个数据集比较.我目前正在使用 Leigh Quince 的 LineBar 扩展,这是在这里找到的答案:

                  您可以在此处获取修改后的 Chart.js 文件 >> https://github.com/khertan/Chart.js/tree/9edcc71f97361bb45c8fe93d07acb1917c2b4807

                  您只需将选项添加到您的 options 变量中:

                  var 选项 = {...scaleUse2Y:真,...};

                  然后实例化一个普通的折线图:

                  var chart = new Chart(ctx).Line(data, options);

                  问题是,如果您使用像 StackedBar 这样的扩展,例如,它可能会损坏......这一定是它尚未与 Chart.js 的 master 分支合并的原因.耐心等待2.0版本发布.

                  I am trying to add a double Y-axis in Chart.js for two dataset comparisons. I'm currently using Leigh Quince's LineBar extension which was the answer found here: Chart.js how to get Combined Bar and line charts?

                  There is also a solution written about a year ago for double Y-axis but only for a Line charts, and its way out of sync with Nick's master. Seems there's either Line and Bar charts, or Double-Y but not both.

                  My issue here is that I need to represent TSAT % (Saturation levels), left Y-axis, Line Chart, to the amount of Ferritin dosage levels, right Y-axis Bar Chart. Here's what I need it to look like:

                  (Seems Stackoverflow has changed the color of it on me, hope you can still read the Y-Axis scales)

                  If someone can comp up with a solution I would be greatly appreciative.

                  Current code:

                              var data = {
                                  labels: ["Jun 2013", "Jul 2013","Aug 2013","Sep 2013","Oct 2013","Nov 2013","Dec 2013", "Jan 2014", "Feb 2014", "Mar 2014", "Apr 2014", "May 2014"],
                                  datasets: [
                  
                                      {
                                          label: "TSAT",
                                          type: "line",
                                          fillColor: "transparent",
                                          strokeColor: "#a33a59",
                                          pointColor: "#a33a59",
                                          pointHighlightStroke: "#FFF",
                                          data:[33,32.9,32.9,33.2,33.2,33.2,32.7,32.9,32.9,32.7,32.7,32.7]
                                      },                  
                                      {
                                          label: "Ferritin",
                                          type: "bar",
                                          fillColor: "#ed7141",
                                          strokeColor: "#ed7141",
                                          data: [939,929,949,991,992,993,976,976,973,986,972,939]
                                      }
                                  ]
                              };
                  
                              var options = {
                                  responsive: true,
                                  scaleOverride: true,
                                  scaleSteps: 10,
                                  scaleStepWidth: 5,
                                  scaleStartValue: 0,
                                  showTooltips: false,
                                  pointDot: true,
                                  pointDotRadius : 10,
                                  datasetStrokeWidth : 3,
                                  bezierCurve : false,
                                  scaleShowLines: false,
                                  scaleGridLineWidth : 2,
                                  scaleGridLineColor : "#EEEEEE",
                                  scaleLineWidth: 3,
                                  scaleLineColor: "#000000",
                                  scaleFontFamily: 'Gotham Book,sans-serif',
                                  scaleFontSize: 18,
                              }
                  
                              ctx = $("#myChart").get(0).getContext("2d");
                              TSATChart = new Chart(ctx).LineBar(data, options);      
                  

                  BTW... I modified Quince's LineBar to render Bar first then lines. The code originally had it reversed. As such, I may not be able to add something to jsfiddle, I will edit and add a link if I'm successful with adding an example there.

                  Thank you!

                  解决方案

                  To show a Line Chart with two Y axis, @khertan made a pull request to add this feature >> https://github.com/nnnick/Chart.js/pull/1355

                  You can grab the modified Chart.js file here >> https://github.com/khertan/Chart.js/tree/9edcc71f97361bb45c8fe93d07acb1917c2b4807

                  You'll only need to add the option to your options variable:

                  var options = {
                      ...
                      scaleUse2Y: true,
                      ...
                  };
                  

                  And then instantiate a normal Line chart:

                  var chart = new Chart(ctx).Line(data, options);
                  

                  Problem is that if you're using an extension like StackedBar, for example, it will probably break... That must be the reason why it hasn't been merged with master's branch of Chart.js yet. Patience for the 2.0 version release.

                  这篇关于如何在 Chart.js 中为条形图和折线图添加第二个 Y 轴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  append() 方法在被选元素的结尾(仍然在内部)插入指定内容。 语法: $(selector).append( content ) var creatPrintList = function(data){ var innerHtml = ""; for(var i =0;i data.length;i++){ innerHtml +="li class='contentLi'"; innerHtml +="a href
                  问题描述: 在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中的序数)

                        <tbody id='V7aG5'></tbody>

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

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