Trying to display custom labels on Highcharts column chart x-axis.
The chart currently renders data, but default labels like 0,1,2,3... are displayed on the x-axis.
notes_controller:
def dashboard
@data = Note.getData()
end
note.rb
def self.getData
data = []
self.subject_types.each do |type|
data << self.type_count(type)
end
data
end
private
def self.subject_types
pluck(:subject_type).uniq
end
def self.type_count(type)
where(subject_type: type).count
end
end
dashboard.html.erb javascript
...series: [{
name: 'Number of Notes By Class Module',
data: <%= @data %>
}]...
Everything is working fine, but how can I get the labels to show up from a specific column in my table named "subject_type"? I tried the following:
note.rb:
def self.getSubjects
respond_to do |format|
render :json => @note.to_json(:only => [:subject_type])
end
(I'm unsure if this approach is correct!)
notes_controller.rb:
def subject
@subject = Note.getSubjects()
end
dashboard.html.erb:
...series: [{
name: 'Number of Notes By Class Module',
data: <%= @data %>, <%= @subject %>
}]...
Any assistance with this would be greatly appreciated.