highcharts - 如何增加 highcharts 中特定 x 刻度的刻度长度

标签 highcharts

___________________________xAxis
| 10 ' 20 ' 30 | 40 ' 50 ' 60 | 70

如上所示,我想将 x 轴开始处的刻度长度增加为 10 ,40 和 70。

我找到了 Xaxis 的 tickLength 属性,它可以有一个数值,但它会更新沿轴的所有刻度的长度。

有办法实现我的目标吗?

最佳答案

您可以添加额外的 x 轴,该 x 轴将链接到主轴,并且将具有更长的选定刻度。在下面的示例中,使用tickPositions放置价格变动,但如果需要首先计算较长价格变动的位置,则可以使用tickPositioner。

JSFiddle:http://jsfiddle.net/qL550pmh/1/

/* Expect to increse the tick length infront of 2013, 2014 & 2015 */

//  |2013 |   |   |    | 2014 |    |    |    |2015
//  |                  |                     |

$(function () {

    var currentYear = '';
    var isMonthCombined = false;

    $('#container').highcharts({
        credits: {
            enabled: false
        },
        chart: {
            type: 'spline',
            style: {
                fontFamily: '"Open Sans", "Helvetica Neue", Helvetica, Arial',
                fontSize: 14
            },
            marginLeft: 78
        },
        title: {
            text: null
        },
        legend: {
            x: 40
        },
        xAxis: [{
            linkedTo: 1,
            categories: [],
            tickLength: 25,
            labels: {
                format: ' '
            },
            tickPositions: [3, 7]
        }, {
            gridLineColor: '#e0e0e0',
            gridLineWidth: 1,
            lineColor: '#e0e0e0',
            tickColor: '#e0e0e0',
            categories: ["Jan 2013 - Mar 2013",
                "Apr 2013 - Jun 2013",
                "Jul 2013 - Sep 2013",
                "Oct 2013 - Dec 2013",
                "Jan 2014 - Mar 2014",
                "Apr 2014 - Jun 2014",
                "Jul 2014 - Sep 2014",
                "Oct 2014 - Dec 2014",
                "Jan 2015"],
            labels: {
                formatter: function () {

                    var year = this.value.slice(-4);
                    if (currentYear != year) {
                        currentYear = year;
                        return currentYear;
                    }
                    return '';
                }
            }
        }],
        yAxis: {
            gridLineColor: '#e0e0e0',
            gridLineWidth: 1,
            lineColor: '#e0e0e0',
            title: {
                text: 'Views'
            },
            min: 0
        },
        plotOptions: {
            series: {
                allowPointSelect: true
            }
        },
        series: [{
            xAxis: 1,
            name: 'Views and Downloads',
            lineWidth: 6,
            color: '#f29400',
            marker: {
                symbol: 'circle',
                fillColor: '#FFFFFF',
                radius: 7,
                lineWidth: 5,
                lineColor: null
            },
            data: [21410,
            9413,
            3982,
            1000,
            0,
            5,
            176,
            104,
            3]
        }]
    });
});

关于highcharts - 如何增加 highcharts 中特定 x 刻度的刻度长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27841673/

相关文章:

javascript - 添加 html 按钮并选择到 Highcharts

javascript - 格式 "data"和 "name"highchart mvc asp.net

javascript - Highmaps/Highcharts setData 不变

javascript - highcharts 动态类别不起作用

javascript - Highcharts:在向下钻取之前获取一个事件?

php - HighCharts 圆环图向下钻取

javascript - 可视化库建议

highcharts - 在 highchart.stock 中启用禁用悬停

javascript - Highcharts - 如何在工具提示中显示图例符号

javascript - 设置类别名称后,Highchart 会勾选起点变化