我正在尝试让一个Python CGI脚本显示一个带有线性趋势线的谷歌ScatterChart,我可以在其他地方使用它的方程。ScatterChart趋势线选项绘制一条趋势线,我可以通过将指针放在趋势线上找到该趋势线的方程式,但这没有帮助,因为我需要通过编程从方程式中获取系数。
我能想到的一种解决方案是编写一个函数来计算趋势线并将其显示在ScatterChart的顶部。这里的问题是,我不知道如何制作一个Google图表,让它有两个不同的数据系列(一个系列是点,另一个是线)。
一种混合的解决方案是使用我的函数来计算趋势线,这样我的程序中就有了方程,然后用它自己的Google生成的趋势线显示图表。这里的问题是,我知道有不止一种方法可以绘制线性趋势线,但我不知道谷歌使用哪种方法。
发布于 2013-09-13 02:50:01
使用series..lineWidth选项使用连接线绘制一个系列:
series: {
0: {
// scatter series
lineWidth: 0
},
1: {
// trendline
lineWidth: 1,
// control the point size of the trendline
pointSize: 0,
// set this if you don't want the points on the trendline to spawn tooltips
enableInteractivity: false,
// set this to remove the trendline from the legend
visibleInLegend: false
}
}https://stackoverflow.com/questions/18765794
复制相似问题