-
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.
Merge pull request #9 from Prakriti-nith/charteditor
Added chart editor examples
- Loading branch information
Showing
7 changed files
with
97 additions
and
0 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 ChartEditor 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,26 @@ | ||
class ChartEditorController < ApplicationController | ||
def chart_editor | ||
# set the library, to plot charts | ||
Daru::View.plotting_library = :googlecharts | ||
|
||
data = [ | ||
['Year', 'Sales', 'Expenses'], | ||
['2013', 1000, 400], | ||
['2014', 1170, 460], | ||
['2015', 660, 1120], | ||
['2016', 1030, 540] | ||
] | ||
data_str = 'https://docs.google.com/spreadsheets/d/1aXns2ch8y_rl9ZLxSYZIU5ewUB1ZNAg5O6iPLZLApZI/gviz/tq?header=1&tq=' | ||
area_chart_options = { | ||
type: :area | ||
} | ||
|
||
@area_table = Daru::View::Table.new(data, {}, chart_class: 'Charteditor') | ||
@area_chart = Daru::View::Plot.new(@area_table.table, area_chart_options, chart_class: 'Charteditor') | ||
|
||
@table = Daru::View::Table.new(data_str, {width: 500}, chart_class: 'Charteditor') | ||
@plot = Daru::View::Plot.new(data, {width: 500}, chart_class: 'Charteditor') | ||
|
||
render "chart_editor" , 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 ChartEditorHelper | ||
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,55 @@ | ||
<h3> Area Chart Table</h3> | ||
<p> | ||
<b>Data : </b> | ||
<%=raw @area_table.data %> | ||
<br> | ||
<b>Options</b> | ||
<%=raw @area_table.options %> | ||
<br> | ||
<b>Table : </b> | ||
<br> | ||
<%=raw @area_table.div %> | ||
</p> | ||
<br> | ||
|
||
<h3> Area Chart</h3> | ||
<p> | ||
<b>Data : </b> | ||
<%=raw @area_chart.data %> | ||
<br> | ||
<b>Options</b> | ||
<%=raw @area_chart.options %> | ||
<br> | ||
<b>Chart : </b> | ||
<br> | ||
<%=raw @area_chart.div %> | ||
</p> | ||
<br> | ||
|
||
<h3> Table using data as google spreadsheet URL</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> Chart using data as google spreadsheet URL</h3> | ||
<p> | ||
<b>Data : </b> | ||
<%=raw @plot.data %> | ||
<br> | ||
<b>Options</b> | ||
<%=raw @plot.options %> | ||
<br> | ||
<b>Chart : </b> | ||
<br> | ||
<%=raw @plot.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
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 ChartEditorControllerTest < ActionDispatch::IntegrationTest | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |