Glyph disappears when zooming out

When zooming out, the glyph disappears as soon as the plot range is greater than the original plot range,
in particular, if the newly loaded dataframe is larger than the initial dataframe (which is passed on the
the ColumnDataSource.

Is this a known bug?

class TimeValueElement:
def init(self, df=None, time_column, value_column):
if df is None:
df = pd.DataFrame()
df[self.time_column] =
df[self.value_column] =
self.df = df
self.source = ColumnDataSource(self.df)
self.reload_function = None

def _add_glyph(self, plot, style='point', **properties):
    if style == 'point':
        plot.circle(source=self.source, x=self.time_column,
                    y=self.value_column, **properties)

def _reload(self, document, plot_start, plot_end):
    if self.reload_function:
        time_start = to_datetime(plot_start)
        time_end = to_datetime(plot_end)
        df = self.reload_function(time_start, time_end,
                                  *self.args, **self.kwargs)
        if df is None:
            df = pd.DataFrame()
            df[self.time_column] = []
            df[self.value_column] = []
        self.df = df
        self._update(document)

def _update(self, document):
    document.hold()
    self.source.data = ColumnDataSource(self.df).data
    document.unhold()

``

Hi Artur,

Your code doesn’t really show anything. What is “reload_function”, how do you call the method of this class?

Also, you don’t set “self.time_column” and “self.value_column” in “init”, and you don’t need “document.hold()” and “document.unhold()” when you change only one field.

Could you provide an example that can be reproduced?

Regards,

Eugene

···

On Wednesday, February 14, 2018 at 3:33:56 AM UTC+7, Artur Scholz wrote:

When zooming out, the glyph disappears as soon as the plot range is greater than the original plot range,
in particular, if the newly loaded dataframe is larger than the initial dataframe (which is passed on the
the ColumnDataSource.

Is this a known bug?

class TimeValueElement:
def init(self, df=None, time_column, value_column):
if df is None:
df = pd.DataFrame()
df[self.time_column] =
df[self.value_column] =
self.df = df
self.source = ColumnDataSource(self.df)
self.reload_function = None

def _add_glyph(self, plot, style='point', **properties):
    if style == 'point':
        plot.circle(source=self.source, x=self.time_column,
                    y=self.value_column, **properties)

def _reload(self, document, plot_start, plot_end):
    if self.reload_function:
        time_start = to_datetime(plot_start)
        time_end = to_datetime(plot_end)
        df = self.reload_function(time_start, time_end,
                                  *self.args, **self.kwargs)
        if df is None:
            df = pd.DataFrame()
            df[self.time_column] = []
            df[self.value_column] = []
        self.df = df
        self._update(document)

def _update(self, document):
    document.hold()
    self.source.data = ColumnDataSource(self.df).data
    document.unhold()

``

It appears that the webgl option is not working for lines. Below is a jupyter notebook example that does not plot

the lines correctly. In contrast, when changing to circle glyphs, or without webgl option, all data is plotted.

···

On Tue, Feb 13, 2018 at 9:40 PM, Eugene Pakhomov [email protected] wrote:

Hi Artur,

Your code doesn’t really show anything. What is “reload_function”, how do you call the method of this class?

Also, you don’t set “self.time_column” and “self.value_column” in “init”, and you don’t need “document.hold()” and “document.unhold()” when you change only one field.

Could you provide an example that can be reproduced?

Regards,

Eugene

On Wednesday, February 14, 2018 at 3:33:56 AM UTC+7, Artur Scholz wrote:

When zooming out, the glyph disappears as soon as the plot range is greater than the original plot range,
in particular, if the newly loaded dataframe is larger than the initial dataframe (which is passed on the
the ColumnDataSource.

Is this a known bug?

class TimeValueElement:
def init(self, df=None, time_column, value_column):
if df is None:
df = pd.DataFrame()
df[self.time_column] =
df[self.value_column] =
self.df = df
self.source = ColumnDataSource(self.df)
self.reload_function = None

def _add_glyph(self, plot, style='point', **properties):
    if style == 'point':
        plot.circle(source=self.source, x=self.time_column,
                    y=self.value_column, **properties)

def _reload(self, document, plot_start, plot_end):
    if self.reload_function:
        time_start = to_datetime(plot_start)
        time_end = to_datetime(plot_end)
        df = self.reload_function(time_start, time_end,
                                  *self.args, **self.kwargs)
        if df is None:
            df = pd.DataFrame()
            df[self.time_column] = []
            df[self.value_column] = []
        self.df = df
        self._update(document)

def _update(self, document):
    document.hold()
    self.source.data = ColumnDataSource(self.df).data
    document.unhold()

``

You received this message because you are subscribed to a topic in the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/Frf_WcOP0vE/unsubscribe.

To unsubscribe from this group and all its topics, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/cf11a46a-949f-488f-ba3a-a5996df1d3f1%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.