Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
342 views
in Technique[技术] by (71.8m points)

javascript - Highcharts x-axis tick starts with an offset

I am trying to remove the offset on the tick of the x-axis.

I want the first tick 10/8 to start from the x-axis and y-axis intersection.

10-8 should be on the marker which is between the two labels.

I have following code for it in highchart.

xAxis: {
            categories: categories,
            title: {
              text: title_x_axis,
              style: {
                fontWeight: 'bold'
              },
              formatter: function(){
                return "<h3><b>" + this.value + "</b></h3>";  
              }
            },
            min: 0,
            startOnTick: true,
            endOnTick: true,
            minPadding: 0,
            maxPadding: 0,
            align: "left"               
        },

Max padding and min padding are set to 0, So I don't know what the problem is?

EDIT:

I have created a fiddle of the type of chart I am dealing with. Note Image below has different x-axis values as I am not using the same value of fiddle. Also I have set tickmarkPlacement: "on" after I took that snapshot. I want Jan label to start from the beginning of line. It has some offset currently.

Highchart x-axis offset

Can anyone help me with this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You could use (assuming 'categories' is your array of categories)

 min: 0.5,
 max: categories.length-1.5,
 startOnTick: false,
 endOnTick: false,

Example: http://jsfiddle.net/27hg0v06/1/

Use newset version of highcharts to get fully working tooltip:

<script src="http://github.highcharts.com/highcharts.js"></script>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...