我试图让Python CGI脚本显示一个带有线性趋势线的Google ScatterChart,我可以在其他地方使用它。 ScatterChart trendline选项绘制了一条趋势线,我可以通过将我的指针放在趋势线上来找出该线的等式,但这没有任何帮助,因为我需要以编程方式从等式中获得系数。
我能想到的一个解决方案是编写一个计算趋势线的函数,并将其显示在ScatterChart之上。这里的问题是我不知道如何制作一个有两个不同系列数据的谷歌图表(一个系列为点,另一个系列为一行)。
混合解决方案是使用我的函数来计算趋势线,以便在程序中得到公式,然后使用自己的Google生成的趋势线显示图表。这里的问题是,我知道制作线性趋势线的方法不止一种,我不知道Google使用哪种方式。
答案 0 :(得分:0)
使用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
}
}