Project

General

Profile

Feature #1060 ยป js.html

Hammel, 11 Mar 2025 21:18

 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
<html>
3
<head>
4
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
	<title>Flot Examples: PiStoreWeb</title>
6
	<link href="css/examples.css" rel="stylesheet" type="text/css">
7
	<script language="javascript" type="text/javascript" src="js/jquery.js"></script>
8
	<script language="javascript" type="text/javascript" src="js/jquery.canvaswrapper.js"></script>
9
	<script language="javascript" type="text/javascript" src="js/jquery.colorhelpers.js"></script>
10
	<script language="javascript" type="text/javascript" src="js/jquery.flot.js"></script>
11
	<script language="javascript" type="text/javascript" src="js/jquery.flot.saturated.js"></script>
12
	<script language="javascript" type="text/javascript" src="js/jquery.flot.browser.js"></script>
13
	<script language="javascript" type="text/javascript" src="js/jquery.flot.drawSeries.js"></script>
14
	<script language="javascript" type="text/javascript" src="js/jquery.flot.uiConstants.js"></script>
15
	<script language="javascript" type="text/javascript" src="js/jquery.flot.categories.js"></script>
16
	<script type="text/javascript">
17

    
18
	$(function() {
19

    
20
		var data = [ ["January", 10], ["February", 8], ["March", 4], ["April", 13], ["May", 17], ["June", 9] ];
21
		        var as;
22

    
23
		// var as = async () => {
24
  			// const response = await fetch('/api/1.0/status');
25
  			// const myJson = await response.json(); //extract JSON from the http response
26
		// };
27

    
28
const apiUrl = '/api/1.0/status';
29
const outputElement = document.getElementById('output');
30

    
31
fetch(apiUrl)
32
  .then(response => {
33
    if (!response.ok) {
34
      throw new Error('Network response was not ok');
35
    }
36
    return response.json();
37
  })
38
  .then(data => {
39
    // Display data in an HTML element
40
    outputElement.textContent = JSON.stringify(data, null, 4);
41
    console.log(data);
42
  })
43
  .catch(error => {
44
    console.error('Error:', error);
45
  });
46

    
47

    
48

    
49
		$.plot("#placeholder", [ data ], {
50
			series: {
51
				bars: {
52
					show: true,
53
					barWidth: 0.6,
54
					align: "center"
55
				}
56
			},
57
			xaxis: {
58
				mode: "categories",
59
				showTicks: false,
60
				gridLines: false
61
			}
62
		});
63

    
64
		// Add the Flot version string to the footer
65

    
66
		$("#footer").prepend("Flot " + $.plot.version + " &ndash; ");
67
	});
68

    
69
	</script>
70
</head>
71
<body>
72

    
73
	<div id="header">
74
		<h2>PiStoreWeb</h2>
75
	</div>
76

    
77
	<div id="content">
78

    
79
		<div class="demo-container">
80
			<div id="placeholder" class="demo-placeholder"></div>
81
		</div>
82

    
83
		<p>With the categories plugin you can plot categories/textual data easily.</p>
84

    
85
	</div>
86

    
87
	<div id="footer">
88
		Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
89
	</div>
90

    
91
</body>
92
</html>
    (1-1/1)