forked from devsecopsmaturitymodel/DevSecOps-MaturityModel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scutter.php
183 lines (167 loc) · 5.06 KB
/
scutter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
include_once "head.php";
?>
<body>
<?php
include_once "navi.php";
?>
<?php
include_once "data.php";
function getJson($dimensions)
{
$json = array();
$shapes = array('circle', 'cross', 'triangle-up', 'triangle-down', 'diamond', 'square');
$shape = 0;
foreach ($dimensions as $dimension => $subdimensions) {
foreach ($subdimensions as $subdimension => $element) {
$values = array();
foreach ($element as $activityName => $content) {
$values[] = array(
"series" => 0,
"shape" => $shapes[$shape],
"size" => 3000,
"x" => getDifficultyOfImplementation($dimensions, $content),
"y" => $content["usefulness"],
"key" => $activityName
);
}
$json[] = array(
"key" => "$dimension - " . $subdimension,
"values" => $values
);
$shape++;
}
}
return json_encode($json);
}
?>
<script>
var _d3;
nv.addGraph(function () {
var init = true;
var chart = nv.models.scatterChart()
.showDistX(true) //showDist, when true, will display those little distribution lines on the axis.
.showDistY(true)
.transitionDuration(350)
.color(d3.scale.category10().range());
var getGraph = false;
function getGraphtPt(graph, x1, y1) {
var a = graph.series.values;
var i = a.length;
while (i--) {
console.log("ax,ay,x1,y1", a[i].x,a[i].y, x1,y1);
if (a[i].x == x1 & a[i].y == y1) {
return a[i];
}
}
return null;
}
chart.tooltipContent(function (key, x, y, graph) {
var s = "unknown";
var pt = getGraphtPt(graph, x, y);
if (pt != null) {
s = pt.key;
}
return '<h3>' + key + ": " + s + '</h3>';
});
function getLabelForAxis(d) {
if(!init) {
return d;
}
if (d <= 1.5) {
return "Sehr gering";
}
if (d <= 2.5) {
return "Gering";
}
if (d <= 3.5) {
return "Mittel";
}
if (d <= 4.5) {
return "Hoch"
}
if (d <= 5) {
return "Sehr Hoch";
}
return "";
}
//Axis settings
chart.xAxis
.tickFormat(function (d) {
return getLabelForAxis(d);
})
.axisLabel("Difficulty of Implementation");
chart.yAxis
.tickFormat(function (d) {
return getLabelForAxis(d);
})
.axisLabel("Value");
chart.scatter.forceX([1, 6]);
chart.scatter.forceY([1, 6]);
//We want to show shapes other than circles.
chart.scatter.onlyCircles(false);
var myData = getData();
var svg = d3.select('#chart svg')
svg.datum(myData)
svg.call(chart);
//svg. call(chart);
nv.utils.windowResize(chart.update);
toggle();
$("#toggleChartLabel").click(function () {
toggle();
});
init = false;
return chart;
});
/**************************************
* Simple test data generator
*/
function getData() { //# groups,# points per group
var data = [],
shapes = ['circle', 'cross', 'triangle-up', 'triangle-down', 'diamond', 'square'],
data = <?php echo getJson($dimensions); ?>;
return data;
}
function toggle() {
if ($("text.labels").size() > 0) {
$("text.labels").remove();
} else {
d3.selectAll(".nv-group path")[0].forEach(function (d) {
var tf = d3.select(d).attr("transform")
t = d3.transform(tf).translate;
t[0] = t[0] + 10;//moving the translate x by 5 pixel.
//console.log(d3.select(d).style("visibility"))//data associated with the point
var point = d3.select(d).data()[0];
d3.select(d.parentNode)
.append("text")
.attr("class", "labels")
.text(point.key)//putting data
.attr("transform", "translate(" + t[0] + "," + t[1] + ")");//setting the changed translate for label
});
}
}
</script>
<button id="toggleChartLabel">Toggle Label</button>
<form action="?" method="get">
<input name="aggregated" type="hidden"
<?php
if($_GET['aggregated'] == "true") {
echo "value='false'";
}else {
echo "value='true'";
}
?>">
</input>
<button id="">
<?php
if($_GET['aggregated'] == "true") {
echo "Show specific values";
}else {
echo "Show total values";
}
?>
</button>
</form>
<div id='chart'>
<svg style='height:500px'></svg>
</div>