diff --git a/elements/linechart.js b/elements/linechart.js index a2bd958..99464ed 100644 --- a/elements/linechart.js +++ b/elements/linechart.js @@ -6,9 +6,9 @@ const Component = withComponent(); const legendLabel = (datasets, idx) => { const parts = datasets.map(set => set.split('.')); - let uniques = parts[idx].filter((part, idx) => { + const uniques = parts[idx].filter((part, index) => { for (let i = 0; i < parts.length; i++) { - if (parts[i][idx] !== part) { + if (parts[i][index] !== part) { return true; } } @@ -37,9 +37,7 @@ class LineChart extends Component { const endDate = new Date(); const startDate = new Date(); startDate.setDate(startDate.getDate() - days); - const promises = this.timeseries.split(' ').map((dataset) => { - return this.fetch(dataset, startDate, endDate); - }); + const promises = this.timeseries.split(' ').map(dataset => this.fetch(dataset, startDate, endDate)); Promise.all(promises) .then((res) => { this.data = res; @@ -49,7 +47,7 @@ class LineChart extends Component { fetch(timeseries, start, end) { const url = `http://openmct.cbrp3.c-base.org/telemetry/${timeseries}?start=${start.getTime()}&end=${end.getTime()}`; return fetch(url) - .then(data => data.json()) + .then(data => data.json()); } renderer(renderRoot, render) { @@ -78,10 +76,10 @@ class LineChart extends Component { return el; } const lineShape = shape || 'spline'; - const graphWidth = Math.floor(window.innerWidth / 100 * (width || 40)); - const graphHeight = Math.floor(window.innerHeight / 100 * (height || 50)); + const graphWidth = Math.floor((window.innerWidth / 100) * (width || 40)); + const graphHeight = Math.floor((window.innerHeight / 100) * (height || 50)); const datasets = this.timeseries.split(' '); - const showLegend = (datasets.length > 1) ? true : false; + const showLegend = (datasets.length > 1); const graphData = data.map((values, idx) => { const res = { y: values.map(point => parseValue(point.value)), diff --git a/lib/colors.js b/lib/colors.js index 5554546..16db745 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -11,3 +11,5 @@ export const colors = [ 'hsl(310, 98%, 46%)', 'hsl(335, 98%, 46%)', ]; + +export default colors; diff --git a/lib/values.js b/lib/values.js index a781391..72243dd 100644 --- a/lib/values.js +++ b/lib/values.js @@ -7,3 +7,5 @@ export function parseValue(val) { } return parseFloat(val); } + +export default parseValue;