2

在电子表格中创建动态图表并选择“发布”后,我得到以下代码,该代码粘贴到我服务器上的 HTML 页面中,生成一个工作图表(我删除了我的电子表格 URL):

<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>

但是,图表不保留我在图表显示中所做的任何状态更改:颜色、大小、Lin/Log 等。

我可以通过高级对话框获取当前状态设置字符串:

{"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":{} 参数中没有效果。我尝试将状态字符串放在其他各个位置,但仍然没有效果。我在哪里放置状态字符串来显示我想要的初始状态?

4

1 回答 1

1

您将它们作为字符串而不是对象添加到“状态”选项中:

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'
于 2013-08-28T19:17:55.583 回答