[9628] | 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() {
|
---|
[9625] | 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 | },
|
---|
[9628] | 47 | seriesDefaults: {
|
---|
| 48 | markerOptions: { show: false },
|
---|
| 49 | //fill: true
|
---|
| 50 | },
|
---|
[9625] | 51 | dataRenderer: ajaxDataRenderer,
|
---|
| 52 | axes: {
|
---|
| 53 | xaxis: {
|
---|
| 54 | renderer: $.jqplot.DateAxisRenderer,
|
---|
[9644] | 55 | pad: 0
|
---|
[9625] | 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 | },
|
---|
[9644] | 73 | gridPadding: { left: 50, right: 10 },
|
---|
[9625] | 74 | cursor: {
|
---|
| 75 | show: true,
|
---|
[9628] | 76 | showTooltip: false,
|
---|
| 77 | zoom: true,
|
---|
| 78 | clickReset: false,
|
---|
| 79 | dblClickReset: false,
|
---|
| 80 | constrainZoomTo: 'x'
|
---|
[9625] | 81 | }
|
---|
| 82 | });
|
---|
| 83 |
|
---|
[9644] | 84 | @(destinationTag)Plot.replot({ resetAxes: true });
|
---|
[9625] | 85 |
|
---|
[9628] | 86 | $('#@destinationTag').contextmenu(function() {
|
---|
| 87 | @(destinationTag)Plot.resetZoom();
|
---|
[9644] | 88 | @(destinationTag)Plot.replot({ resetAxes: true });
|
---|
[9628] | 89 | return false;
|
---|
| 90 | });
|
---|
| 91 |
|
---|
[9625] | 92 | $(window).resize(function() {
|
---|
[9644] | 93 | @(destinationTag)Plot.replot({ resetAxes: true });
|
---|
[9625] | 94 | });
|
---|
| 95 | </script>
|
---|
[9643] | 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 | @: }
|
---|
[9644] | 103 | @: @(destinationTag)Plot.replot({ resetAxes: true })
|
---|
[9643] | 104 | @:}});
|
---|
[9625] | 105 | } |
---|