【问题标题】:Highchart circle position by jqueryjQuery的Highchart圆圈位置
【发布时间】:2015-10-05 08:51:22
【问题描述】:
function(chart) { // on complete
    var xpos = '50%';
    var ypos = '53%';
    var circleradius = 102;

    // Render the circle
    chart.renderer.circle(xpos, ypos, circleradius).attr({
        fill: '#7EBA00',
    }).add();
}); 

//position updating based on window size
$(window).on('load resize', function() {
    var wd = $(window).width();
    if (wd < 361) {
        //alert(wd);
        chart.renderer.circle().cx = '60%';
    } 
}); 

如何使用 jQuery 将 xy 位置值添加到在 highchart SVG 中创建的圆圈?

【问题讨论】:

    标签: jquery svg highcharts


    【解决方案1】:

    您需要将渲染对象保存在一个变量中,然后(在调整大小事件中)引用它,调用 attr()。

    示例:http://jsfiddle.net/2aap3285/

    $(window).on('load resize', function () {
        var wd = $(window).width();
        if (wd < 361) {
            circle.attr({
                cx: 100
            });
        }
    });
    

    cx 参数应定义为数字而不是百分比。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-01
      • 1970-01-01
      • 2017-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多