@netdata/charts
Version:
Netdata frontend SDK and chart utilities
265 lines (262 loc) • 8.61 kB
JavaScript
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
import ChartType from "../components/toolbox/chartType";
import Fullscreen from "../components/toolbox/fullscreen";
import Information from "../components/toolbox/information";
import Download from "../components/toolbox/download";
import Status from "../components/status";
export default {
id: "",
name: "",
chartLibrary: "",
theme: "default",
host: "",
description: null,
before: 0,
after: 0,
title: null,
min: 0,
max: 0,
pristineStaticValueRange: undefined,
valueRange: null,
staticValueRange: null,
getValueRange: function getValueRange(chart) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$dygraph = _ref.dygraph,
dygraph = _ref$dygraph === void 0 ? false : _ref$dygraph;
if (!chart) return [null, null];
var _chart$getAttributes = chart.getAttributes(),
_chart$getAttributes$ = _chart$getAttributes.min,
min = _chart$getAttributes$ === void 0 ? null : _chart$getAttributes$,
_chart$getAttributes$2 = _chart$getAttributes.max,
max = _chart$getAttributes$2 === void 0 ? null : _chart$getAttributes$2,
_chart$getAttributes$3 = _chart$getAttributes.valueRange,
valueRange = _chart$getAttributes$3 === void 0 ? [null, null] : _chart$getAttributes$3,
staticValueRange = _chart$getAttributes.staticValueRange;
if (staticValueRange) return staticValueRange;
if (!valueRange || valueRange[0] === null && valueRange[1] === null) {
if (dygraph) return [null, null];
return [min, max];
}
var _valueRange = _slicedToArray(valueRange, 2),
rangeMin = _valueRange[0],
rangeMax = _valueRange[1];
if (dygraph) {
var _chart$getAttributes2 = chart.getAttributes(),
groupBy = _chart$getAttributes2.groupBy,
aggregationMethod = _chart$getAttributes2.aggregationMethod;
if (groupBy.length > 1 || groupBy[0] !== "dimension" || aggregationMethod !== "avg") return [null, null];
}
var newValueRange = [rangeMin === null || rangeMin > min ? min : rangeMin, rangeMax === null || rangeMax < max ? max : rangeMax];
return newValueRange;
},
loaded: false,
loading: false,
processing: false,
updatedAt: 0,
fetchStartedAt: 0,
focused: false,
active: false,
sparkline: false,
chartType: "",
selectedLegendDimensions: [],
contextItems: [],
contextScope: [],
nodesScope: [],
selectedContexts: [],
selectedDimensions: [],
selectedLabels: [],
selectedNodes: [],
selectedInstances: [],
dimensionIds: [],
versions: {},
enabledHover: true,
syncHover: true,
hoverX: null,
navigation: "",
enabledNavigation: true,
enabledResetRange: true,
syncPanning: true,
panning: false,
hovering: false,
syncHighlight: true,
highlighting: false,
desiredUnits: "auto",
abs: true,
unitsConversionMethod: [""],
unitsConversionDivider: [-1],
unitsConversionFractionDigits: [0],
unitsConversionPrefix: [""],
unitsConversionBase: [""],
dbUnitsConversionMethod: [""],
dbUnitsConversionDivider: [-1],
dbUnitsConversionFractionDigits: [0],
dbUnitsConversionPrefix: [""],
dbUnitsConversionBase: [""],
temperature: "celsius",
secondsAsTime: true,
timezone: undefined,
syncTimezone: true,
dimensionsSort: "default",
// default | nameAsc | nameDesc | valueAsc | valueDesc
autofetch: false,
autofetchOnWindowBlur: false,
paused: false,
pixelsPerPoint: 3,
legend: true,
groupingMethod: "average",
groupingTime: 0,
urlOptions: [],
eliminateZeroDimensions: true,
fullscreen: false,
overlays: {},
showingInfo: false,
colors: [],
height: "",
enabledYAxis: true,
width: "",
enabledXAxis: true,
hasToolbox: true,
hasHoverPopover: true,
expandable: true,
hasYlabel: true,
yAxisLabelWidth: 60,
axisLabelFontSize: 10,
outOfLimits: false,
aggregationMethod: "sum",
postAggregationMethod: "avg",
groupBy: ["dimension"],
groupByLabel: [],
postGroupBy: ["selected"],
postGroupByLabel: [],
dimensionsSortBy: [{
id: "contribution",
desc: true
}],
instancesSortBy: [{
id: "contribution",
desc: true
}],
nodesSortBy: [{
id: "contribution",
desc: true
}],
groupBySortBy: [],
labelsSortBy: [{
id: "contribution",
desc: true
}],
nodesExpanded: {},
groupByExpanded: {},
labelsExpanded: {},
drilldown: {
groupBy: ["node", "instance", "dimension"],
groupByLabel: [],
data: null,
loading: false,
error: null,
sortBy: [],
expanded: {},
groupBySortBy: [],
groupByExpanded: {}
},
pristine: {},
themeGridColor: ["#E4E8E8", "#212727"],
themeCrosshair: ["#536775", "#536775"],
themeTrackColor: ["#DBE1E1", "#353F3F"],
themeScaleColor: ["#F7F8F8", "#2B3136"],
themeEasyPieTrackColor: ["#DBE1E1", "#353F3F"],
themeEasyPieScaleColor: ["#B7C2C2", "#424E4E"],
themeGaugePointer: ["#8F9EAA", "#536775"],
themeGaugeStroke: ["#DBE1E1", "#353F3F"],
themeD3pieSmallColor: ["#536775", "#CFD5DA"],
themeD3pieStroke: ["#DBE1E1", "#353F3F"],
themeInnerLabelColor: ["#F7F8F8", "#282827"],
themeLabelColor: ["#35414a", "#ffffff"],
themeBackground: ["#ffffff", "#282C34"],
themeNeutralBackground: ["#DBE1E1", "#353F3F"],
themeWarningBackground: ["#FFCC26", "#FFCC26"],
themeErrorBackground: ["#F95251", "#F95251"],
themeAnomalyScaleColor: ["#9F75F9", "#9F75F9"],
themeGroupBoxesMin: ["#E4F1FF", "#000C18"],
themeGroupBoxesMax: ["#0075F2", "#0075F2"],
themeLoadingStart: ["#BFE5C6", "#2f5446"],
themeNetdata: ["#00AB44", "#00AB44"],
themeShadow: ["rgba(9, 30, 66, 0.15)", "rgba(0, 0, 0, 0.4)"],
designFlavour: "default",
legendScroll: 0,
initializedFilters: false,
error: null,
agent: true,
toolboxElements: [Information, ChartType, Fullscreen, Download],
toolboxProps: {},
leftHeaderElements: [Status],
expanded: false,
expandedHeight: 300,
viewDimensions: {
ids: [],
names: [],
count: 0,
priorities: [],
grouped: [],
algorithm: "absolute" // absolute|incremental
},
// view
units: [""],
unitsStsByContext: {},
unitsByContext: {},
viewUpdateEvery: 0,
// view.update_every
// db
dbUnits: [""],
dbUnitsStsByContext: {},
dbUnitsByContext: {},
updateEvery: 0,
firstEntry: 0,
lastEntry: 0,
// summary
dimensions: {},
labels: {},
nodes: {},
instances: {},
alerts: {},
drawer: {
action: "values",
tab: "window",
showAdvancedStats: false
},
renderedAt: null,
fetchAt: null,
dimensionsOnNonDimensionGrouping: null,
en: {
instance: {
one: "instance",
other: "instances"
}
},
tableColumns: ["context", "dimension"],
bearer: null,
xNetdataBearer: null,
showPostAggregations: false,
showAnomalies: true,
draftAnnotation: null,
// { timestamp, createdAt, status: "draft"|"editing"|"saving" }
compareData: {},
comparePeriods: [],
compareLoading: false,
compareError: null,
customPeriods: [{
id: "24h",
label: "24 hours before",
offsetSeconds: 86400
}, {
id: "7d",
label: "7 days before",
offsetSeconds: 604800
}],
selectedNodeLabelsFilter: []
};