谷歌图表将缩放的图像保存为PNG
Google charts save zoomed image as PNG
我正在使用Google图表来创建折线图,并且正在使用
explorer: {actions: ['dragToZoom', 'rightClickToReset']
以允许用户放大边界框。我希望能够将缩放的图像另存为 PNG。为此,我尝试在图表的左边缘和右边缘找到 HAxis 值,在图表的顶部和底部边缘找到 VAxis 值:
var cli = chart.getChartLayoutInterface();
var hl = cli.getHAxisValue(cli.getChartAreaBoundingBox().left);
var hr = cli.getHAxisValue(cli.getChartAreaBoundingBox().left + cli.getChartAreaBoundingBox().width);
var vt = cli.getVAxisValue(cli.getChartAreaBoundingBox().top);
var vb = ??
然后,我在我的选项中使用这些来使用这些限制来重新填充图表:
var options = {
width: 1430,
height: 563,
hAxis: {
title: 'X-Axis',
viewWindow: { min: hl, max: hr}
},
explorer: {actions: ['dragToZoom', 'rightClickToReset'], keepInBounds: true, maxZoomIn: .01 },
curveType: "function",
vAxis: {
logScale: log1,
title: "Y-Axis",
titleTextStyle: {color: '#0000FF'},
textStyle: {color: '#0000FF'},
baselineColor: '#0000FF',
viewWindow: { min: vb, max: vt}}
},
title: "Figure 1"
};
var chart = new google.visualization.LineChart(document.getElementById('plot'));
chart.draw(data, options);
drawpng = chart.getImageURI();
return drawpng;
我的左边缘、右边缘和上边缘的值工作正常,但我无法弄清楚如何确定底部边缘。我已经试过了
var vb = cli.getVAxisValue(cli.getChartAreaBoundingBox().top - cli.getChartAreaBoundingBox().height)
和
var vb = cli.getVAxisValue(cli.getChartAreaBoundingBox().height)
和
var vb = cli.getVAxisValue(cli.getChartAreaBoundingBox().height - cli.getChartAreaBoundingBox().top)
但这些都没有给我正确的价值。
有谁知道如何完成这项工作,或者保存放大图表的另一种方法?谢谢!
我让它使用
cli.getVAxisValue(cli.getChartAreaBoundingBox().top+cli.getChartAreaBoundingBox().height)
我没有意识到这个位置是从顶部计算的,而不是从底部计算的。
相关文章:
- 如何将乳胶配方奶粉图像保存到Asp.net中的文件夹中
- 将多个重叠的透明图像保存为一个图像
- 将图像保存到安卓系统中的SD卡
- 将图像保存到硬盘驱动器
- 在将图像保存到服务器之前检查图像大小
- 使用Cordova contacts插件将图像保存到用户的联系人中
- 如何使用纯javascript或jQuery将HTML5画布屏幕作为png图像保存到项目的特定文件夹中
- 是否可以调用Google API获取地图图像并将图像保存在某个位置
- 将图像保存到用户的pc缓存中,并使用asp.net从缓存中使用它
- 谷歌图表将缩放的图像保存为PNG
- 将上传的图像保存在本地位置
- 如何将图像保存为基数 64
- 将上传的图像保存到本地存储(chrome 扩展程序)
- 无法将完整画布图像保存到服务器
- 如何将画布图像保存在磁盘中
- React Native 将 http 图像保存到 Android 相机胶卷
- 使用Phonegap将图像保存到Iphone照片库
- 将图像保存到Webkit和Gecko中的blob
- Javascript和FF-addon:如何在不重新下载的情况下将图像保存到本地磁盘
- 将本地计算机上的相机捕获的图像保存在文件夹中