0

我已经创建了这个 highchart,但我需要 renderer.text 与父 highchart 一起缩放。例如。在第二个图表中,我更改了最大和最小宽度,以便图表在最小值和最大值内缩放,但 render.text 保持静态。每当用户更改宽度时,我想让第二个小提琴看起来像第一个小提琴。谢谢您的帮助。

http://jsfiddle.net/jimbob25/V446C/

http://jsfiddle.net/jimbob25/V446C/1/

renderer.path(['M', 485, 40, 'L', 505, 40, 505,300, 485, 300])
    .attr({
        'stroke-width': 1,
        stroke: 'red',
        zIndex: 3
    })
    .add();

renderer.text('+/-2%', 435,93)
    .attr({
        zIndex: 3
    })
    .css({
        color: '#000000',
        fontSize: '12px'
    })
    .add();
4

2 回答 2

1

在第二个小提琴中,您已经设置了,height:400px; width:530px;因此您已经修复了值并且图表不会缩放,因此您应该设置min-width并且min-height您也可以设置max-widthand max-height
这是小提琴

于 2014-01-15T13:10:04.807 回答
0

Osyan 感谢您的帮助,但我的意思是渲染器文本不随图像缩放。我最终将渲染器绘制为 530px 宽度,然后每当 hgihchart 调整大小时,我都会获得偏移量并使用该偏移量重绘图像

redraw: function() {
                    var offset = 530 - chart.chartWidth;
                    initDrawing(chart,offset);
                }

接着

function initDrawing(chart,offset){
      $("#alert1").remove();
      $("#greenArrow1").remove();
         //Clear all of the old elements by id because we will redraw new ones.

    // subtract the offset and add to chart
    renderer.text('+/-2%', 435-offset, 40)
        .attr({
            id: 'alert1'
    })
        .css({
        color: '#000000',
        fontSize: '12px'
    })
        .add();
于 2014-01-15T13:36:51.440 回答