<commit_before><%#
LuCI - Lua Configuration Interface
Copyright 2008-2009 <NAME> <<EMAIL>>
Copyright 2008-2011 <NAME> <<EMAIL>>
Copyright 2012 <NAME> <<EMAIL>>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0
-%>

<%+header%>

<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript" src="<%=resource%>/jquery.min.js"></script>
<script type="text/javascript" src="<%=resource%>/highcharts.src.js"></script>
<script type="text/javascript" src="<%=resource%>/exporting.js"></script>

<h2><a id="content" name="content"><%:Measurements%></a></h2>

<div class="cbi-map" id="sensors">
</div>

<script type="text/javascript">//<![CDATA[
	<%local path = luci.dispatcher.context.requestpath%>
	<%local addr = path[#path]:gsub(":", "z")%>
	var addr = <%luci.http.write_json(addr)%>
	Highcharts.setOptions({global:{useUTC: false}});
	var charts = new Array();
	// Get data descriptor
	XHR.get('<%=luci.dispatcher.build_url("admin", "services", "sensors_poll", addr, "desc")%>', null,
		function(x, st) {
			if (st) {
				document.getElementById('sensors').innerHTML = "";
				for (var i in st.data) {
					var str = '<h2>' + i.toUpperCase() + ': <font id="val_' + i + '">...</font> ' + st.data[i] + '</h2>';
					str += '<fieldset class="cbi-section">';
					str += '<div id="plot_' + i + '" style="min-width: 400px; height: 200px; margin: 0 auto"></div>';
					str += '</fieldset>';
					document.getElementById('sensors').innerHTML += str;
					charts.push(new Highcharts.Chart({
						chart: { renderTo: 'plot_' + i, type: 'spline', marginRight: 10 },
						title: { text: i.toUpperCase() },
						xAxis: { type: 'datetime', tickPixelInterval: 150 },
						yAxis: { title: { text: 'Value (' + st.data[i] + ')' },
							plotLines: [{ value: 0, width: 1, color: '#808080' }] },
						tooltip: {
							formatter: function() {
								return '<b>'+ this.series.name +'</b><br/>'+
									Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) +'<br/>'+
									Highcharts.numberFormat(this.y, 2);
							}
						},
						legend: { enabled: false },
						exporting: { enabled: false },
						series: [{
							name: i.toUpperCase(),
							data: (function() {
								var data = [],
									time = (new Date()).getTime(),
									i;
								for (j = -19; j <= 0; j++) {
									data.push({ x: time + j * 1000, y: 0 });
								}
								return data;
							})()
						}]
					}));
				}
			}
		}
	);
	// Actually add data
	XHR.poll(1, '<%=luci.dispatcher.build_url("admin", "services", "sensors_poll", addr, "data")%>', null,
		function(x, st) {
			if (st) {
				var j = 0;
				for (var i in st) {
					document.getElementById("val_" + i).innerHTML = String.format('%s ', st[i]);
					charts[j].series[0].addPoint([new Date().getTime(), st[i]], true, true);
					j++;
				}
			}
		}
	);
//]]></script>

<%+footer%>
<commit_msg>flexibity: Update plot to multiline<commit_after><%#
LuCI - Lua Configuration Interface
Copyright 2008-2009 <NAME> <<EMAIL>>
Copyright 2008-2011 <NAME> <<EMAIL>>
Copyright 2012 <NAME> <<EMAIL>>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0
-%>

<%+header%>

<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript" src="<%=resource%>/jquery.min.js"></script>
<script type="text/javascript" src="<%=resource%>/highcharts.src.js"></script>
<script type="text/javascript" src="<%=resource%>/exporting.js"></script>

<h2><a id="content" name="content"><%:Measurements%></a></h2>

<div class="cbi-map" id="sensors">
	<fieldset class="cbi-section">
		<div id="plot" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
	</fieldset>
</div>

<script type="text/javascript">//<![CDATA[
	<%local path = luci.dispatcher.context.requestpath%>
	<%local addr = path[#path]:gsub(":", "z")%>
	var addr = <%luci.http.write_json(addr)%>
	Highcharts.setOptions({global:{useUTC: false}});
	var chart;
	// Get data descriptor
	XHR.get('<%=luci.dispatcher.build_url("admin", "services", "sensors_poll", addr, "desc")%>', null,
		function(x, st) {
			if (st) {
				var y_axis = new Array();
				var series = new Array();
				var series_data = new Array();
				var time = (new Date()).getTime();
				for (k = -29; k <= 0; k++) {
					series_data.push({
						x: time + k * 1000,
						y: 0
					});
				}
				for (var i in st.data) {
					y_axis.push({
						lables: { formatter: function() { return this.value + st.data[i]; } },
						title: { text: i.toUpperCase() + ' (' + st.data[i] + ')' },
                                                plotLines: [{ value: 0, width: 1, color: '#808080' }]
					});
					series.push({
						name: i.toUpperCase(),
						type: 'spline',
						data: series_data
					});
				}
				chart = new Highcharts.Chart({
					title: { text: st.type + ' data' },
					chart: { renderTo: 'plot', type: 'spline', marginRight: 10 },
					xAxis: { type: 'datetime', tickPixelInterval: 150 },
					yAxis: y_axis,
					legend: { enabled: false },
					exporting: { enabled: false },
					series: series
				});
			}
		}
	);
	// Actually add data
	XHR.poll(1, '<%=luci.dispatcher.build_url("admin", "services", "sensors_poll", addr, "data")%>', null,
		function(x, st) {
			if (st) {
				var j = 0;
				for (var i in st) {
					chart.series[j].addPoint([(new Date()).getTime(), st[i]], true, true);
					j++;
				}
			}
		}
	);
//]]></script>

<%+footer%>

{'fraction_non_alphanumeric': 0.21220624342336022, 'fraction_numerical': 0.020343739038933707, 'mean_word_length': 3.190301249081558, 'pattern_counts': {'":': 2, '<': 99, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6985546', 'n_tokens_mistral': 2500, 'n_tokens_neox': 1985, 'n_words': 473}