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]> 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]. > To post to this group, send email to google-visualization-api@ > googlegroups.com. > 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] <[email protected]> 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/CAOtcSJMVr0%2Bds7PzMcJiymBXr6mTyuGw6n-rV8sxGBUCgceVqw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
