简体   繁体   English

样式高图x和y轴

[英]Style highcharts x and y axis

I am stuck on a problem and cannot find how to move further. 我遇到了问题,无法找到进一步的方法。 I am trying to style up a chart using highcharts. 我正在尝试使用highcharts设计图表。 But cannot get to show up the right percent values on the left side and style up the bottom and left lines a little so they will look like in first screen. 但无法在左侧显示正确的百分比值,并将底部和左侧线条设置为一点,以便它们看起来像在第一个屏幕中。 The same problem I have with the tick under bottom labels, they seems like they cannot be moved to top so they will overlay the bottom line on the middle. 与底部标签下的勾号相同的问题,它们似乎无法移动到顶部,因此它们将覆盖中间的底线。

This is how it must be: 这是必须的:

在此输入图像描述

This is what I've made so far: 这是我到目前为止所做的:

在此输入图像描述

Here is how my code looks: http://jsfiddle.net/8Wp7k/ 以下是我的代码的外观: http//jsfiddle.net/8Wp7k/

And highcharts settings: 和highcharts设置:

$j('.investor-calculator .chart-container .chart').highcharts({
    title: {
        text: '',
        x: -20 /*center*/
    },
    background: {
        linearGradient: {
            x1: 0,
            y1: 0,
            x2: 0,
            y2: 1
        },
        stops: [
            [0, 'rgb(96, 96, 96)'],
            [1, 'rgb(16, 16, 16)']
        ]
    },
    subtitle: {
        text: '',
        x: -20
    },
    xAxis: {
        categories: ['Янв', 'Мар', 'Май', 'Июл', 'Сен', 'Ноя'],
        tickmarkPlacement: 'on',
        tickColor: '#d2d2d2',
        gridLineColor: '#eee',
        tick: false
    },
    yAxis: {
        title: null,
        tickPosition: 'inside',
        gridLineDashStyle: 'longdash',
        lineColor: '#d2d2d2',
        lineWidth: 1
    },
    tooltip: {
        valueSuffix: null
    },
    series: [{
        name: 'Some Name',
        data: [1.0, 6.9, 2.5, 8.5, 1.0, 12.5]
    }],
    legend: {
        enabled: false
    },
    exporting: {
        enabled: false
    },
    credits: {
        enabled: false
    },
    colors: ['#e0502f'],
    plotOptions: {
        series: {
            lineWidth: 4,
            marker: {
                enabled: false
            }
        }
    }
});

For the Y Axis labels, you need to use : 对于Y轴标签, 您需要使用

        labels: {
            format: '{value} %'
        },
        tickInterval: 5

Fiddle 小提琴

For the tick position, you're limited to 'inside' or 'outside, per the documentation , they cannot straddle the x-axis. 对于刻度位置,您仅限于“内部”或“外部”, 根据文档 ,它们不能跨越x轴。

As for the Axes crossover, Steve P has the answer to this 至于Axes交叉,史蒂夫P有这个答案

To move your x-axis labels, add something like this to the x-axis: 要移动x轴标签,请在x轴上添加以下内容:

 labels:{
        y:25
 }

For the y-axis, you can force the tick interval to be every 5%, and format the labels like this: 对于y轴,您可以强制每5%的刻度间隔,并格式化标签,如下所示:

    tickInterval: 5,
    labels: {
        format: '{value} %'
    }

http://jsfiddle.net/Kd5k7/ http://jsfiddle.net/Kd5k7/

A few more tweaks: 还有一些调整:

You can move the axis positions using offset eg: 您可以使用偏移移动轴位置,例如:

 yAxis: {
        min:-4,
        startOnTick:false,
        offset:-20

The min and startOnTick forces the y-axis to start at -4, but won't print a label, as the min is not a multiple if 5. min和startOnTick强制y轴从-4开始,但不会打印标签,因为min不是5的倍数。

http://jsfiddle.net/P9M3t/ http://jsfiddle.net/P9M3t/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM