1 | <!DOCTYPE html>
|
---|
2 | <html lang="en">
|
---|
3 | <head>
|
---|
4 | <meta charset="UTF-8" />
|
---|
5 | <meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
---|
6 | <meta http-equiv="X-UA-Compatible" />
|
---|
7 | <script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0/dist/Chart.min.js"></script>
|
---|
8 | <style>
|
---|
9 | .wrapper {
|
---|
10 | display: flex;
|
---|
11 | flex: wrap;
|
---|
12 | order: row;
|
---|
13 | }
|
---|
14 | </style>
|
---|
15 | <title>Histogram toJSON()</title>
|
---|
16 | </head>
|
---|
17 | <body>
|
---|
18 | <div style="max-width: 800px;">
|
---|
19 | <canvas id="chart1595168308658" width="16" height="9"></canvas>
|
---|
20 | </div>
|
---|
21 | <script>
|
---|
22 | const format = num => {
|
---|
23 | const chunked = [];
|
---|
24 | String(num)
|
---|
25 | .split("")
|
---|
26 | .reverse()
|
---|
27 | .forEach((char, index) => {
|
---|
28 | if (index % 3 === 0) {
|
---|
29 | chunked.unshift([char]);
|
---|
30 | } else {
|
---|
31 | chunked[0].unshift(char);
|
---|
32 | }
|
---|
33 | });
|
---|
34 |
|
---|
35 | return chunked.map(chunk => chunk.join("")).join(" ");
|
---|
36 | };
|
---|
37 | const ctx1595168308658 = document
|
---|
38 | .getElementById("chart1595168308658")
|
---|
39 | .getContext("2d");
|
---|
40 | const chart1595168308658 = new Chart(ctx1595168308658, {
|
---|
41 | type: "bar",
|
---|
42 | data: {
|
---|
43 | labels: ["JS 32B Histogram", "JS 32B Histogram light"],
|
---|
44 | datasets: [
|
---|
45 | {
|
---|
46 | data: [53, 1266],
|
---|
47 | backgroundColor: [
|
---|
48 | "rgba(63, 142, 252, 0.8)",
|
---|
49 | "rgba(116, 165, 127, 0.8)"
|
---|
50 | ],
|
---|
51 | borderColor: ["rgba(63, 142, 252, 1)", "rgba(116, 165, 127, 1)"],
|
---|
52 | borderWidth: 1
|
---|
53 | }
|
---|
54 | ]
|
---|
55 | },
|
---|
56 | options: {
|
---|
57 | legend: {
|
---|
58 | display: false
|
---|
59 | },
|
---|
60 | title: {
|
---|
61 | display: true,
|
---|
62 | text: "Histogram toJSON()",
|
---|
63 | fontSize: 16,
|
---|
64 | padding: 20
|
---|
65 | },
|
---|
66 | tooltips: {
|
---|
67 | callbacks: {
|
---|
68 | label: tooltipItem => {
|
---|
69 | return format(tooltipItem.yLabel) + " ops/s";
|
---|
70 | }
|
---|
71 | }
|
---|
72 | },
|
---|
73 | scales: {
|
---|
74 | yAxes: [
|
---|
75 | {
|
---|
76 | gridLines: {
|
---|
77 | color: "rgba(127, 127, 127, 0.2)"
|
---|
78 | },
|
---|
79 | scaleLabel: {
|
---|
80 | display: true,
|
---|
81 | labelString: "Operations per second"
|
---|
82 | },
|
---|
83 | ticks: {
|
---|
84 | beginAtZero: true,
|
---|
85 | callback: format
|
---|
86 | }
|
---|
87 | }
|
---|
88 | ],
|
---|
89 | xAxes: [
|
---|
90 | {
|
---|
91 | gridLines: {
|
---|
92 | color: "rgba(127, 127, 127, 0.2)"
|
---|
93 | },
|
---|
94 | maxBarThickness: 150
|
---|
95 | }
|
---|
96 | ]
|
---|
97 | }
|
---|
98 | }
|
---|
99 | });
|
---|
100 | </script>
|
---|
101 | </body>
|
---|
102 | </html>
|
---|