【问题标题】:c3 chart not displaying changes on axisc3图表不显示轴上的变化
【发布时间】:2018-05-07 18:34:01
【问题描述】:

我正在尝试在 x 和 y 轴上显示带有所需选项的以下图表,但轴上的更改不起作用。图表正在显示,但是 Y 轴没有 min、max 属性,位置不是我通过的... 有什么问题?

<div id="chart2"></div>
            <script>
                var chart = c3.generate({
                    bindto: '#chart2',
                    data: {
                        url: "../static/CSV/Chart_data/grades_access.csv",
                        x:'AC_GRADE',
                        type: 'scatter'
                    },
                    axis: {
                        y: {
                            label: "Average grade",
                            position: "outer-middle",
                            padding: {top: 200, bottom: 0},
                            min:0,
                            max:10
                        },
                        x: {
                            label: "Access grade",
                            position: "outer-center",
                            padding: {top: 200, bottom: 0},
                            min:0,
                            max:10
                        }
                    },
                    size: {
                        height: 400,
                        width: 800
                    },
                    zoom: {
                        enabled: true
                    }     
                }); 
            </script>

【问题讨论】:

    标签: javascript html d3.js c3.js


    【解决方案1】:

    嗯,其实很多错误定义的参数。
    1.标签位置应该这样定义

    axis: {
      x: {
       label: {
        text: 'Your X Axis',
        position: 'outer-center'
       } 
     }
    }
    

    2. 填充会影响最小值和最大值,因此如果需要,应将其设置为 0
    3. 填充 x 轴应使用leftright 属性。
    也许还有别的,只需彻底检查http://c3js.org/reference.html

    【讨论】:

      猜你喜欢
      • 2020-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多