☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

FixedTickFormatter stop working in 0.12.4rc1

Community Support
chupach1
chupach1

Hello,

an example using DateGapTickFormatter used to work in 0.12.3, not in 0.12.4rc1.

The errors are a bit cryptic. Hopefully a simple bug / a simple cure.

Code below.

Thx !

Complaints in the javascript console:

TypeError: DateGapTickFormatter.define is not a function. (In 'DateGapTickFormatter.define({

date_labels: [p.Any]

})’, ‘DateGapTickFormatter.define’ is undefined)

Error: Model `DateGapTickFormatter’ does not exists. The problem may be two fold. Either a model was requested that’s available in an extra bundle, e.g. a widget, or a custom model was requested, but it wasn’t registered before first usage.

Code:

from math import pi

import pandas as pd

from bokeh.models.formatters import TickFormatter, String, List

from bokeh.plotting import figure, show, output_file

from bokeh.sampledata.stocks import MSFT

from bokeh.io import curdoc,output_file, show

class DateGapTickFormatter(TickFormatter):

date_labels = List(String)

implementation = “”"

_ = require “underscore”

Model = require “model”

p = require “core/properties”

class DateGapTickFormatter extends Model

type: ‘DateGapTickFormatter’

doFormat: (ticks) →

date_labels = @date_labels

return (date_labels[tick] ? “” for tick in ticks)

@define {

date_labels: [ p.Any ]

}

module.exports =

Model: DateGapTickFormatter

“”"

df = pd.DataFrame(MSFT)[:50]

date_labels = [date.strftime(’%b %d’) for date in pd.to_datetime(df[“date”])]

mids = (df.open + df.close)/2

spans = abs(df.close-df.open)

inc = df.close > df.open

dec = df.open > df.close

w = 0.5

TOOLS = “pan,wheel_zoom,box_zoom,reset,save”

p = figure(tools=TOOLS, plot_width=1000, title=“MSFT Candlestick with Custom X-Axis”)

p.xaxis.major_label_orientation = pi/4

p.grid[0].ticker.desired_num_ticks = 6

p.xaxis[0].formatter = DateGapTickFormatter(date_labels = date_labels)

p.segment(df.index, df.high, df.index, df.low, color=“black”)

p.rect(df.index[inc], mids[inc], w, spans[inc], fill_color="#D5E1DD", line_color=“black”)

p.rect(df.index[dec], mids[dec], w, spans[dec], fill_color="#F2583E", line_color=“black”)

curdoc().add_root(p)

⌁   Link to post
Bryan
Bryan

Extension models are still quite new and some aspects of their format and expression are still evolving, please consult the most recent version of the example:
  
  https://github.com/bokeh/bokeh/blob/master/examples/plotting/file/custom_datetime_axis.py

Bryan

···

On Jan 6, 2017, at 3:24 PM, chupach <mathieur1507@gmail.com> wrote:

Hello,

an example using DateGapTickFormatter used to work in 0.12.3, not in 0.12.4rc1.
The errors are a bit cryptic. Hopefully a simple bug / a simple cure.
Code below.

Thx !

Complaints in the javascript console:

TypeError: DateGapTickFormatter.define is not a function. (In 'DateGapTickFormatter.define({
                date_labels: [p.Any]
            })', 'DateGapTickFormatter.define' is undefined)

Error: Model `DateGapTickFormatter' does not exists. The problem may be two fold. Either a model was requested that's available in an extra bundle, e.g. a widget, or a custom model was requested, but it wasn't registered before first usage.

Code:

from math import pi
import pandas as pd
from bokeh.models.formatters import TickFormatter, String, List
from bokeh.plotting import figure, show, output_file
from bokeh.sampledata.stocks import MSFT
from bokeh.io import curdoc,output_file, show

class DateGapTickFormatter(TickFormatter):
    date_labels = List(String)

    __implementation__ = """
    _ = require "underscore"
    Model = require "model"
    p = require "core/properties"

    class DateGapTickFormatter extends Model
      type: 'DateGapTickFormatter'

      doFormat: (ticks) ->
        date_labels = @date_labels
        return (date_labels[tick] ? "" for tick in ticks)

      @define {
        date_labels: [ p.Any ]
      }

    module.exports =
      Model: DateGapTickFormatter
    """

