forked from SciRuby/daru
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
html table code of DataFrame and Vector are modified (SciRuby#366)
* table id is added in table html code * separating thead and tbody * methods for accessing thead and tbody * working tbody and thead script in datatables gem * modified some testcases * rubocop errors fixed * vector html table code modified and used thead and tbody tag
- Loading branch information
1 parent
e43ee55
commit b6839c7
Showing
17 changed files
with
263 additions
and
214 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
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 |
---|---|---|
@@ -1,52 +1,5 @@ | ||
<b> Daru::DataFrame<%= name ? ": #{name} " : ''%>(<%=nrows%>x<%=ncols%>) </b> | ||
<table> | ||
<tr> | ||
<th colspan='<%= @vectors.size+1 %>'>Daru::DataFrame<%= name ? ": #{name} " : ''%>(<%=nrows%>x<%=ncols%>)</th> | ||
</tr> | ||
|
||
<% if @vectors.is_a? MultiIndex %> | ||
<% Daru::IRuby::Helpers.tuples_with_colspans(@vectors).each_with_index do |tuple, idx| %> | ||
<tr> | ||
<% if idx.zero? %> | ||
<th rowspan="<%= @vectors.width %>"></th> | ||
<% end %> | ||
<% tuple.each do |idx, span| %> | ||
<th colspan="<%= span %>"><%= idx %></th> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
<% else %> | ||
<tr> | ||
<th></th> | ||
<% @vectors.each do |vector| %> | ||
<th><%=vector%></th> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
<% @index.first(threshold).each_with_index do |index, pos| %> | ||
<tr> | ||
<td><%= index %></td> | ||
<% row.at(pos).each do |element| %> | ||
<td><%= element.to_s %></td> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
<% if nrows > threshold %> | ||
<tr> | ||
<% (@vectors.size + 1).times do %> | ||
<td>...</td> | ||
<% end %> | ||
</tr> | ||
|
||
<% last_index = @index.to_a.last | ||
last_row = row_at @index.size-1 %> | ||
|
||
<tr> | ||
<td><%= last_index %></td> | ||
<% last_row.each do |element| %> | ||
<td><%= element.to_s %></td> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
<%= table_thead %> | ||
<%= table_tbody %> | ||
</table> |
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 |
---|---|---|
@@ -1,58 +1,5 @@ | ||
<b> Daru::DataFrame<%= name ? ": #{name} " : ''%>(<%=nrows%>x<%=ncols%>) </b> | ||
<table> | ||
<tr> | ||
<th colspan='<%= @vectors.size+index.width %>'>Daru::DataFrame<%= name ? ": #{name} " : ''%>(<%=nrows%>x<%=ncols%>)</th> | ||
</tr> | ||
<% if @vectors.is_a? MultiIndex %> | ||
<% Daru::IRuby::Helpers.tuples_with_colspans(@vectors).each_with_index do |tuple, idx| %> | ||
<tr> | ||
<% if idx.zero? %> | ||
<th colspan="<%= index.width %>" rowspan="<%= @vectors.width %>"></th> | ||
<% end %> | ||
<% tuple.each do |idx, span| %> | ||
<th colspan="<%= span %>"><%= idx %></th> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
<% else %> | ||
<tr> | ||
<th colspan="<%= index.width %>"></th> | ||
<% @vectors.each do |vector| %> | ||
<th><%=vector%></th> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
<% Daru::IRuby::Helpers.tuples_with_rowspans(@index).first(threshold).zip(@index.to_a).each do |tuple, index| %> | ||
<tr> | ||
<% tuple.each do |idx, span| %> | ||
<th rowspan="<%= span %>"><%= idx %></th> | ||
<% end %> | ||
<% row[index].each do |element| %> | ||
<td><%= element.to_s %></td> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
<% if nrows > threshold %> | ||
<tr> | ||
<% index.width.times do %> | ||
<th>...</th> | ||
<% end %> | ||
<% @vectors.size.times do %> | ||
<td>...</td> | ||
<% end %> | ||
</tr> | ||
|
||
<% last_index = @index.to_a.last | ||
last_row = row[last_index] %> | ||
|
||
<tr> | ||
<% last_index.each do |idx| %> | ||
<th><%= idx %></td> | ||
<% end %> | ||
<% last_row.each do |element| %> | ||
<td><%= element.to_s %></td> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
<%= table_thead %> | ||
<%= table_tbody %> | ||
</table> |
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 @@ | ||
<tbody> | ||
<% Daru::IRuby::Helpers.tuples_with_rowspans(@index).first(threshold).zip(@index.to_a).each do |tuple, index| %> | ||
<tr> | ||
<% tuple.each do |idx, span| %> | ||
<th rowspan="<%= span %>"><%= idx %></th> | ||
<% end %> | ||
<% row[index].each do |element| %> | ||
<td><%= element.to_s %></td> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
<% if nrows > threshold %> | ||
<tr> | ||
<% index.width.times do %> | ||
<th>...</th> | ||
<% end %> | ||
<% @vectors.size.times do %> | ||
<td>...</td> | ||
<% end %> | ||
</tr> | ||
|
||
<% last_index = @index.to_a.last | ||
last_row = row[last_index] %> | ||
|
||
<tr> | ||
<% last_index.each do |idx| %> | ||
<th><%= idx %></td> | ||
<% end %> | ||
<% last_row.each do |element| %> | ||
<td><%= element.to_s %></td> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
</tbody> |
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,21 @@ | ||
<thead> | ||
<% if @vectors.is_a? MultiIndex %> | ||
<% Daru::IRuby::Helpers.tuples_with_colspans(@vectors).each_with_index do |tuple, idx| %> | ||
<tr> | ||
<% if idx.zero? %> | ||
<th colspan="<%= index.width %>" rowspan="<%= @vectors.width %>"></th> | ||
<% end %> | ||
<% tuple.each do |idx, span| %> | ||
<th colspan="<%= span %>"><%= idx %></th> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
<% else %> | ||
<tr> | ||
<th colspan="<%= index.width %>"></th> | ||
<% @vectors.each do |vector| %> | ||
<th><%=vector%></th> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
</thead> |
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,28 @@ | ||
<tbody> | ||
<% @index.first(threshold).each_with_index do |index, pos| %> | ||
<tr> | ||
<td><%= index %></td> | ||
<% row.at(pos).each do |element| %> | ||
<td><%= element.to_s %></td> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
<% if nrows > threshold %> | ||
<tr> | ||
<% (@vectors.size + 1).times do %> | ||
<td>...</td> | ||
<% end %> | ||
</tr> | ||
|
||
<% last_index = @index.to_a.last | ||
last_row = row_at @index.size-1 %> | ||
|
||
<tr> | ||
<td><%= last_index %></td> | ||
<% last_row.each do |element| %> | ||
<td><%= element.to_s %></td> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
</tbody> |
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,21 @@ | ||
<thead> | ||
<% if @vectors.is_a? MultiIndex %> | ||
<% Daru::IRuby::Helpers.tuples_with_colspans(@vectors).each_with_index do |tuple, idx| %> | ||
<tr> | ||
<% if idx.zero? %> | ||
<th rowspan="<%= @vectors.width %>"></th> | ||
<% end %> | ||
<% tuple.each do |idx, span| %> | ||
<th colspan="<%= span %>"><%= idx %></th> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
<% else %> | ||
<tr> | ||
<th></th> | ||
<% @vectors.each do |vector| %> | ||
<th><%=vector%></th> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
</thead> |
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 |
---|---|---|
@@ -1,27 +1,5 @@ | ||
<b> Daru::Vector(<%= size %>)<%= ':category' if category? %> </b> | ||
<table> | ||
<tr> | ||
<th colspan="2">Daru::Vector(<%= size %>)<%= ':category' if category? %></th> | ||
</tr> | ||
<% if name %> | ||
<tr> | ||
<th> </th> | ||
<th><%= name %></th> | ||
</tr> | ||
<% end %> | ||
<% @index.each_with_index.first(threshold).each do |index, pos| %> | ||
<tr> | ||
<td><%= index %></td> | ||
<td><%= self.at(pos) %></td> | ||
</tr> | ||
<% end %> | ||
<% if size > threshold %> | ||
<% last_index = @index.size-1 %> | ||
<tr><td>...</td><td>...</td></tr> | ||
<tr> | ||
<td><%= last_index %></td> | ||
<td><%= self.at last_index %></td> | ||
</tr> | ||
<% end %> | ||
<%= table_thead %> | ||
<%= table_tbody %> | ||
</table> |
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 |
---|---|---|
@@ -1,36 +1,5 @@ | ||
<b> Daru::Vector(<%= size %>)<%= ':category' if category? %> </b> | ||
<table> | ||
<tr> | ||
<th colspan="<%= index.width+1 %>">Daru::Vector(<%= size %>)<%= ':category' if category? %></th> | ||
</tr> | ||
<% if name %> | ||
<tr> | ||
<th colspan="<%= index.width %>"> </th> | ||
<th><%= name %></th> | ||
</tr> | ||
<% end %> | ||
<% Daru::IRuby::Helpers.tuples_with_rowspans(@index).first(threshold).zip(to_a).each do |tuple, value| %> | ||
<tr> | ||
<% tuple.each do |idx, span| %> | ||
<th rowspan="<%= span %>"><%= idx %></th> | ||
<% end %> | ||
<td><%= value %></td> | ||
</tr> | ||
<% end %> | ||
<% if size > threshold %> | ||
<% last_index = @index.to_a.last %> | ||
<tr> | ||
<% last_index.size.times do %> | ||
<th>...</th> | ||
<% end %> | ||
<td>...</td> | ||
</tr> | ||
<tr> | ||
<% last_index.each do |idx| %> | ||
<th><%= idx %></td> | ||
<% end %> | ||
<td><%= self[last_index] %></td> | ||
</tr> | ||
<% end %> | ||
<%= table_thead %> | ||
<%= table_tbody %> | ||
</table> |
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 @@ | ||
<tbody> | ||
<% Daru::IRuby::Helpers.tuples_with_rowspans(@index).first(threshold).zip(to_a).each do |tuple, value| %> | ||
<tr> | ||
<% tuple.each do |idx, span| %> | ||
<th rowspan="<%= span %>"><%= idx %></th> | ||
<% end %> | ||
<td><%= value %></td> | ||
</tr> | ||
<% end %> | ||
<% if size > threshold %> | ||
<% last_index = @index.to_a.last %> | ||
<tr> | ||
<% last_index.size.times do %> | ||
<th>...</th> | ||
<% end %> | ||
<td>...</td> | ||
</tr> | ||
<tr> | ||
<% last_index.each do |idx| %> | ||
<th><%= idx %></td> | ||
<% end %> | ||
<td><%= self[last_index] %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> |
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,8 @@ | ||
<thead> | ||
<% if name %> | ||
<tr> | ||
<th colspan="<%= index.width %>"> </th> | ||
<th><%= name %></th> | ||
</tr> | ||
<% end %> | ||
</thead> |
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,17 @@ | ||
<tbody> | ||
<% @index.each_with_index.first(threshold).each do |index, pos| %> | ||
<tr> | ||
<td><%= index %></td> | ||
<td><%= self.at(pos) %></td> | ||
</tr> | ||
<% end %> | ||
<% if size > threshold %> | ||
<% last_index = @index.size-1 %> | ||
<tr><td>...</td><td>...</td></tr> | ||
<tr> | ||
<td><%= last_index %></td> | ||
<td><%= self.at last_index %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> |
Oops, something went wrong.