Class: ErdMap::Plot

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/erd_map/plot.rb

Defined Under Namespace

Classes: Header

Instance Method Summary collapse

Instance Method Details

#headerObject



29
30
31
# File 'lib/erd_map/plot.rb', line 29

def header
  @header.to_a
end

#plotObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/erd_map/plot.rb', line 8

def plot
  return @plot if @plot

  padding_ratio = 0.1
  x_min, x_max, y_min, y_max = graph.initial_layout.values.transpose.map(&:minmax).flatten
  x_padding, y_padding = [(x_max - x_min) * padding_ratio, (y_max - y_min) * padding_ratio]
  @plot = bokeh_models.Plot.new(
    sizing_mode: "stretch_both",
    x_range: bokeh_models.Range1d.new(start: x_min - x_padding, end: x_max + x_padding),
    y_range: bokeh_models.Range1d.new(start: y_min - y_padding, end: y_max + y_padding),
    tools: [
      wheel_zoom_tool = bokeh_models.WheelZoomTool.new,
      bokeh_models.ResetTool.new,
      bokeh_models.PanTool.new,
      bokeh_models.TapTool.new,
    ],
  ).tap do |plot|
    plot.toolbar.active_scroll = wheel_zoom_tool
  end
end