简体   繁体   English

增加出口图表的高度

[英]Increase Height Of Chart On Export

Using latest highcharts (3.0.7). 使用最新的图表(3.0.7)。 We are trying to add text to the top of the chart on export. 我们正在尝试在导出图表的顶部添加文本。 to do this I need to increase the spacingTop so that we do not overwrite any chart elements. 为此,我需要增加spacingTop以便我们不会覆盖任何图表元素。 This then causes the chart to become less high by that amount of spacingTop for a the same chart height. 然后,在相同的图表高度下,通过该spacingTop数量,图表将变得不那么高。 How can I get the current chart height and add X amount to it on export? 如何获得当前图表的高度,并在导出时为其添加X值? I have tried: 我努力了:

exporting: {
    sourceWidth: 400,
    //sourceHeight: this.chartHeight,
    //sourceHeight: this.chartHeight + 200,
    scale: 1, //(default)
    chartOptions: {
        subtitle: null,
        height: this.chartHeight + 200
    }
}

This seems to be ignored. 这似乎被忽略了。 See this fiddle . 看到这个小提琴 This was just a test to see if I could do this at all. 这只是测试,看看我是否可以做到这一点。 Seems like it should be straight forward. 似乎应该是直截了当的。 If I uncomment out the sourceHeight it still does not do what I expect - the chart is still 400px high. 如果我取消注释sourceHeight它仍然无法达到我的预期-图表仍为400px高。 So it seems that this.chartHeight does not contain anything. 因此,似乎this.chartHeight不包含任何内容。

In the end this height change code is going to exist in a function we call: 最后,这个高度变化代码将存在于我们称为的函数中:

chartMainLoc.exportChart({
    type: 'image/jpeg',
    sourceHeight: this.chartHeight + 200,
    sourceWidth: this.chartWidth,
    scale: 1
}, {
    chart: {
        events: {
            load: function () {
                this.renderer.text('Occupational Employment and Wage Rates (OES) for Multiple Occupations in Louisiana in 2012<br /> The graph below shows the annual occupational employment and annual wage data for Multiple Occupations in Louisiana in 2012.<br /> ', 5, 15).attr({
                    rotation: 0
                }).css({
                    color: '#4572A7',
                    fontSize: '10px',
                    fontStyle: 'italic',
                    width: this.chartWidth
                }).add();
                this.renderer.rect(5, 5, this.chartWidth - 10, 60, 5).attr({
                    'stroke-width': 2,
                    stroke: 'black',
                    zIndex: 2
                }).add();
            }
        },
        spacingTop: 200,
        shadow: false
    }
})

Since I do not know the chart's height or width beforehand I have to get this value somehow. 由于我事先不知道图表的高度或宽度,因此必须以某种方式获取此值。

您需要像示例http://jsfiddle.net/GQUDJ/2/中那样设置带有对象( chart / series等)的图表优化

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM