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

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

      <i id='dvqEl'><tr id='dvqEl'><dt id='dvqEl'><q id='dvqEl'><span id='dvqEl'><b id='dvqEl'><form id='dvqEl'><ins id='dvqEl'></ins><ul id='dvqEl'></ul><sub id='dvqEl'></sub></form><legend id='dvqEl'></legend><bdo id='dvqEl'><pre id='dvqEl'><center id='dvqEl'></center></pre></bdo></b><th id='dvqEl'></th></span></q></dt></tr></i><div id='dvqEl'><tfoot id='dvqEl'></tfoot><dl id='dvqEl'><fieldset id='dvqEl'></fieldset></dl></div>
    1. <legend id='dvqEl'><style id='dvqEl'><dir id='dvqEl'><q id='dvqEl'></q></dir></style></legend>
      <tfoot id='dvqEl'></tfoot>
    2. Chart.js xAxis 线性比例:奇怪的行为

      Chart.js xAxis linear scale : strange behavior(Chart.js xAxis 线性比例:奇怪的行为)
        <tbody id='l0vby'></tbody>
        <i id='l0vby'><tr id='l0vby'><dt id='l0vby'><q id='l0vby'><span id='l0vby'><b id='l0vby'><form id='l0vby'><ins id='l0vby'></ins><ul id='l0vby'></ul><sub id='l0vby'></sub></form><legend id='l0vby'></legend><bdo id='l0vby'><pre id='l0vby'><center id='l0vby'></center></pre></bdo></b><th id='l0vby'></th></span></q></dt></tr></i><div id='l0vby'><tfoot id='l0vby'></tfoot><dl id='l0vby'><fieldset id='l0vby'></fieldset></dl></div>

          • <small id='l0vby'></small><noframes id='l0vby'>

              <tfoot id='l0vby'></tfoot>
              • <bdo id='l0vby'></bdo><ul id='l0vby'></ul>
                <legend id='l0vby'><style id='l0vby'><dir id='l0vby'><q id='l0vby'></q></dir></style></legend>
              • 本文介绍了Chart.js xAxis 线性比例:奇怪的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试在我的 chart.js 图表中的 x 轴上使用线性刻度.我添加了一些代码,因为 stackoverflow 在添加 jsfiddle url 时必须这样做,但我不明白这一点:

                I'm trying to use linear scale on x-axis in my chart.js chart. I add some code beause stackoverflow makes it obligatory when adding a jsfiddle url, but I don't see the point :

                var options={
                    scales:{
                    xAxes:[{ type: "linear"}]
                  }
                };
                

                我得到一张非常奇怪的图表(第二张):http://jsfiddle.net/t0krmau8/

                I'm getting a very strange chart (2nd one) : http://jsfiddle.net/t0krmau8/

                在第一个图表中,我希望在 2 和 4 之间获得更多空间(比 1 和 2 之间的空间多 2 倍),这就是我使用线性刻度的原因.

                In the first chart, I'd like to get more space between 2 and 4 (2 times more space than between 1 and 2), that's why I'm using a linear scale.

                我是否使用了错误的线性刻度?还是我应该使用其他东西?

                Am I using the linear scale wrong? Or should I use something else?

                谢谢

                推荐答案

                您没有为 scatter line 图提供正确格式的数据.

                You're not providing the data in correct format for the scatter line plot.

                以下来自 Chart.js Docs 的示例描述了提供数据的正确格式.

                The correct format to provide the data is described by the following example from Chart.js Docs.

                var scatterChart = new Chart(ctx/* your canvas context*/, {
                 type: 'line',
                    data: {
                        datasets: [{
                            label: 'Scatter Dataset',
                            data: [{
                                x: -10,
                                y: 0
                            }, {
                                x: 0,
                                y: 10
                            }, {
                                x: 10,
                                y: 5
                            }]
                        }]
                    },
                    options: {
                        scales: {
                            xAxes: [{
                                type: 'linear',
                                position: 'bottom'
                            }]
                        }
                    }
                });
                

                来源

                我认为 xy 应该可以分离成不同的数组,但你总是可以做一个组合步骤,将它们组合成对象.

                I think the x and y should be separable into different arrays, but you can always do a combination step and combine them into objects.

                这篇关于Chart.js xAxis 线性比例:奇怪的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

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

                    <tbody id='IaQdy'></tbody>

                    <tfoot id='IaQdy'></tfoot>
                    • <bdo id='IaQdy'></bdo><ul id='IaQdy'></ul>
                      <legend id='IaQdy'><style id='IaQdy'><dir id='IaQdy'><q id='IaQdy'></q></dir></style></legend>
                      1. <small id='IaQdy'></small><noframes id='IaQdy'>

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