javascript - Highcharts 渲染器 x 和 y 在 Firefox 与 Chrome 上不同

标签 javascript jquery google-chrome firefox highcharts

我有一个图表,其中通过 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 中的样子:/image/TB98C.png

这是 Chrome 中的样子:/image/X0QPz.png

最佳答案

我相信我已经找到了解决方案。它与图表偏移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();  
                    });

关于javascript - Highcharts 渲染器 x 和 y 在 Firefox 与 Chrome 上不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21121541/

相关文章:

javascript - 在javascript中读取JSON数据

javascript - 跨源请求被阻止 Microsoft Azure Function

google-chrome - 运行 gui 测试时在 Chrome 中禁用保存密码提示

jQuery done() 似乎在发送请求之前触发

javascript - 如何用 'null' 字符串替换 javaScript 对象中的所有空值?

javascript - 仅在页面加载时调试 Jquery

google-chrome - Chrome Webdriver 在 Selenium 中产生超时

javascript - 如何找到 child 的最后一个 child ?

javascript - 克隆一个 div 并在 div 中获取特定 id 的值

javascript - jQuery 单选按钮检查添加类,否则如果单选按钮未选中则删除类?