@@ -41,25 +41,31 @@ export function register(...plugins) {
4141
4242function drawChart ( chart ) {
4343 return async function ( el , view , task , end_col , end_row ) {
44- let jsonp ;
44+ let jsonp , metadata ;
4545 const realValues = JSON . parse ( this . getAttribute ( "columns" ) ) ;
46-
47- if ( end_col && end_row ) {
48- jsonp = view . to_json ( { end_row, end_col, leaves_only : true } ) ;
49- } else if ( end_col ) {
50- jsonp = view . to_json ( { end_col, leaves_only : true } ) ;
51- } else if ( end_row ) {
52- jsonp = view . to_json ( { end_row, leaves_only : true } ) ;
53- } else {
54- jsonp = view . to_json ( { leaves_only : true } ) ;
46+ try {
47+ if ( end_col && end_row ) {
48+ jsonp = view . to_json ( { end_row, end_col, leaves_only : true } ) ;
49+ } else if ( end_col ) {
50+ jsonp = view . to_json ( { end_col, leaves_only : true } ) ;
51+ } else if ( end_row ) {
52+ jsonp = view . to_json ( { end_row, leaves_only : true } ) ;
53+ } else {
54+ jsonp = view . to_json ( { leaves_only : true } ) ;
55+ }
56+ metadata = await Promise . all ( [ this . _table . schema ( false ) , view . computed_schema ( false ) , view . schema ( false ) , jsonp , view . get_config ( ) ] ) ;
57+ } catch ( e ) {
58+ if ( e . message !== "View is not initialized" ) {
59+ throw e ;
60+ }
5561 }
5662
57- let [ table_schema , computed_schema , view_schema , json , config ] = await Promise . all ( [ this . _table . schema ( false ) , view . computed_schema ( false ) , view . schema ( false ) , jsonp , view . get_config ( ) ] ) ;
58-
5963 if ( task . cancelled ) {
6064 return ;
6165 }
6266
67+ let [ table_schema , computed_schema , view_schema , json , config ] = metadata ;
68+
6369 /**
6470 * Retrieve a tree axis column from the table and computed schemas,
6571 * returning a String type or `undefined`.
@@ -105,7 +111,7 @@ function getOrCreatePluginElement() {
105111function createOrUpdateChart ( div , chart , settings ) {
106112 const perspective_d3fc_element = getOrCreatePluginElement . call ( this ) ;
107113
108- if ( ! document . body . contains ( perspective_d3fc_element ) ) {
114+ if ( ! div . contains ( perspective_d3fc_element ) ) {
109115 div . innerHTML = "" ;
110116 div . appendChild ( perspective_d3fc_element ) ;
111117 }
0 commit comments