| 1 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 |
import './plot.css'; |
| 3 |
|
| 4 |
import React from 'react'; |
| 5 |
import { createRoot } from 'react-dom/client'; |
| 6 |
|
| 7 |
import { PlotState } from "plot.js"; |
| 8 |
import { SvgPlot, bytes_config } from "cockpit-components-plot.jsx"; |
| 9 |
|
| 10 |
const direct_metric = { |
| 11 |
direct: ["mem.util.available"], |
| 12 |
units: "bytes" |
| 13 |
}; |
| 14 |
|
| 15 |
const pmcd_metric = { |
| 16 |
pmcd: ["mem.util.available"], |
| 17 |
units: "bytes" |
| 18 |
}; |
| 19 |
|
| 20 |
const internal_metric = { |
| 21 |
internal: ["memory.used"], |
| 22 |
units: "bytes", |
| 23 |
}; |
| 24 |
|
| 25 |
document.addEventListener("DOMContentLoaded", function() { |
| 26 |
const plot_state = new PlotState(); |
| 27 |
plot_state.plot_single('direct', direct_metric); |
| 28 |
plot_state.plot_single('pmcd', pmcd_metric); |
| 29 |
plot_state.plot_single('internal', internal_metric); |
| 30 |
|
| 31 |
// For the tests |
| 32 |
window.plot_state = plot_state; |
| 33 |
|
| 34 |
createRoot(document.getElementById('plot-direct')).render( |
| 35 |
<SvgPlot className="mem-graph" |
| 36 |
title="Direct" config={bytes_config} |
| 37 |
plot_state={plot_state} plot_id="direct" /> |
| 38 |
); |
| 39 |
|
| 40 |
createRoot(document.getElementById('plot-pmcd')).render( |
| 41 |
<SvgPlot className="mem-graph" |
| 42 |
title="PMCD" config={bytes_config} |
| 43 |
plot_state={plot_state} plot_id="pmcd" /> |
| 44 |
); |
| 45 |
|
| 46 |
createRoot(document.getElementById('plot-internal')).render( |
| 47 |
<SvgPlot className="mem-graph" |
| 48 |
title="Internal" config={bytes_config} |
| 49 |
plot_state={plot_state} plot_id="internal" /> |
| 50 |
); |
| 51 |
}); |