在电子表格中创建动态图表并选择“发布”后,我得到以下代码,粘贴到我服务器上的HTML页面中会生成一个工作图表(我删除了我的电子表格网址):
<script type="text/javascript" src="//ajax.googleapis.com/ajax/static/modules/gviz/1.0/chart.js"> {"dataSourceUrl":"//docs.google.com/spreadsheet/tq?key=[mysheet]&transpose=0&headers=1&range=A1%3AC57&gid=0&pub=1","options":{"showChartButtons":true,"vAxes":[{"title":"Left vertical axis title","useFormatFromData":true,"minValue":null,"viewWindow":{"min":null,"max":null},"maxValue":null},{"useFormatFromData":true,"minValue":null,"viewWindow":{"min":null,"max":null},"maxValue":null}],"titleTextStyle":{"fontSize":16},"title":"Chart title","booleanRole":"certainty","height":643,"animation":{"duration":500},"width":1468,"showSidePanel":true,"hAxis":{"title":"Horizontal axis title","useFormatFromData":true,"minValue":null,"viewWindow":{"min":null,"max":null},"maxValue":null}},"state":{},"view":{},"isDefaultVisualization":true,"chartType":"MotionChart","chartName":"Chart 1"} </script>
然而,图表不会保持我在图表显示中所做的任何状态更改:颜色,大小,林/日志等。
我可以通过高级对话框获取当前状态设置字符串:
{"yLambda":0,"xZoomedDataMax":381835,"colorOption":"_UNIQUE_COLOR","xZoomedIn":false,"showTrails":false,"yZoomedIn":false,"playDuration":15000,"nonSelectedAlpha":0.4,"xLambda":0,"yAxisOption":"2","yZoomedDataMax":381835,"yZoomedDataMin":6213,"iconType":"BUBBLE","time":"2000","orderedByX":false,"iconKeySettings":[{"key":{"dim0":"Metric1"}},{"key":{"dim0":"Metric2"}},{"key":{"dim0":"Metric3"}},{"key":{"dim0":"Metric4"}}],"dimensions":{"iconDimensions":["dim0"]},"orderedByY":false,"duration":{"multiplier":1,"timeUnit":"Y"},"sizeOption":"2","uniColorForNonSelected":false,"xAxisOption":"2","xZoomedDataMin":6213}
但是将它们放在我的HTML文件中的“state”:{}参数中没有任何效果。我已经尝试将状态字符串放在其他各个位置,再次没有效果。我在哪里放置状态字符串以显示我想要的初始状态?
答案 0 :(得分:1)
您可以将它们作为字符串添加到“state”选项中,而不是对象:
state: '{"yLambda":0,"xZoomedDataMax":381835,"colorOption":"_UNIQUE_COLOR","xZoomedIn":false,"showTrails":false,"yZoomedIn":false,"playDuration":15000,"nonSelectedAlpha":0.4,"xLambda":0,"yAxisOption":"2","yZoomedDataMax":381835,"yZoomedDataMin":6213,"iconType":"BUBBLE","time":"2000","orderedByX":false,"iconKeySettings":[{"key":{"dim0":"Metric1"}},{"key":{"dim0":"Metric2"}},{"key":{"dim0":"Metric3"}},{"key":{"dim0":"Metric4"}}],"dimensions":{"iconDimensions":["dim0"]},"orderedByY":false,"duration":{"multiplier":1,"timeUnit":"Y"},"sizeOption":"2","uniColorForNonSelected":false,"xAxisOption":"2","xZoomedDataMin":6213}'
具体是状态选项(即options
的参数),而不是状态参数,因为MotionCharts是传统的可视化早在现代结构之前。输入如下:
options: {/* list of options */, state: 'state string'}
不喜欢这样:
options: {/* list of options */}, state: 'state string'