2

我正在尝试绘制 y 轴反转的 xy 线并且我正在绘制但mouse event我无法纠正它显示反向事件,我想自动找到轴的最小和混合如何做到这一点?以及如何将x轴置于顶部?

这是我的代码:

JS

$(function () {
var chart = new Highcharts.Chart({
    chart: {
        renderTo: 'container',
        zoomType: 'xy',
        marginLeft: 50,
        marginBottom: 90
    },

   // How to get minmax automatically zooming is a issue
   // reverse is true
    yAxis: {
        reversed: true,
        min:0,max:50
    },
    plotOptions: {
        series: {
            stacking: 'normal'
        }
    },

   series: [
           {
                   name: '01-Jan-2014',
                   data: [[30,0],[28,10]]
           }
           ]
});
});

HTML

  <script src="http://code.highcharts.com/highcharts.js"></script>
  <div id="container" style="height: 400px"></div>

这是一个JS Fiddle

是否可以在系列内传递字符串?可能是我的问题很愚蠢请告诉我是否可能,如下所示我很感兴趣

   string mystring = "{
                 name: '01-Jan-2014',
                 data: [[28, 10],[30, 0]]
               },
               {
                 name: '01-Jan-2014',
                 data: [[28, 10],[30, 0]]
               }"

在代码的系列部分中,我想做如下

                 series: [ 
                             mystring
                         ]

此数组的预期输出,按 y 轴排序好的模式 - 小提琴但鼠标移动不起作用

data:[
[ 25.290,1.000 ],
[ 25.240,2.000 ],
[ 25.210,3.000 ],
[ 25.190,4.000 ],
[ 25.180,5.000 ],
[ 25.170,6.000 ],
[ 25.160,7.000 ],
[ 25.310,8.000 ],
[ 25.210,9.000 ],
[ 25.170,10.000 ],
[ 25.160,11.000 ],
[ 25.160,12.000 ],
[ 25.150,13.000 ],
  ]

在这里,我对 xaxis 进行了排序-鼠标事件没问题,但是绘图模式(线)不是我期望的错误模式-小提琴

   data:[
[ 25.150,13.000 ],
[ 25.160,12.000 ],
[ 25.160,11.000 ],
[ 25.160,7.000 ],
[ 25.170,6.000 ],
[ 25.170,10.000 ],
[ 25.180,5.000 ],
[ 25.190,4.000 ],
[ 25.210,9.000 ],
[ 25.210,3.000 ],
[ 25.240,2.000 ],
[ 25.290,1.000 ],
[ 25.310,8.000 ],
  ]
4

1 回答 1

1

答案:

  • 您在 JS 控制台中有错误 - 修复它们(按 x 值升序对数据进行排序!)
  • 设置最小值和最大值,不要设置任何东西,Highcharts 会计算极值
  • 要在顶部显示 xAxis,请设置opposite: true

演示:http: //jsfiddle.net/2xLvY/1/

var chart = new Highcharts.Chart({
    chart: {
        renderTo: 'container',
        zoomType: 'xy',
        marginLeft: 50,
        marginBottom: 90
    },

    yAxis: {
        reversed: true,
        //min: 0,
        //max: 50
    },
    plotOptions: {
        series: {
            stacking: 'normal'
        }
    },
    xAxis: {
        opposite: true  
    },
    series: [{
        name: '01-Jan-2014',
        data: [
            // NOTE: proper order, first x-value is lower that second
            [28, 10],
            [30, 0]
        ]
    }]
});
于 2014-03-20T11:56:02.440 回答