Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/App_Code/ChartHelper.cshtml @ 9646

Last change on this file since 9646 was 9646, checked in by pfleck, 11 years ago

#2063:
Changed year in headers from 2012 to 2013.
Minor reformattings in chart helpers.
Refactored and simplified some statistics generator methods.

File size: 3.6 KB
Line 
1@* HeuristicLab
2 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
3 *
4 * This file is part of HeuristicLab.
5 *
6 * HeuristicLab is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * HeuristicLab is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
18 *@
19
20@helper AjaxDataRenderer() {
21    <script>
22        var ajaxDataRenderer = function (url, plot, options) {
23            var ret = null;
24            $.ajax({
25                async: false,
26                url: url,
27                dataType: "json",
28                success: function (data) {
29                    ret = data;
30                }
31            });
32            return ret;
33        };
34    </script>
35}
36
37@helper LineChartTime(string destinationTag, string url, string title = "", double? minY = null, double? maxY = null, string axisYFormat = null) {
38    <script>
39        var @(destinationTag)Plot = $.jqplot("@destinationTag", "@url", {
40            title: "@title",
41            highlighter: {
42                show: true,
43                sizeAdjust: 7.5
44            },
45            seriesDefaults: {
46                markerOptions: { show: false }
47            },
48            dataRenderer: ajaxDataRenderer,
49            axes: {
50                xaxis: {
51                    renderer: $.jqplot.DateAxisRenderer,
52                    pad: 0
53                },
54                yaxis: {
55                    tickOptions: {
56                        @if (axisYFormat != null) {
57                            @:formatString: "@axisYFormat",
58                        }
59                    },
60                    @if (minY != null) {
61                        @:min: @minY,
62                    }
63                    @if (maxY != null) {
64                        @:max: @maxY,
65                    }
66                    pad: 0,
67                    autoscale: true
68                },
69            },
70            gridPadding: { left: 50, right: 10 },
71            cursor: {
72                show: true,
73                showTooltip: false,
74                zoom: true,
75                clickReset: false,
76                dblClickReset: false,
77                constrainZoomTo: 'x'
78            }
79        });
80       
81        @(destinationTag)Plot.replot({ resetAxes: true });
82       
83        $('#@destinationTag').contextmenu(function() {
84            @(destinationTag)Plot.resetZoom();
85            @(destinationTag)Plot.replot({ resetAxes: true });
86            return false;
87        });
88       
89        $(window).resize(function() {
90            @(destinationTag)Plot.replot({ resetAxes: true });
91        });
92    </script>
93}
94
95@helper RefreshChart(string destinationTag, string url, string startDateVar, string endDateVar) {
96    <text>
97    $.ajax({url: "@(new HtmlString(url))?start=" + @startDateVar + "&end=" + @endDateVar, datatype: "json", success: function(result) {
98        for (var i = 0; i < result.length; i++) {
99            @(destinationTag)Plot.series[i].data = result[i];
100        }
101        @(destinationTag)Plot.replot({ resetAxes: true })
102    }});
103    </text>
104}
Note: See TracBrowser for help on using the repository browser.