<commit_before>﻿@using Domain.Model.Entities
@using Telerik.Web.Mvc.UI
@using Wotstat.Application.Boilerplate.Extensions.Web
@using Wotstat.Application.Statistics.ViewModels
@model StatisticsViewModel
@{
    var periods = ((IEnumerable<Period>) ViewBag.Periods).ToList();
    var graphPeriods = ((IEnumerable<SelectListItem>) ViewBag.GraphicPeriods).ToList();
}          
<h2>Статистика</h2>          
<table class="table-bordered table">
    <thead>
        <tr>
            <th></th>
            <th>Текущее значение</th>
            @foreach (var period in periods)
            {
                <th>@period.Name</th>
            }
        </tr>
    </thead>
    <tbody>
        @if (Model != null)
        {
            <tr>
                <td>
                    Процент попаданий
                </td>
                <td>@Model.LastStatistic.HitsPercents.ToString("0.00")</td>
                @Html.DynamicDataTableRow(Model.Dynamic, periods, x => x.HitsPercents.ToString("0.00"))
            </tr>
            <tr>
                <td>
                    Уничтожено техники
                </td>
                <td>@Model.LastStatistic.Frags</td>
                @Html.DynamicDataTableRow(Model.Dynamic, periods, x => x.Frags)
            </tr>
            <tr>
                <td>
                    Средний опыт за бой
                </td>
                <td>@Model.LastStatistic.BattleAvgXp</td>
                @Html.DynamicDataTableRow(Model.Dynamic, periods, x => x.BattleAvgXp)
            </tr>
            <tr>
                <td>
                    Процент побед
                </td>
                <td>@Model.LastStatistic.WinsPercents.ToString("0.00")</td>
                @Html.DynamicDataTableRow(Model.Dynamic, periods, x => x.WinsPercents.ToString("0.00"))
            </tr>
            <tr>
                <td>
                    Проведено боёв
                </td>
                <td>@Model.LastStatistic.Battles</td>
                @Html.DynamicDataTableRow(Model.Dynamic, periods, x => x.Battles)
            </tr>
            <tr>
                <td>
                    Нанесено повреждений
                </td>
                <td>@Model.LastStatistic.DamageDealt</td>
                @Html.DynamicDataTableRow(Model.Dynamic, periods, x => x.DamageDealt)
            </tr>
            <tr>
                <td>
                    Максимальный опыт за бой
                </td>
                <td>@Model.LastStatistic.MaxXp</td>
                @Html.DynamicDataTableRow(Model.Dynamic, periods, x => x.MaxXp)
            </tr>
        }
    </tbody>
</table>

@Html.DropDownList("graphic-period-selection", graphPeriods)

<button class="t-button" onclick="rebind()">Показать</button>

@(Html.Telerik().Chart<StatisticItemData>()
              .DataBinding(dataBinding => dataBinding.Ajax().Select("GraphicDate", "Statistic"))
      .Name("Chart")
       .Series(series => series.ScatterLine(x=>x.DateTicks, x=>x.Value))
      .YAxis(y => y.Numeric().Title("Значение"))
          .XAxis(x => x.Numeric().Title("Дата").Labels(y => y.Template("<#= test(value) #>"))))
      
