-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b48a12
commit 703840c
Showing
9 changed files
with
217 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://coffeescript.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the HandlingEvents controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class HandlingEventsController < ApplicationController | ||
def handling_events | ||
Daru::View.plotting_library = :googlecharts | ||
|
||
data = [ | ||
['Year', 'Sales', 'Expenses'], | ||
['2013', 1000, 400], | ||
['2014', 1170, 460], | ||
['2015', 660, 1120], | ||
['2016', 1030, 540] | ||
] | ||
user_options = { | ||
listeners: { | ||
page: "alert('The user is navigating to page ' + (e['page'] + 1));", | ||
select: "alert('A table row was selected');" | ||
} | ||
} | ||
@table = Daru::View::Table.new(data, {page: 'enable', pageSize: 2}, user_options) | ||
|
||
user_options_chart = { | ||
listeners: { | ||
select: " var selection = chart.getSelection(); | ||
var selectedValue = data_table.getFormattedValue(selection[0].row, 0); | ||
alert('You selected ' + selectedValue + ' year');", | ||
# exports the chart to PDF format | ||
ready: "var doc = new jsPDF(); | ||
doc.addImage(chart.getImageURI(), 0, 0); | ||
doc.save('chart.pdf');" | ||
} | ||
} | ||
@column_chart = Daru::View::Plot.new(@table.table, { type: :column, width: 800 }, user_options_chart) | ||
|
||
render "handling_events" , layout: "googlecharts_layout" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module HandlingEventsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<h3> Handling Events in Google Table</h3> | ||
<p> | ||
<b>Data : </b> | ||
<%=raw @table.data %> | ||
<br> | ||
<b>Options</b> | ||
<%=raw @table.options %> | ||
<br> | ||
<b>Table : </b> | ||
<br> | ||
<%=raw @table.div %> | ||
</p> | ||
<br> | ||
|
||
<h3> Handling events in Google charts</h3> | ||
<p> | ||
<b>Data : </b> | ||
<%=raw @column_chart.data %> | ||
<br> | ||
<b>Options</b> | ||
<%=raw @column_chart.options %> | ||
<br> | ||
<b>Chart : </b> | ||
<br> | ||
<%=raw @column_chart.div %> | ||
</p> | ||
<br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
demo_rails/test/controllers/handling_events_controller_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test_helper' | ||
|
||
class HandlingEventsControllerTest < ActionDispatch::IntegrationTest | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<h3> Line Graph - Grey Background using CSS</h3> | ||
<p> | ||
<b>Data : </b> | ||
<%= @line_graph.chart.series_data %> | ||
<br> | ||
<b>Options</b> | ||
<%= @line_graph.chart.options %> | ||
<br> | ||
<b>Chart : </b> | ||
<br> | ||
<%= @line_graph.div %> | ||
</p> | ||
<br> | ||
|
||
<h3> Column Graph - Different styling using CSS</h3> | ||
<p> | ||
<b>Data : </b> | ||
<%= @column_graph.chart.series_data %> | ||
<br> | ||
<b>Options</b> | ||
<%= @column_graph.chart.options %> | ||
<br> | ||
<b>Chart : </b> | ||
<br> | ||
<%= @column_graph.div %> | ||
</p> | ||
<br> |