Highstock X-Axis: Categories in Place of Time

心已入冬 提交于 2019-12-18 09:11:32

问题


Is it possible to use categories as x-values in Highstock? I don't need a time bar as x-axes, but something like numbered ratings.

This works in Highcharts, but i need the scrollbar functionality from Highstock.


回答1:


You can use highstock release, but use highcharts and scrollbar.

Take look at example:

var chart = new Highcharts.Chart({

    chart: {
        renderTo: 'container'
    },
    xAxis:{
        min:0,
        max:2,
        categories:['first','second','third','fourth']
    },
    scrollbar: {
        enabled: true
    },

    rangeSelector: {
        enabled:false
    },

    series: [{
        name: 'USD to EUR',
        data: [1,3,4,6]
    }]
});

http://jsfiddle.net/b826C/




回答2:


You may be able to get the functionality you want using Highstock and the following workaround:

The x-axis is a datetime and your series date ranges from datetime 0 to datetime x, here x is the number of categories you have.

Then when you format the xAxis label use:

labels: {
    formatter: function() {
    return categoryText[this.value];
   }
}

Similarly you can format, the text in the navigator,

categoryText is a local variable that contains the text names of your categories.

Here is the fiddle: https://jsfiddle.net/b826C/98/




回答3:


One of the developers of Highcharts/Highstock answered to my support request: It's not possible to switch the navigator to something else than time intervals.

The only solution to my problem is a navigation with a master and detail chart like in this sample: http://www.highcharts.com/demo/dynamic-master-detail



来源:https://stackoverflow.com/questions/15068028/highstock-x-axis-categories-in-place-of-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!