lib/yinx_st.rb in yinx_st-0.1.1 vs lib/yinx_st.rb in yinx_st-0.1.2
- old
+ new
@@ -16,11 +16,11 @@
def last_n_days n
batches = Batches.new n
duration = "最近#{n}日"
- chart = MyChart.js do
+ @chart = MyChart.js do
material batches.all_notes
material batches.unwind_tags, name: :unwind_tags
select :yesterday do |note|
note.dump_id == batches.latest_id
@@ -68,15 +68,16 @@
bar :number_of_tags, name: '目前每篇笔记的标签数', from: :yesterday, w: 800, h: 240, asc: :key
line :dump_day, :tags, name: "#{duration}标签数变化", from: :unwind_tags, w: 1400, h:740, asc: :key, keys: batches.time_line
end
- generate_html chart
-
+ self
end
- def generate_html chart
- template = File.read File.expand_path('../yinx_st/chart.erb', __FILE__)
+ attr_reader :chart
+
+ def generate_html(erb_file=File.expand_path('../yinx_st/chart.erb', __FILE__))
+ template = File.read erb_file
html = ERB.new(template).result(binding)
end
end
end