@section scripts{
    <script type="text/javascript">

        function getChart() {
            return $("#Chart").data("tChart");
        }

        function rebind() {
            var val = $('#graphic-period-selection option:selected').val();
            getChart().rebind({ propertyIndex: val });
        }

        function test(ticks) {
            var date = new Date(ticks*1000);
            return to2DigitFormat(date.getDay()) + "." + to2DigitFormat(date.getMonth()+1) + "." + date.getFullYear();
        }

        function to2DigitFormat(value) {
            value += "";
            if (value.length == 1) value = "0" + value;
            return value;
        }

    </script>
}<commit_msg>add tooltips to chart<commit_after>﻿@using Domain.Model.Entities
@using Telerik.Web.Mvc.UI
@using Wotstat.Application.Boilerplate.Extensions.Web
@using Wotstat.Application.Statistics.ViewModels
@model StatisticsViewModel
@{
    var periods = ((IEnumerable<Period>) ViewBag.Periods).ToList();
    var graphPeriods = ((IEnumerable<SelectListItem>) ViewBag.GraphicPeriods).ToList();
}          
<h2>Статистика</h2>          
<table class="table-bordered table">
    <thead>
        <tr>
            <th></th>
            <th>Текущее значение</th>
            @foreach (var period in periods)
            {
                <th>@period.Name</th>
            }
        </tr>
    </thead>
    <tbody>
        @if (Model != null)
        {
            <tr>
                <td>
                    Процент попаданий
                </td>
                <td>@Model.LastStatistic.HitsPercents.ToString("0.00")</td>
                @Html.DynamicDataTableRow(Model.Dynamic, periods, x => x.HitsPercents.ToString("0.00"))
            </tr>
            <tr>
                <td>
                    Уничтожено техники
                </td>
                <td>@Model.LastStatistic.Frags</td>
                @Html.DynamicDataTableRow(Model.Dynamic, periods, x => x.Frags)
            </tr>
            <tr>
                <td>
                    Средний опыт за бой
                </td>
                <td>@Model.LastStatistic.BattleAvgXp</td>
                @Html.DynamicDataTableRow(Model.Dynamic, periods, x => x.BattleAvgXp)
            </tr>
            <tr>
                <td>
                    Процент побед
                </td>
                <td>@Model.LastStatistic.WinsPercents.ToString("0.00")</td>
                @Html.DynamicDataTableRow(Model.Dynamic, periods, x => x.WinsPercents.ToString("0.00"))
            </tr>
            <tr>
                <td>
                    Проведено боёв
                </td>
                <td>@Model.LastStatistic.Battles</td>
                @Html.DynamicDataTableRow(Model.Dynamic, periods, x => x.Battles)
            </tr>
            <tr>
                <td>
                    Нанесено повреждений
                </td>
                <td>@Model.LastStatistic.DamageDealt</td>
                @Html.DynamicDataTableRow(Model.Dynamic, periods, x => x.DamageDealt)
            </tr>
            <tr>
                <td>
                    Максимальный опыт за бой
                </td>
                <td>@Model.LastStatistic.MaxXp</td>
                @Html.DynamicDataTableRow(Model.Dynamic, periods, x => x.MaxXp)
            </tr>
        }
    </tbody>
</table>

@Html.DropDownList("graphic-period-selection", graphPeriods)

<button class="t-button" onclick="rebind()">Показать</button>

@(Html.Telerik().Chart<StatisticItemData>()
              .DataBinding(dataBinding => dataBinding.Ajax().Select("GraphicDate", "Statistic"))
      .Name("Chart")
           .Series(series => series.ScatterLine(x => x.DateTicks, x => x.Value)
                        .Tooltip(tooltip => tooltip.Template("<#= currentStatisticDataCaption  + ': ' + value.y + ' (дата: ' + unixToDate(value.x) + ')' #>")))

      .YAxis(y => y.Numeric().Title("Значение"))
          .XAxis(x => x.Numeric().Title("Дата").Labels(y => y.Template("<#= unixToDate(value) #>")))
      .Tooltip(true).Legend(false))
      
@section scripts{
    <script type="text/javascript">
        var currentStatisticDataCaption = $('#graphic-period-selection option:selected').text();

        function getChart() {
            return $("#Chart").data("tChart");
        }

        function rebind() {
            var selected = $('#graphic-period-selection option:selected');
            var val = selected.val();
            currentStatisticDataCaption = selected.text();
            getChart().rebind({ propertyIndex: val });
        }

        function unixToDate(ticks) {
            var date = new Date(ticks*1000);
            return to2DigitFormat(date.getDate()) + "." + to2DigitFormat(date.getMonth()+1) + "." + date.getFullYear();
        }

        function to2DigitFormat(value) {
            value += "";
            if (value.length == 1) value = "0" + value;
            return value;
        }

    </script>
}
{'fraction_non_alphanumeric': 0.143317230273752, 'fraction_numerical': 0.005945745076179859, 'mean_word_length': 1.6036762334730732, 'pattern_counts': {'":': 0, '<': 136, '<?xml version=': 0, '>': 165, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7381893', 'n_tokens_mistral': 2508, 'n_tokens_neox': 2455, 'n_words': 381}