Module: Sol::BaseChart

Included in:
Chart
Defined in:
lib/charts/base_chart.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) data


Base Mixin Set the data callback or retrieve the chart's data set. The data callback is passed the chart's group and by default will return group.all(). This behavior may be modified to, for instance, return only the top 5 groups:




58
59
# File 'lib/charts/base_chart.rb', line 58

def data
end

- (Object) dimension(val = nil)


Base Mixin Set or get the dimension attribute of a chart. In dc a dimension can be any valid crossfilter dimension. If a value is given, then it will be used as the new dimension. If no value is specified then the current dimension will be returned.




69
70
71
72
73
# File 'lib/charts/base_chart.rb', line 69

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

- (Object) group(method, name = nil)


Base Mixin Set or get the group attribute of a chart. In dc a group is a crossfilter group. Usually the group should be created from the particular dimension associated with the same chart. If a value is given, then it will be used as the new group.

If no value specified then the current group will be returned. If name is specified then it will be used to generate legend label.




93
94
95
96
97
98
99
100
101
# File 'lib/charts/base_chart.rb', line 93

def group(method, name = nil)
  
  @group_name = @name.downcase + "Group"
  @group = 
    "var #{@group_name} = #{@dim}.group().#{Sol.camelcase(method.to_s)}(function(d) {return d[\"#{@y_column}\"];});"
  @properties["group"] = @group_name
  return self

end

- (Boolean) grouped?



Returns:

  • (Boolean)


79
80
81
# File 'lib/charts/base_chart.rb', line 79

def grouped?
  @group != nil
end

- (Object) height(val = nil)


Base Mixin Set or get the height attribute of a chart. The height is applied to the SVG element generated by the chart when rendered (or rerendered). If a value is given, then it will be used to calculate the new height and the chart returned for method chaining. The value can either be a numeric, a function, or falsy. If no value is specified then the value of the current height attribute will be returned.

By default, without an explicit height being given, the chart will select the width of its anchor element. If that isn't possible it defaults to 200. Setting the value falsy will return the chart to the default behavior




45
46
47
48
49
# File 'lib/charts/base_chart.rb', line 45

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

- (Object) min_height


Base Mixin Set or get the minimum height attribute of a chart. This only applicable if the width is calculated by dc.




119
120
121
# File 'lib/charts/base_chart.rb', line 119

def min_height

end

- (Object) min_width


Base Mixin Set or get the minimum width attribute of a chart. This only applicable if the width is calculated by dc.




109
110
111
# File 'lib/charts/base_chart.rb', line 109

def min_width

end

- (Object) transition_duration(val = nil)


Set or get the animation transition duration(in milliseconds) for this chart instance. Default duration is 750ms.




128
129
130
131
132
# File 'lib/charts/base_chart.rb', line 128

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

- (Object) width(val = nil)


Base Mixin Set or get the width attribute of a chart. See .height for further description of the behavior.




140
141
142
143
144
# File 'lib/charts/base_chart.rb', line 140

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