It's easy to imagine that the chart code could have a difficult time doing its job without any columns.
I tried the workaround that you suggest but the issue is that all series on a given axis must be of the same data type. So If I add an 'always shown' column it needs to be a number (I'm drawing a line chart in this case). That number will draw its line on the chart and add an entry in the legend. If you know of any way to create a valid data point for a numeric column that doesn't show anything on the chart and doesn't create a legend entry that would be helpful but I don't think that exists. At least I don't see anything like it in the docs. The only other approach is inelegant and outside the chat api - redefine the behavior of a list of checkboxes so they never allow all of them to be turned off. But changing the interaction of the venerable checkbox would have a negative affect on the user experience so I'm going to keep looking for some other solution. Just for your reference, here are two use cases prompting this. 1. the user wants to compare a few of the series on the chart rather than deal with all of them at once (and sooner or later they'll turn them all off). 2. the data has outlying series that expand the vertical axis' range which visually compresses the non-outlying values. When the chart is drawn without the outliers the vertical axis range is re-scaled so the similarities and differences of the non-outliers are more apparent. If I find some reasonable solution I'll post it to this thread. Thank you very much for your help. On Tuesday, August 16, 2016 at 8:21:06 PM UTC+2, Daniel LaLiberte wrote: > > The charts are generally resistant to being draw with no columns of data, > other than the domain column. At the very least, charts won't know how to > generate the target axis unless you specify the bounds with the viewWindow > option. > > But we haven't put much effort into drawing an empty chart because there > is little demand for that. I can see why it would be useful in special > situations, however, and we should find a way at some point. > > As a workaround, you might try adding a special column will all null > values, which you never remove but also it won't show anything. I'm not > sure how well that will work either, but it is worth a shot. > > On Tue, Aug 16, 2016 at 1:28 PM, <[email protected] <javascript:>> wrote: > >> I'd like give the user the ability to hide and show lines on a line >> chart. >> But eventually a user will 'turn off' all the columns of a chart so I'm >> looking for a way to hide ALL the columns of a chart. >> >> Given this partial pseudo code: >> >> myDataTable.addColumn('date', 'Month'); >> myDataTable.addColumn('number', 'Line 1'); >> myDataTable.addColumn('number', 'Line 2'); >> myDataTable.addColumn('number', 'Line 3'); >> ... then add appropriate data to myDataTable... >> >> myDataView = new google.visualization.DataView(myDataTable); >> myDataView .setColumns([0, 1, 2, 3]); >> myLineChart .draw(myDataView, myOptions); >> (Shows all the columns of the chart) >> >> But when I call this: >> >> myDataView .setColumns([0]); >> myLineChart .draw(myDataView, myOptions); >> >> I get this error: >> Not enough columns given to draw the requested chart. >> >> I've also tried >> myDataView .hideColumns([1,2,3]) >> draw... >> and get the same error message. >> >> Is there anyway to draw a chart when all the columns need to be hidden? >> >> >> >> -- >> 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 [email protected] >> <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at >> https://groups.google.com/group/google-visualization-api. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/google-visualization-api/16af04f2-8015-45ce-b24c-aeba4dc0e60b%40googlegroups.com >> >> <https://groups.google.com/d/msgid/google-visualization-api/16af04f2-8015-45ce-b24c-aeba4dc0e60b%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2> > [email protected] <javascript:> 5CC, Cambridge MA > On Tuesday, August 16, 2016 at 8:21:06 PM UTC+2, Daniel LaLiberte wrote: > > The charts are generally resistant to being draw with no columns of data, > other than the domain column. At the very least, charts won't know how to > generate the target axis unless you specify the bounds with the viewWindow > option. > > But we haven't put much effort into drawing an empty chart because there > is little demand for that. I can see why it would be useful in special > situations, however, and we should find a way at some point. > > As a workaround, you might try adding a special column will all null > values, which you never remove but also it won't show anything. I'm not > sure how well that will work either, but it is worth a shot. > > On Tue, Aug 16, 2016 at 1:28 PM, <[email protected] <javascript:>> wrote: > >> I'd like give the user the ability to hide and show lines on a line >> chart. >> But eventually a user will 'turn off' all the columns of a chart so I'm >> looking for a way to hide ALL the columns of a chart. >> >> Given this partial pseudo code: >> >> myDataTable.addColumn('date', 'Month'); >> myDataTable.addColumn('number', 'Line 1'); >> myDataTable.addColumn('number', 'Line 2'); >> myDataTable.addColumn('number', 'Line 3'); >> ... then add appropriate data to myDataTable... >> >> myDataView = new google.visualization.DataView(myDataTable); >> myDataView .setColumns([0, 1, 2, 3]); >> myLineChart .draw(myDataView, myOptions); >> (Shows all the columns of the chart) >> >> But when I call this: >> >> myDataView .setColumns([0]); >> myLineChart .draw(myDataView, myOptions); >> >> I get this error: >> Not enough columns given to draw the requested chart. >> >> I've also tried >> myDataView .hideColumns([1,2,3]) >> draw... >> and get the same error message. >> >> Is there anyway to draw a chart when all the columns need to be hidden? >> >> >> >> -- >> 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 [email protected] >> <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at >> https://groups.google.com/group/google-visualization-api. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/google-visualization-api/16af04f2-8015-45ce-b24c-aeba4dc0e60b%40googlegroups.com >> >> <https://groups.google.com/d/msgid/google-visualization-api/16af04f2-8015-45ce-b24c-aeba4dc0e60b%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2> > [email protected] <javascript:> 5CC, Cambridge MA > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/google-visualization-api. To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/67ba742d-77ae-445d-bf43-bf47eeedec4c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
