mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-07-26 22:26:08 +02:00
Introduce units.js, centralizes value normalizing
This commit is contained in:
@@ -196,7 +196,7 @@
|
||||
</style>
|
||||
|
||||
<script context="module">
|
||||
import { formatNumber } from '../utils.js'
|
||||
import { formatNumber } from '../units.js'
|
||||
|
||||
export function binsFromFootprint(weights, values, numBins) {
|
||||
let min = 0, max = 0
|
||||
|
@@ -22,7 +22,7 @@
|
||||
-->
|
||||
<script>
|
||||
import uPlot from 'uplot'
|
||||
import { formatNumber } from '../utils.js'
|
||||
import { formatNumber } from '../units.js'
|
||||
import { getContext, onMount, onDestroy } from 'svelte'
|
||||
|
||||
export let width
|
||||
@@ -312,7 +312,9 @@
|
||||
|
||||
</script>
|
||||
|
||||
<!--Add empty series warning card-->
|
||||
<div bind:this={plotWrapper} class="cc-plot"></div>
|
||||
|
||||
<style>
|
||||
.cc-plot {
|
||||
border-radius: 5px;
|
||||
|
@@ -46,16 +46,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
const power = [1, 1e3, 1e6, 1e9, 1e12]
|
||||
const suffix = ['', 'k', 'm', 'g']
|
||||
function formatNumber(x) {
|
||||
for (let i = 0; i < suffix.length; i++)
|
||||
if (power[i] <= x && x < power[i+1])
|
||||
return `${x / power[i]}${suffix[i]}`
|
||||
|
||||
return Math.abs(x) >= 1000 ? x.toExponential() : x.toString()
|
||||
}
|
||||
|
||||
function axisStepFactor(i, size) {
|
||||
if (size && size < 500)
|
||||
return 10
|
||||
@@ -307,6 +297,7 @@
|
||||
|
||||
<script>
|
||||
import { onMount, tick } from 'svelte'
|
||||
import { formatNumber } from '../units.js'
|
||||
|
||||
export let flopsAny = null
|
||||
export let memBw = null
|
||||
|
@@ -3,7 +3,7 @@
|
||||
</div>
|
||||
|
||||
<script context="module">
|
||||
import { formatNumber } from '../utils.js'
|
||||
import { formatNumber } from '../units.js'
|
||||
|
||||
const axesColor = '#aaaaaa'
|
||||
const fontSize = 12
|
||||
|
Reference in New Issue
Block a user