<commit_before><%--
  #%L
  Bitrepository Webclient
  %%
  Copyright (C) 2010 - 2013 The State and University Library, The Royal Library and The State Archives, Denmark
  %%
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Lesser General Public License as 
  published by the Free Software Foundation, either version 2.1 of the 
  License, or (at your option) any later version.
  
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Lesser Public License for more details.
  
  You should have received a copy of the GNU General Lesser Public 
  License along with this program.  If not, see
  <http://www.gnu.org/licenses/lgpl-2.1.html>.
  #L%
  --%>
<%@page pageEncoding="UTF-8"%>

<%
    long UTC_FIX = DashboardServlet.getTimeZoneOffSetInMillis(); //Because javascript-time is local in browser. This fix makes it work in Denmark summer and winter time
    ArrayList<ArrayList<StatisticsDataSize>> allDataSizeList = (  ArrayList<ArrayList<StatisticsDataSize>> ) request.getAttribute(DashboardServlet.DATA_SIZE_HISTORY_ATTRIBUTE);
    ArrayList<String> allDataSizeIdList = (  ArrayList<String> ) request.getAttribute(DashboardServlet.DATA_SIZE_HISTORY_ID_ATTRIBUTE);

    String graphType = (String) request.getAttribute(DashboardServlet.GRAPH_TYPE_ATTRIBUTE);

    if (allDataSizeList == null){
        allDataSizeList = new ArrayList<ArrayList<StatisticsDataSize>>();
    }
    if (allDataSizeIdList == null){
        allDataSizeIdList = new ArrayList<String>();
    }

    HashMap<String,String> collectionId2NameMap = DashboardDataCache.getCollectionId2NameMap();
    HashMap<String, String> collectionId2ColorMap = DashboardDataCache.getCollectionId2ColorMap();
    long maxByteSize=DashboardServlet.getMaximumByteSize(allDataSizeList);
    String byteUnitSuffix =FileSizeUtils.toHumanUnit(maxByteSize);
    float byteUnit = FileSizeUtils.getByteSize(byteUnitSuffix);

    String y_axis_text=byteUnitSuffix.trim();
    if ("graph_tilvaekst".equals(graphType)){
        y_axis_text = byteUnitSuffix.trim();
    }
    else if ("graph_delta".equals(graphType)){
        y_axis_text = byteUnitSuffix.trim()+" pr. dag";
    }


%>

<style type="text/css">
    #placeholder .button {
        position: absolute;
        cursor: pointer;
    }
    #placeholder div.button {
        font-size: smaller;
        color: #999;
        background-color: #eee;
        padding: 2px;
    }
    #placeholder .button:hover {
        border-top-color: #28597a;
        background: #28597a;
        color: #ccc;
    }

</style>

<script>
    function changeData(){
        document.dashboardForm.submit();
    }
</script>

<script>
    function dateFormat(formattedDate) {

        var d = formattedDate.getDate();
        var m = formattedDate.getMonth()+1; //Javascript getMonths() returns 0 - 11.
        var y = formattedDate.getFullYear();
        var minutes = formattedDate.getMinutes();
        var hour = formattedDate.getHours();

        if (m <10){m = "0"+m}
        if (d <10){d = "0"+d}
        if (hour <10){hour = "0"+hour}
        if (minutes <10){minutes = "0"+minutes}

        return y + "/" + m +"/"+d +" " +hour+":"+minutes;
    }
</script>



<form name="dashboardForm" action="dashboardServlet" method="POST" class="dashboardForm">

        <select name="graphType" onchange="javascript:changeData();">
            <option <%if ("graph_tilvaekst".equals(graphType)){ out.println(" selected "); }%> value="graph_tilvaekst">Tilvækst</option>
            <option <%if ("graph_delta".equals(graphType)){ out.println(" selected "); }%> value="graph_delta">Tilvækstændring</option>
        </select>

        <%
            for ( String id : collectionId2NameMap.keySet()){
        %>
        <div class="collectionCheckBoxes"><input type="checkbox" onClick="javascript:changeData();"  <%if(request.getAttribute(id) != null){out.println("checked");}%> name="<%=id%>"> <div class="checkboxLegendWrap"><div class="checkboxLegend" style="background-color: <%=collectionId2ColorMap.get(id)%> "></div></div> <%=collectionId2NameMap.get(id)%> </div>
        <%
            }
        %>
