0

I would have said that defining the STEP parameter for the xAxis would be rather straightforward. But there are weird things happening with my graphs. One thing is that although I am assigning a STEP value of 1, it only displays every fifth year. If I increase the value to 2, it displays every tenth year.

This is the setting (with a fiddle here):

    "xAxis": {
        "labels": {
            "step": 1
        },
        "tickWidth": 0,
        "showFirstLabel": true,
        "showLastLabel": true
    },

Thanks for any help on this!

luftikus143
  • 1,285
  • 3
  • 27
  • 52
  • Setting step value to two means one label is ignored before showing another label. It doesn't set the ticks to show. What do you exactly want to show in labels? – Raein Hashemi Feb 25 '15 at 10:34
  • http://api.highcharts.com/highcharts#xAxis.labels.step – Raein Hashemi Feb 25 '15 at 10:35
  • I would have thought that if I use a STEP-label of "1", every xAxis-value is being displayed as a label. If I set it to "2", only every second value is being displayed, etc. In my case however, a STEP-label of "1" displays only every fifth value. Why is that? I'd like to have it as I understand it should work. I am having problems with a line chart where 1 equals every tenth year, and the same graph as a column chart, where 1 equals every year. – luftikus143 Feb 25 '15 at 10:54
  • Default of step is 1, so actually the labels are showing the normal way without using step. As I understood from your sentence, you want every year as one label. Is that correct? – Raein Hashemi Feb 25 '15 at 11:01

1 Answers1

2

You don't need step. Step is to show only every n'th label on the axis. You need tickInterval for setting the interval of labels. Also you will need rotation because labels are too close to each other:

"xAxis": {
        "labels": {
            "step": 1,
            rotation: -45,
        },
        "tickWidth": 0,
        tickInterval: 1,            
        "showFirstLabel": true,
        "showLastLabel": true
    }

Here's the DEMO

Raein Hashemi
  • 3,346
  • 4
  • 22
  • 33
  • Ah, hmm... It's tickInterval then. That's a bit confusing. But I see now. Thanks a lot! – luftikus143 Feb 25 '15 at 11:13
  • No problem, and yes it is. That's why you should search the net or use the API before using it. – Raein Hashemi Feb 25 '15 at 11:15
  • Did search quite a bite around. But I am not sure if the commands are really logical, which makes it difficult to find the right ones: A tickInterval is in my opinion only the interval for the ticks. In my case, I don't display any ticks. So, my logic would be: I don't need tickInterval, when tickWidth is 0. However, the label->step is what I need, as I want to display only every Xth label. Has nothing to do with ticks. Hmmm... – luftikus143 Feb 27 '15 at 07:40