df = pd.DataFrame(MSFT)[:50]
date_labels = [date.strftime('%b %d') for date in pd.to_datetime(df["date"])]
mids = (df.open + df.close)/2
spans = abs(df.close-df.open)
inc = df.close > df.open
dec = df.open > df.close
w = 0.5

TOOLS = "pan,wheel_zoom,box_zoom,reset,save"

p = figure(tools=TOOLS, plot_width=1000, title="MSFT Candlestick with Custom X-Axis")
p.xaxis.major_label_orientation = pi/4
p.grid[0].ticker.desired_num_ticks = 6
p.xaxis[0].formatter = DateGapTickFormatter(date_labels = date_labels)
p.segment(df.index, df.high, df.index, df.low, color="black")
p.rect(df.index[inc], mids[inc], w, spans[inc], fill_color="#D5E1DD", line_color="black")
p.rect(df.index[dec], mids[dec], w, spans[dec], fill_color="#F2583E", line_color="black")
curdoc().add_root(p)

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/cbb138ef-155e-43b4-84e4-64c28b60804c%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post
Mateusz_Paprocki
Mateusz_Paprocki

Hi,

···

On Fri, Jan 6, 2017 at 10:24 PM, chupach mathieur1507@gmail.com wrote:

Hello,

an example using DateGapTickFormatter used to work in 0.12.3, not in 0.12.4rc1.

The errors are a bit cryptic. Hopefully a simple bug / a simple cure.

Code below.

Thx !

Complaints in the javascript console:

TypeError: DateGapTickFormatter.define is not a function. (In 'DateGapTickFormatter.define({

date_labels: [p.Any]

})', ‘DateGapTickFormatter.define’ is undefined)

Error: Model `DateGapTickFormatter’ does not exists. The problem may be two fold. Either a model was requested that’s available in an extra bundle, e.g. a widget, or a custom model was requested, but it wasn’t registered before first usage.

Code:

from math import pi

import pandas as pd

from bokeh.models.formatters import TickFormatter, String, List

from bokeh.plotting import figure, show, output_file

from bokeh.sampledata.stocks import MSFT

from bokeh.io import curdoc,output_file, show

class DateGapTickFormatter(TickFormatter):

date_labels = List(String)

implementation = “”"

_ = require “underscore”

Model = require “model”

p = require “core/properties”

class DateGapTickFormatter extends Model

type: ‘DateGapTickFormatter’

doFormat: (ticks) →

date_labels = @date_labels

return (date_labels[tick] ? “” for tick in ticks)

@define {

date_labels: [ p.Any ]

}

module.exports =

Model: DateGapTickFormatter

“”"

Model imports and exports changed in 0.12.4. Here are necessary changes:

Model = require “model”

{Model} = require “model”

module.exports =
Model: DateGapTickFormatter

module.exports = {

DateGapTickFormatter: DateGapTickFormatter
}

Alternatively, you can use new syntax for imports and exports:

import {Model} from “model”

export class DateGapTickFormatter extends Model

and remove module.exports = {...}.

Mateusz

df = pd.DataFrame(MSFT)[:50]

date_labels = [date.strftime(‘%b %d’) for date in pd.to_datetime(df[“date”])]

mids = (df.open + df.close)/2

spans = abs(df.close-df.open)

inc = df.close > df.open

dec = df.open > df.close

w = 0.5

TOOLS = “pan,wheel_zoom,box_zoom,reset,save”

p = figure(tools=TOOLS, plot_width=1000, title=“MSFT Candlestick with Custom X-Axis”)

p.xaxis.major_label_orientation = pi/4

p.grid[0].ticker.desired_num_ticks = 6

p.xaxis[0].formatter = DateGapTickFormatter(date_labels = date_labels)

p.segment(df.index, df.high, df.index, df.low, color=“black”)

p.rect(df.index[inc], mids[inc], w, spans[inc], fill_color=“#D5E1DD”, line_color=“black”)

p.rect(df.index[dec], mids[dec], w, spans[dec], fill_color=“#F2583E”, line_color=“black”)

curdoc().add_root(p)

–

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

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/cbb138ef-155e-43b4-84e4-64c28b60804c%40continuum.io.

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

⌁   Link to post

End of archived discussion · Replies are disabled