</form>

<script>
    <%
     for (int i = 0; i< allDataSizeList.size();i++){
       ArrayList<StatisticsDataSize> dataSizeList =allDataSizeList.get(i);
     %>

    var data_tilvaekst<%=i%> = [
        <%
        for (int j = 0 ;j <dataSizeList.size();j++){
          StatisticsDataSize current = dataSizeList.get(j);%>
        [<%=(current.getDateMillis()+UTC_FIX)%> ,  <%=current.getDataSize()/byteUnit%> ],
        <%}%>
    ];

    <%}%>
    var options = {
        hoverable: true,
      
        legend:{        
            backgroundOpacity: 0.5,
            noColumns: 5,  
            position: "nw"
        }, 

        grid:  {
            hoverable: true,
            borderColor: "#cccccc"

        },
        xaxis: {  mode: "time",  localTimezone: true , zoomRange: [0.1, 10] , timeformat: "%y/%0m/%0d %0H:%0M"},
        yaxis: {  axisLabel: "<%=y_axis_text%>"},
        selection:{  mode: "xy" } ,
        points: { show: true ,  radius: 2} ,
        lines: { show: true},
        zoom: { interactive: true}
    };


    var dataObj = [
        <%
         for (int i = 0; i< allDataSizeIdList.size();i++){
         String currentId = allDataSizeIdList.get(i);
         %>

        {label:"<%=collectionId2NameMap.get(currentId)%> (<%=y_axis_text%>)", data: data_tilvaekst<%=i%> , color: '<%=collectionId2ColorMap.get(currentId)%>'},
        
        <%}%>
    ];

    $.fn.UseRange = function (plot) {
        $(this).bind("plotselected", function (event,ranges) {
            // do the zooming
            plot = $.plot($("#placeholder"), dataObj,
                    $.extend(true, {}, options, {   xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to }
                        ,   yaxis: { min: ranges.yaxis.from, max: ranges.yaxis.to }
                    }));
        });
    };<commit_msg>Dashboard:mindre punkt-størrelse. Ingen huller i punkter<commit_after><%--
  #%L
  Bitrepository Webclient
  %%
  Copyright (C) 2010 - 2013 The State and University Library, The Royal Library and The State Archives, Denmark
  %%
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Lesser General Public License as 
  published by the Free Software Foundation, either version 2.1 of the 
  License, or (at your option) any later version.
  
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Lesser Public License for more details.
  
  You should have received a copy of the GNU General Lesser Public 
  License along with this program.  If not, see
  <http://www.gnu.org/licenses/lgpl-2.1.html>.
  #L%
  --%>
<%@page pageEncoding="UTF-8"%>

<%
    long UTC_FIX = DashboardServlet.getTimeZoneOffSetInMillis(); //Because javascript-time is local in browser. This fix makes it work in Denmark summer and winter time
    ArrayList<ArrayList<StatisticsDataSize>> allDataSizeList = (  ArrayList<ArrayList<StatisticsDataSize>> ) request.getAttribute(DashboardServlet.DATA_SIZE_HISTORY_ATTRIBUTE);
    ArrayList<String> allDataSizeIdList = (  ArrayList<String> ) request.getAttribute(DashboardServlet.DATA_SIZE_HISTORY_ID_ATTRIBUTE);

    String graphType = (String) request.getAttribute(DashboardServlet.GRAPH_TYPE_ATTRIBUTE);

    if (allDataSizeList == null){
        allDataSizeList = new ArrayList<ArrayList<StatisticsDataSize>>();
    }
    if (allDataSizeIdList == null){
        allDataSizeIdList = new ArrayList<String>();
    }

    HashMap<String,String> collectionId2NameMap = DashboardDataCache.getCollectionId2NameMap();
    HashMap<String, String> collectionId2ColorMap = DashboardDataCache.getCollectionId2ColorMap();
    long maxByteSize=DashboardServlet.getMaximumByteSize(allDataSizeList);
    String byteUnitSuffix =FileSizeUtils.toHumanUnit(maxByteSize);
    float byteUnit = FileSizeUtils.getByteSize(byteUnitSuffix);

    String y_axis_text=byteUnitSuffix.trim();
    if ("graph_tilvaekst".equals(graphType)){
        y_axis_text = byteUnitSuffix.trim();
    }
    else if ("graph_delta".equals(graphType)){
        y_axis_text = byteUnitSuffix.trim()+" pr. dag";
    }


