summaryrefslogtreecommitdiff
path: root/web/views/reports/characters_in_keys.erb
blob: 23db20c105bd021a57e6e730e63f9d214afc4c29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<div class="pre">
    <h1><%= t.reports.characters_in_keys.name %></h1>
    <%= t.reports.characters_in_keys.intro %>
</div>
<div id="tabs">
    <ul>
        <li><a href="#statistics"><%= t.reports.characters_in_keys.statistics.tab %></a></li>
        <li><a href="#whitespace"><span style="background-color: #d62727;">&nbsp;&nbsp;&nbsp;</span> <%= t.reports.characters_in_keys.whitespace.tab %></a></li>
        <li><a href="#problematic"><span style="background-color: #ff9896;">&nbsp;&nbsp;&nbsp;</span> <%= t.reports.characters_in_keys.problematic.tab %></a></li>
    </ul>
    <div id="statistics">
        <h2><%= t.reports.characters_in_keys.statistics.title %></h2>
        <div class="canvas boxpre" id="canvas" style="margin-bottom: 20px;"></div>
        <table class="list">
            <tr>
                <th>&nbsp;</th>
                <th class="tr"><%= t.misc.count %></th>
                <th class="tr"><%= t.reports.characters_in_keys.statistics.fraction %></th>
                <th class="tl"><%= t.reports.characters_in_keys.statistics.characters %></th>
            </tr>
<% letter='A'
   colors = { :A => '#2ca02c', :B => '#98df8a', :C => '#dbdb8d', :D => '#d62728', :E => '#ff9896', :F => '#aec7e8' }
   %w(plain colon letters space problem rest).each_with_index do |type, n| c = (n%2!=0) ? ' even' : '' %>
            <tr>
                <td class="tc<%= c %>" style="background-color: <%= colors[letter.to_sym] %>;"><%= letter %></td>
                <td class="tr<%= c %>"><%= @db.stats('characters_in_keys_' + type) %></td>
                <td class="tr<%= c %>"><%= sprintf '%.2f', @db.stats('characters_in_keys_' + type) * 100.0 / @db.stats('num_keys') %>%</td>
                <td class="tl<%= c %>"><%= t.reports.characters_in_keys.statistics.characters_in_keys[type] %></td>
            </tr>
<% letter = letter.succ; end %>
            <tr>
                <td class="tc" style="border-top: 1px solid #000000;"></td>
                <td class="tr" style="border-top: 1px solid #000000;"><%= @db.stats('num_keys') %></td>
                <td class="tr" style="border-top: 1px solid #000000;">100%</td>
                <td class="tl" style="border-top: 1px solid #000000;">Total</td>
            </tr>
        </table>
    </div>
    <div id="whitespace">
        <h2><%= t.reports.characters_in_keys.whitespace.title %></h2>
        <div class="boxpre">
            <%= t.reports.characters_in_keys.whitespace.intro %>
        </div>
        <table id="grid-whitespace">
        </table>
    </div>
    <div id="problematic">
        <h2><%= t.reports.characters_in_keys.problematic.title %></h2>
        <div class="boxpre">
            <%= t.reports.characters_in_keys.problematic.intro %>
        </div>
        <table id="grid-problematic">
        </table>
    </div>
</div>

<% javascript do
    JS.raw(<<"JAVASCRIPT")
function page_init2() {
    init_tabs('reports.characters_in_keys', []);

    var data = #{ i = '@'; %w(plain colon letters space problem rest).map{ |type| i=i.next; [ { :label => i, :value => @db.stats('characters_in_keys_' + type) } ] }.to_json() };

    var w=968, h=50;

    var vis = new pv.Panel()
        .canvas('canvas')
        .width(w + 20)
        .height(h);

    var colors = #{ colors.to_json };

    var scale = pv.Scale.linear(0, #{ @db.stats('num_keys') }).range(0, w);

    vis.add(pv.Layout.Stack)
        .orient('left-top')
        .left(10)
        .layers(data)
        .x(10)
        .y(function(d) { return scale(d.value); })
    .layer.add(pv.Bar)
        .fillStyle(function(d) { return colors[d.label]; })
        .height(20)
    .anchor('bottom')
        .add(pv.Label)
        .font('12px Arial,sans-serif')
        .top(46)
        .text(function(d) { return d.label; });

    vis.render();
}
JAVASCRIPT
end
%>
<% javascript "#{ r18n.locale.code }/reports/characters_in_keys" %>