New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sinatra examples #15

Merged
merged 5 commits into from Jul 28, 2018
File filter...
Filter file types
Jump to file or symbol
Failed to load files and symbols.
+100 −0
Diff settings

Always

Just for now

Sinatra examples for importing data from google spreadsheet

  • Loading branch information...
Prakriti-nith committed Jul 28, 2018
commit dfddd1479a0fdc558b7383826fe3be85005a1c8a
Copy path View file
@@ -157,6 +157,28 @@ def googlecharts_example
@table.table, type: :pie, is3D: true, adapter: :googlecharts, height: 500, width: 800)
@geochart = Daru::View::Plot.new(
@table.table, type: :geo, adapter: :googlecharts, height: 500, width: 800)

data_customers = 'https://docs.google.com/spreadsheets/d/1aXns2ch8y_rl9ZLxSYZIU5ewUB1ZNAg5O6iPLZLApZI/gviz/tq?header=1&tq='
query_customers = 'SELECT * WHERE A > 1'
data_customers << query_customers
@customers_table = Daru::View::Table.new(data_customers, adapter: :googlecharts)
@customers_chart = Daru::View::Plot.new(data_customers, {type: :line, adapter: :googlecharts})

query_products = 'SELECT A, H, O, Q, R, U LIMIT 5 OFFSET 8'
products = 'https://docs.google.com/spreadsheets/d/1XWJLkAwch5GXAt_7zOFDcg8Wm8' \
'Xv29_8PWuuW15qmAE/gviz/tq?gid=0&headers=1&tq='
products << query_products
column_chart_options = {
width: 600,
type: :column,
adapter: :googlecharts
}
table_options = {
adapter: :googlecharts,
showRowNumber: true
}
@products_table = Daru::View::Table.new(products, table_options)
@column_chart = Daru::View::Plot.new(products, column_chart_options)
end

def datatables_examples
@@ -28,4 +28,82 @@
</p>
<br>

<br>

<h3> Importing Data from Google spreadsheet - 1 </h3>
<p>
<b>Data: </b>
<%= @customers_table.data %>
<br>
<b>Options</b>
<%= @customers_table.options %>
<br>
<b>JavaScript Generated: </b>
<br> &ensp;function d() {
<br> &emsp;var query = new google.visualization.Query('https://docs.google.com/spreadsheets/d/1aXns2ch8y_rl9ZLxSYZIU5ewUB1ZNAg5O6iPLZLApZI/gviz/tq?header=1&tq=SELECT * WHERE A > 1');
<br> &emsp;query.send(handleQueryResponse);
<br> &ensp;}
<br> &ensp;function handleQueryResponse(response) {
<br> &emsp;var data_table = response.getDataTable();
<br> &emsp;var table = new google.visualization.Table(document.getElementById('id'));
<br> &emsp;table.d(data_table, {});
<br> &ensp;};
<br>
<b>Table : </b>
<br>
<%= @customers_table.div %>
</p>
<br>

<h3> Importing Data from Google spreadsheet - 1 </h3>
<p>
<b>Data: </b>
<%= @customers_chart.data %>
<br>
<b>Options</b>
<%= @customers_chart.options %>
<br>
<b>JavaScript Generated: </b>
<br> &ensp;function d() {
<br> &emsp;var query = new google.visualization.Query('https://docs.google.com/spreadsheets/d/1aXns2ch8y_rl9ZLxSYZIU5ewUB1ZNAg5O6iPLZLApZI/gviz/tq?header=1&tq=SELECT * WHERE A > 1');
<br> &emsp;query.send(handleQueryResponse);
<br> &ensp;}
<br> &ensp;function handleQueryResponse(response) {
<br> &emsp;var data_table = response.getDataTable();
<br> &emsp;var table = new google.visualization.LineChart(document.getElementById('id'));
<br> &emsp;table.d(data_table, {});
<br> &ensp;};
<br>
<b>Chart : </b>
<br>
<%= @customers_chart.div %>
</p>
<br>

<h3> Importing Data from Google spreadsheet - 2 </h3>
<p>
<b>Data: </b>
<%= @products_table.data %>
<br>
<b>Options</b>
<%= @products_table.options %>
<br>
<b>Table : </b>
<br>
<%= @products_table.div %>
</p>
<br>

<h3> Importing Data from Google spreadsheet - 2 </h3>
<p>
<b>Data: </b>
<%= @column_chart.data %>
<br>
<b>Options</b>
<%= @column_chart.options %>
<br>
<b>Chart : </b>
<br>
<%= @column_chart.div %>
</p>
<br>
ProTip! Use n and p to navigate between commits in a pull request.