ChartEditor; A few issues

94 views
Skip to first unread message

Alban Hertroys

unread,
Aug 19, 2015, 10:55:31 AM8/19/15
to Google Visualization API
We have a number of charts, all with continuous X-axes. Currently we're looking into making these charts editable using the ChartEditor class.
The editor works, but there are a few issues.

First our most relevant concern: Our continuous x-axis is read from the first column of a DataTable. This results in incorrect output upon opening the ChartEditor, it handles the first data-column just the same as any other data-column: as a column of data-values to plot on the y-axis.

To work around this, we have to check the option "Use 1st column as labels" each time that we open the chart editor. Is there a way to have that set by default?
I couldn't find anything in the API documentation pointing in that direction.

Secondly, after editing and pressing OK, the charts resize to a much smaller size than what we started on.
I managed to work around that problem by storing the chart wrapper dimensions (width & height) in a variable and then re-applying those values again when handling the 'ok' event of the ChartEditor, with these lines:
    chartEditor.getChartWrapper().setOptions({width: 900, height: 700});
    chartEditor.getChartWrapper().draw();

That doesn't look like that's how it's supposed to work. Am I missing something?

Regards,

Alban.

Daniel LaLiberte

unread,
Aug 19, 2015, 12:05:14 PM8/19/15
to Google Visualization API
Hi Alban,

I'll forward your question to the folks who work on the ChartEditor, which is more in the realm of Google Spreadsheets.  

But one thing I can help with is that the chartEditor.getChartWrapper() call creates a clone of the ChartWrapper each time you call it, which is a bit surprising, and is probably causing the problem you are seeing.   Try just calling it once and setting options and drawing from that one copy.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/e1e1f7f6-519c-4b96-bc3f-aaaea7e8e47c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
dlaliberte@Google.com   5CC, Cambridge MA
daniel.laliberte@GMail.com 9 Juniper Ridge Road, Acton MA

Alban Hertroys

unread,
Aug 21, 2015, 5:12:42 AM8/21/15
to Google Visualization API
On Wednesday, August 19, 2015 at 6:05:14 PM UTC+2, Daniel LaLiberte wrote:
Hi Alban,

I'll forward your question to the folks who work on the ChartEditor, which is more in the realm of Google Spreadsheets.  

Thanks. Could you point me to where that post ended up? I can't seem to find it.
 
But one thing I can help with is that the chartEditor.getChartWrapper() call creates a clone of the ChartWrapper each time you call it, which is a bit surprising, and is probably causing the problem you are seeing.   Try just calling it once and setting options and drawing from that one copy.

I've been experimenting a bit with that idea in mind, but it looks to me that without creating a clone of the ChartWrapper (by using getChartWrapper()) the chart does not update to reflect the changes made in the editor. Of course, that is to be expected if the editor works on a clone, but in that case I don't see any way to use the ChartEditor _without_ using the cloned object.

What's a bit unfortunate is that it appears that the ChartWrapper clone still references the original chart options object that it modified in the ChartEditor. That's understandable, but a bit of an annoyance for options that the ChartEditor cannot set, such as the width and height of the graph; it modifies those options to 600x371 for some reason, while our charts were originally 900x700.

I've been successful by also creating a clone of the options object and apply that to the clone of the ChartWrapper returned from ChartEditor::getChartWrapper(), overriding the options that the ChartEditor modified in the process.

Interestingly, the original options object that was modified by the ChartEditor contains a property 'useFirstColumnAsDomain' after editing. That seems like the property I need. Unfortunately, adding that property to my ChartWrapper options (on creation) does not seem to set that option in the ChartEditor...
 
On Wed, Aug 19, 2015 at 10:55 AM, Alban Hertroys <hara...@gmail.com> wrote:
We have a number of charts, all with continuous X-axes. Currently we're looking into making these charts editable using the ChartEditor class.
The editor works, but there are a few issues.

First our most relevant concern: Our continuous x-axis is read from the first column of a DataTable. This results in incorrect output upon opening the ChartEditor, it handles the first data-column just the same as any other data-column: as a column of data-values to plot on the y-axis.

To work around this, we have to check the option "Use 1st column as labels" each time that we open the chart editor. Is there a way to have that set by default?
I couldn't find anything in the API documentation pointing in that direction.

Secondly, after editing and pressing OK, the charts resize to a much smaller size than what we started on.
I managed to work around that problem by storing the chart wrapper dimensions (width & height) in a variable and then re-applying those values again when handling the 'ok' event of the ChartEditor, with these lines:
    chartEditor.getChartWrapper().setOptions({width: 900, height: 700});
    chartEditor.getChartWrapper().draw();

That doesn't look like that's how it's supposed to work. Am I missing something?

Regards,

Alban.



--
dlali...@Google.com   5CC, Cambridge MA
daniel.l...@GMail.com 9 Juniper Ridge Road, Acton MA
Reply all
Reply to author
Forward
0 new messages