Closed makenstein closed 8 years ago
Have a look at the jobs/timeline.rb file in the repo... you need to send your data in the same format as is being sent in that job. Basically its an array of json objects, where each json object is an event.
events << {
name: event["name"],
date: event["date"],
background: event["background"],
opacity: 0.5
}
Thanks a lot, i'll give it a shot! :)
HI, i created a new job file that extracts information from an excel file and send it to the widget. i tried that job file with "List" widget and "birthday" and data shows correctly, but when i try it with the TIMELINE widget, data never shows up, i just get an empty grey rectangle with the title on the top, that's it.
can someone help me with it please? thanks
this is my code:
require 'date' require 'roo' require 'active_support' require 'active_support/core_ext'
timeline_FILENAME = 'timeline_data.xlsx'
SCHEDULER.every '3s', :first_in => '1s' do timeline = [] timeline_report = Roo::Excelx.new(timeline_FILENAME) (2..timeline_report.last_row).each do |row| name = timelinereport.cell(row, 1) name.sub!(/(\S+),\s(\S+)._/, '\2 \1')
end
get next 10 timeline
timeline = timeline.sort{|a, b| a[:date] <=> b[:date]}[0..9]
assemble data to send to client
timeline_data = [] timeline.each do |timeline| timeline_data.push({ 'label' => timeline[:name], 'value' => timeline[:date].strftime("%-m/%-d") }) end
send_event('data', { items: timeline_data, class: 'icon icon-background icon-calendar'}) end