English 中文(简体)
Highcharts - show every other x-axis category
原标题:

I have Highcharts set up to display a graph with a bunch of xAxis categories. This is all working fine, but I would like to be able to skip some of the xAxis categories, so not everything one is shown. You can see an example of this working within Campaign Monitor s reporting section (screenshot: http://screencast.com/t/Y2FjNzQ4Y).

Any idea how I can achieve this same layout?

最佳回答

You can set the xAxis type as datetime then set the pointInterval and PointStart in the plotoptions.

Code example:

var chart;
$(document).ready(function () {
    chart = new Highcharts.Chart({
        "xAxis": {
            "type": "datetime"

        "plotOptions": {
            "line": {
                "pointInterval": 86400000,
                "pointStart": 1282408923000
            }
        },
    });
});

The figures you see for pointInterval and Start are in millisecionds which you can generate using getTime() The interval in your case would be 86400000ms which is one day. The library displays appropriate intervals based on your data interval.

问题回答

It seems like the xAxis:labels:step value is what should be used to accomplish this:

        xAxis: {
            categories: [ JAN ,  FEB ,  MAR ,  APR ,  MAY ],
            labels:{
                step: 2 // this will show every second label
            }
        },

Step Axis Labels

Super late, but I figure this can help someone out.

    xAxis: {
        categories: categoriesname,
        labels: {
            style: {
                color:  #000 ,
                font:  9px Trebuchet MS, Verdana, sans-serif 
            }
        },
        **tickInterval: TickInterval,**// SET THIS
        tickPixelInterval: 80,
        tickmarkPlacement:  on 
    },

here is my ugly solution :)

I m using array as queue. http://javascript.about.com/library/blqueue.htm if you fill point datas to the queue, you can to set datas for your chart series.

var myQueue = new Array();
var myPoint = [x, y];                                       myQueue.push(myPoint);
chart.series[0].setData(myQueue);

my X axis is not a datetime, it s an integer
first 
var x = 0;

x value should be always increment when you need a new point. http://dl.dropbox.com/u/3482121/picture/highcharts/PM/Screenshot.png





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签