Module: Sol::CoordinateChart

Included in:
BarChart, LineChart
Defined in:
lib/sol/coordinate_chart.rb

Overview

Instance Method Summary collapse

Instance Method Details

#brush_on(bool = nil) ⇒ Object


Turn on/off the brush-based range filter. When brushing is on then user can drag the mouse across a chart with a quantitative scale to perform range filtering based on the extent of the brush, or click on the bars of an ordinal bar chart or slices of a pie chart to filter and unfilter them. However turning on the brush filter will disable other interactive elements on the chart such as highlighting, tool tips, and reference lines. Zooming will still be possible if enabled, but only via scrolling (panning will be disabled.) Default: true




42
43
44
45
46
# File 'lib/sol/coordinate_chart.rb', line 42

def brush_on(bool = nil)
  return @properties["brushOn"] if bool == nil
  @properties["brushOn"] = bool
  return self
end

#clip_padding(val = nil) ⇒ Object


Get or set the padding in pixels for the clip path. Once set padding will be applied evenly to the top, left, right, and bottom when the clip path is generated. If set to zero, the clip area will be exactly the chart body area minus the margins. Default: 5




54
55
56
57
58
# File 'lib/sol/coordinate_chart.rb', line 54

def clip_padding(val = nil)
  return @properties["clipPadding"] if !val
  @properties["clipPadding"] = val
  return self
end

#elastic_x(bool = nil) ⇒ Object


Get or set the elasticity on x axis. If this attribute is set to true, then the x axis will rescle to auto-fit the data range when filtered.




65
66
67
68
69
# File 'lib/sol/coordinate_chart.rb', line 65

def elastic_x(bool = nil)
  return @properties["elasticX"] if bool == nil
  @properties["elasticX"] = bool
  return self
end

#elastic_y(bool = nil) ⇒ Object


Turn on/off elastic y axis behavior. If y axis elasticity is turned on, then the grid chart will attempt to recalculate the y axis range whenever a redraw event is triggered.




77
78
79
80
81
# File 'lib/sol/coordinate_chart.rb', line 77

def elastic_y(bool = nil)
  return @properties["elasticY"] if bool == nil
  @properties["elasticY"] = bool
  return self
end

#x(type, input_domain = nil, input_range = nil) ⇒ Object


Defines the x scale for the chart




87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/sol/coordinate_chart.rb', line 87

def x(type, input_domain = nil, input_range = nil)

  if (type.is_a? Sol::Scale)
    scale = type
  else
    scale = Sol.scale(type)
    scale.domain(input_domain) if input_domain
    scale.range(input_range) if input_range
  end
  @properties["x"] = scale.spec

  return self

end

#x_axis_label(val = nil, padding = 12) ⇒ Object


Set or get the x axis label. If setting the label, you may optionally include additional padding to the margin to make room for the label. By default the padded is set to 12 to accomodate the text height.




108
109
110
111
112
# File 'lib/sol/coordinate_chart.rb', line 108

def x_axis_label(val = nil, padding = 12)
  return @properties["xAxisLabel"] if !val
  @properties["xAxisLabel"] = "\"#{val}\""
  return self
end

#y_axis_label(val = nil, padding = 12) ⇒ Object


Set or get the y axis label. If setting the label, you may optionally include additional padding to the margin to make room for the label. By default the padded is set to 12 to accomodate the text height.




120
121
122
123
124
# File 'lib/sol/coordinate_chart.rb', line 120

def y_axis_label(val = nil, padding = 12)
  return @properties["yAxisLabel"] if !val
  @properties["yAxisLabel"] = "\"#{val}\""
  return self
end