<commit_before>
define [
  "underscore",
  "common/safebind",
  "common/has_parent",
  "common/ticking",
  "renderer/properties",
  "common/plot_widget",
], (_, safebind, HasParent, ticking, Properties, PlotWidget) ->

  line_properties = Properties.line_properties

  class GridView extends PlotWidget
    initialize: (attrs, options) ->
      super(attrs, options)

      @grid_props = new line_properties(@, null, 'grid_')

    render: () ->
      ctx = @plot_view.ctx

      ctx.save()
      @_draw_grids(ctx)
      ctx.restore()

    bind_bokeh_events: () ->
      safebind(this, @model, 'change', @request_render)

    _draw_grids: (ctx) ->
      if not @grid_props.do_stroke
        return
      [xs, ys] = @mget('grid_coords')
      @grid_props.set(ctx, @)
      for i in [0...xs.length]
        [sx, sy] = @plot_view.map_to_screen(xs[i], "data", ys[i], "data")
        ctx.beginPath()
        ctx.moveTo(Math.round(sx[0]), Math.round(sy[0]))
        for i in [1...sx.length]
          ctx.lineTo(Math.round(sx[i]), Math.round(sy[i]))
        ctx.stroke()
      return

  class Grid extends HasParent
    default_view: GridView
    type: 'Grid'

    initialize: (attrs, options)->
      super(attrs, options)

      @register_property('computed_bounds', @_bounds, false)
      @add_dependencies('computed_bounds', this, ['bounds'])

      # FIXME Is it better to register a property?  Or just use a member
      # variable?
      @register_property('scale', @_scale, false)
      @add_dependencies('scale', this, ['is_datetime'])

      @register_property('grid_coords', @_grid_coords, false)<commit_msg>Use caching for the scale property.<commit_after>
define [
  "underscore",
  "common/safebind",
  "common/has_parent",
  "common/ticking",
  "renderer/properties",
  "common/plot_widget",
], (_, safebind, HasParent, ticking, Properties, PlotWidget) ->

  line_properties = Properties.line_properties

  class GridView extends PlotWidget
    initialize: (attrs, options) ->
      super(attrs, options)

      @grid_props = new line_properties(@, null, 'grid_')

    render: () ->
      ctx = @plot_view.ctx

      ctx.save()
      @_draw_grids(ctx)
      ctx.restore()

    bind_bokeh_events: () ->
      safebind(this, @model, 'change', @request_render)

    _draw_grids: (ctx) ->
      if not @grid_props.do_stroke
        return
      [xs, ys] = @mget('grid_coords')
      @grid_props.set(ctx, @)
      for i in [0...xs.length]
        [sx, sy] = @plot_view.map_to_screen(xs[i], "data", ys[i], "data")
        ctx.beginPath()
        ctx.moveTo(Math.round(sx[0]), Math.round(sy[0]))
        for i in [1...sx.length]
          ctx.lineTo(Math.round(sx[i]), Math.round(sy[i]))
        ctx.stroke()
      return

  class Grid extends HasParent
    default_view: GridView
    type: 'Grid'

    initialize: (attrs, options)->
      super(attrs, options)

      @register_property('computed_bounds', @_bounds, false)
      @add_dependencies('computed_bounds', this, ['bounds'])

      # FIXME Is it better to register a property?  Or just use a member
      # variable?
      @register_property('scale', @_scale, true)
      @add_dependencies('scale', this, ['is_datetime'])

      @register_property('grid_coords', @_grid_coords, false)
{'fraction_non_alphanumeric': 0.14761171032357473, 'fraction_numerical': 0.002465331278890601, 'mean_word_length': 3.012360939431397, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7382294', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1066, 'n_words': 230}