Highstock: set xAxis as not “datetime”

可紊 提交于 2019-12-11 04:29:48

问题


I am trying to populate a highchart with some dynamic data in my angularjs application. I am using the "highcharts-ng" directive for working the the highcharts.

https://github.com/pablojim/highcharts-ng

The data is typically of the following format:

x-axis (categories):

 [0, 0.0001001001001, 0.0002002002002, 0.0003003003003,
   0.0004004004004, 0.000500500500501, 0.000600600600601]

y-axis:

{
 name: value1, 
 data: [
     0, 2.27112321592e-7, 8.69358451877e-7, 
     0.00000192654087985, 0.00000339761308545, 
     0.0000052811192715, 0.00000757519580291
]}

The categories can contain thousands of values, and for each value in "x-axis category", there is a corresponding y-axis value

I have set the "x-axis" categories dynamically using the following code: chart.xAxis[0].setCategories(categories);

Some other relevant properties that I have set are:

$scope.chartConfig = {
    chart: {
        type:'spline'
    }
    options: {
        plotOptions: {
            series: {
                turboThreshold: 51000,
            }
        }
    },
    xAxis: {
        type: 'category', (I tried with 'linear' as well)
        allowDecimals: true,
        min: 0,
    },
    useHighStocks: true
};

However, I am still seeing that "x-axis" is showing the values as "datetime". Is there any way in which I can make the x-axis value a simple "decimal values" and not as datetime?

Also, since the x-axis values are decimal values, is it possible to display the corresponding scientific notation instead (i.e. instead of showing 0.0003003003003, can we show 3.003e-04)?

Thanks in advance for your help.

Regards, Kapil


回答1:


In Highstock only datetime axis type exists. In Highcharts you have linear/datetime/logarithmic and categorized types.

References:

  • Highcharts xAxis // type property
  • Highstock xAxis // last element in docs


来源:https://stackoverflow.com/questions/20532540/highstock-set-xaxis-as-not-datetime

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