Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 9644 was 9644, checked in by pfleck, 10 years ago

#2063:
Fixed timezone bug in chart data.
Fixed zooming bug in jqplot dateAxisRenderer.
Reformatting.

File size: 3.6 KB
Line 
1@* HeuristicLab
2 * Copyright (C) 2002-2012 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 = "",
38    double? minY = null, double? maxY = null, string axisYFormat = null) {
39       
40    <script>
41        var @(destinationTag)Plot = $.jqplot("@destinationTag", "@url", {
42            title: "@title",
43            highlighter: {
44                show: true,
45                sizeAdjust: 7.5
46            },
47            seriesDefaults: {
48                markerOptions: { show: false },
49                //fill: true
50            },
51            dataRenderer: ajaxDataRenderer,
52            axes: {
53                xaxis: {
54                    renderer: $.jqplot.DateAxisRenderer,
55                    pad: 0
56                },
57                yaxis: {
58                    tickOptions: {
59                        @if (axisYFormat != null) {
60                            @:formatString: "@axisYFormat",
61                        }
62                    },
63                    @if (minY != null) {
64                        @:min: @minY,
65                    }
66                    @if (maxY != null) {
67                        @:max: @maxY,
68                    }
69                    pad: 0,
70                    autoscale: true
71                },
72            },
73            gridPadding: { left: 50, right: 10 },
74            cursor: {
75                show: true,
76                showTooltip: false,
77                zoom: true,
78                clickReset: false,
79                dblClickReset: false,
80                constrainZoomTo: 'x'
81            }
82        });
83       
84        @(destinationTag)Plot.replot({ resetAxes: true });
85       
86        $('#@destinationTag').contextmenu(function() {
87            @(destinationTag)Plot.resetZoom();
88            @(destinationTag)Plot.replot({ resetAxes: true });
89            return false;
90        });
91       
92        $(window).resize(function() {
93            @(destinationTag)Plot.replot({ resetAxes: true });
94        });
95    </script>
96}
97
98@helper RefreshChart(string destinationTag, string url, string startDateVar, string endDateVar) {
99    @:$.ajax({url: "@(new HtmlString(url))?start=" + @startDateVar + "&end=" + @endDateVar, datatype: "json", success: function(result) {
100    @:    for (var i = 0; i < result.length; i++) {
101    @:        @(destinationTag)Plot.series[i].data = result[i];
102    @:    }
103    @:    @(destinationTag)Plot.replot({ resetAxes: true })
104    @:}});
105}
Note: See TracBrowser for help on using the repository browser.