【问题标题】:Highcharts renderer x and y different on Firefox vs ChromeFirefox 和 Chrome 上的 Highcharts 渲染器 x 和 y 不同
【发布时间】:2014-01-14 18:49:34
【问题描述】:

我有一个带有通过chart.renderer 添加的矩形的图形,它在 Firefox 中看起来完全符合我的要求,但是当我在 Chrome 或 IE 中查看它时,坐标已关闭。我有minmax 设置,我试过setInterval,但无济于事。这是我的代码:

$('#ao_vs_ppv').highcharts({
  chart: {
    renderTo: 'ao_vs_ppv',
    type: 'scatter',
    height:600,
    width:600
  },
  title: {
    text: 'Air Overpressure Vs. Peak Particle Velocity'
  },
  xAxis: {
    min: .01,
    max: 10,
    type: 'logarithmic',
    minorTickInterval:0.1,
    title: {
        text: "Peak Particle Velocity (in/sec)"
    },
    labels: {
        overflow: 'justify'
    },
    tickmarkPlacement: 'on',
    gridLineWidth: 1,
    plotBands: [{
        color: '#F7FE2E',
        from: .4,
        to: 10
    },{
        color: '#F7FE2E',
        from: 1,
        to: 10
    }]
  },
  yAxis: {
    min: 90,
    max: 150,
    title: {
        text: 'Air Overpressure (dBL)'
    },
    tickInterval:10,
    labels: {
        overflow: 'justify'                         
    },
    plotBands: [{ 
        color: '#F7FE2E',
        from: 120,
        to: 150
    }]
  },
  plotOptions: {
    scatter: {
        tooltip: {
            headerFormat: '<b>{series.name}</b><br>',
            pointFormat: 'AO: {point.y}dBL<br>PPV: {point.x}in/sec'
        }
    }
  },
  legend: {
    layout: 'horizontal',
    borderWidth: 1,
    backgroundColor: '#FFFFFF',
    shadow: true
  },
  series:formatHighChartsScatter(data[i]['x_data'],data[i]['y_data'], seismoNames)
}, function(chart) { // on complete
  chart.renderer.rect(348, 50, 242, 217, 0)
    .attr({
        fill: 'red'
    })
    .add();
});

这是它在 Firefox 中的样子:http://i.imgur.com/8OQfRCR.png

这是它在 Chrome 中的样子:http://i.imgur.com/NpKjwu3.png

【问题讨论】:

  • ctrl + 0 被按下了吗?
  • @Rooster 不,它没有被按下。
  • 同时按下它以清除缩放

标签: javascript jquery google-chrome firefox highcharts


【解决方案1】:

我相信我已经找到了解决方案。它与图表偏移量chart.plotLeft 和chart.plotTop 有关。我稍后会发布我的完整解决方案。

这是我的工作代码:

$('#ao_vs_ppv').highcharts({
                            chart: {
                                    renderTo: 'ao_vs_ppv',
                                    type: 'scatter',
                                    height:600,
                                    width:600
                            },
                            title: {
                                    text: 'Air Overpressure Vs. Peak Particle Velocity'
                            },
                            xAxis: {
                                    min: .01,
                                    max: 10,
                                    type: 'logarithmic',
                                    minorTickInterval:0.1,
                                    title: {
                                            text: "Peak Particle Velocity (in/sec)"
                                    },
                                    labels: {
                                            overflow: 'justify'                 
                                    },
                                    gridLineWidth: 1,
                                     plotBands: [{ 
                                        color: '#F7FE2E',
                                        from: .4,
                                        to: 10
                                    },{ 
                                        color: '#F7FE2E',
                                        from: 1,
                                        to: 10
                                    }]
                            },
                            yAxis: {
                                    min: 90,
                                    max: 150,
                                    title: {
                                            text: 'Air Overpressure (dBL)'
                                    },
                                    tickInterval:10,
                                    labels: {
                                            overflow: 'justify'                         
                                    },
                                     plotBands: [{ 
                                        color: '#F7FE2E',
                                        from: 120,
                                        to: 150
                                    }]
                            },
                            plotOptions: {
                                    scatter: {

                                            tooltip: {
                                                    headerFormat: '<b>{series.name}</b><br>',
                                                    pointFormat: 'AO: {point.y}dBL<br>PPV: {point.x}in/sec'
                                            }
                                    }
                            },
                            legend: {
                                    layout: 'horizontal',
                                    borderWidth: 1,
                                    backgroundColor: '#FFFFFF',
                                    shadow: true
                            },
                            series:formatHighChartsScatter(data[i]['x_data'],data[i]['y_data'], seismoNames)

                    }, function(chart) 
                            { // on complete    

                                //calculate corrdinates and dimensions based on offsets
                                var x=279+chart.plotLeft;
                                var y=chart.plotTop;
                                var width=chart.plotWidth*.467;
                                var height=chart.plotHeight*.502;
                                chart.renderer.rect(x, y, width, height, 0)
                                .attr({
                                    fill: 'red'
                                })
                                .add();  
                    });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-21
    • 2019-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-11
    • 2014-12-16
    • 1970-01-01
    相关资源
    最近更新 更多