%>

<style type="text/css">
    #placeholder .button {
        position: absolute;
        cursor: pointer;
    }
    #placeholder div.button {
        font-size: smaller;
        color: #999;
        background-color: #eee;
        padding: 2px;
    }
    #placeholder .button:hover {
        border-top-color: #28597a;
        background: #28597a;
        color: #ccc;
    }

</style>

<script>
    function changeData(){
        document.dashboardForm.submit();
    }
</script>

<script>
    function dateFormat(formattedDate) {

        var d = formattedDate.getDate();
        var m = formattedDate.getMonth()+1; //Javascript getMonths() returns 0 - 11.
        var y = formattedDate.getFullYear();
        var minutes = formattedDate.getMinutes();
        var hour = formattedDate.getHours();

        if (m <10){m = "0"+m}
        if (d <10){d = "0"+d}
        if (hour <10){hour = "0"+hour}
        if (minutes <10){minutes = "0"+minutes}

        return y + "/" + m +"/"+d +" " +hour+":"+minutes;
    }
</script>



<form name="dashboardForm" action="dashboardServlet" method="POST" class="dashboardForm">

        <select name="graphType" onchange="javascript:changeData();">
            <option <%if ("graph_tilvaekst".equals(graphType)){ out.println(" selected "); }%> value="graph_tilvaekst">Tilvækst</option>
            <option <%if ("graph_delta".equals(graphType)){ out.println(" selected "); }%> value="graph_delta">Tilvækstændring</option>
        </select>

        <%
            for ( String id : collectionId2NameMap.keySet()){
        %>
        <div class="collectionCheckBoxes"><input type="checkbox" onClick="javascript:changeData();"  <%if(request.getAttribute(id) != null){out.println("checked");}%> name="<%=id%>"> <div class="checkboxLegendWrap"><div class="checkboxLegend" style="background-color: <%=collectionId2ColorMap.get(id)%> "></div></div> <%=collectionId2NameMap.get(id)%> </div>
        <%
            }
        %>
</form>

<script>
    <%
     for (int i = 0; i< allDataSizeList.size();i++){
       ArrayList<StatisticsDataSize> dataSizeList =allDataSizeList.get(i);
     %>

    var data_tilvaekst<%=i%> = [
        <%
        for (int j = 0 ;j <dataSizeList.size();j++){
          StatisticsDataSize current = dataSizeList.get(j);%>
        [<%=(current.getDateMillis()+UTC_FIX)%> ,  <%=current.getDataSize()/byteUnit%> ],
        <%}%>
    ];

    <%}%>
    var options = {
        hoverable: true,
      
        legend:{        
            backgroundOpacity: 0.5,
            noColumns: 5,  
            position: "nw"
        }, 

        grid:  {
            hoverable: true,
            borderColor: "#cccccc"

        },
        xaxis: {  mode: "time",  localTimezone: true , zoomRange: [0.1, 10] , timeformat: "%y/%0m/%0d %0H:%0M"},
        yaxis: {  axisLabel: "<%=y_axis_text%>"},
        selection:{  mode: "xy" } ,
        points: { show: true ,  radius: 1} ,
        lines: { show: true},
        zoom: { interactive: true}
    };


    var dataObj = [
        <%
         for (int i = 0; i< allDataSizeIdList.size();i++){
         String currentId = allDataSizeIdList.get(i);
         %>

        {label:"<%=collectionId2NameMap.get(currentId)%> (<%=y_axis_text%>)", data: data_tilvaekst<%=i%> , color: '<%=collectionId2ColorMap.get(currentId)%>'},
        
        <%}%>
    ];

    $.fn.UseRange = function (plot) {
        $(this).bind("plotselected", function (event,ranges) {
            // do the zooming
            plot = $.plot($("#placeholder"), dataObj,
                    $.extend(true, {}, options, {   xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to }
                        ,   yaxis: { min: ranges.yaxis.from, max: ranges.yaxis.to }
                    }));
        });
    };
{'fraction_non_alphanumeric': 0.14204221334854536, 'fraction_numerical': 0.010920055415206584, 'mean_word_length': 2.871293375394322, 'pattern_counts': {'":': 2, '<': 137, '<?xml version=': 0, '>': 123, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '536908', 'n_tokens_mistral': 3941, 'n_tokens_neox': 3768, 'n_words': 853}