Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the user to decide how to handle null values in charts #4071

Merged
merged 14 commits into from
Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "Multiple series: groupped",
"input": {
"data": [
{ "a": 42, "b": 10, "g": "first" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "Multiple series: multipple Y mappings",
"input": {
"data": [
{ "a": 42, "b": 10, "c": 41, "d": 92 },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "Multiple series: groupped",
"input": {
"data": [
{ "a": 42, "b": 10, "g": "first" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "Single series",
"input": {
"data": [
{ "a": 42, "b": 10, "c": 41, "d": 92 },
Expand Down
42 changes: 26 additions & 16 deletions client/app/visualizations/chart/getChartData.test.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
import fs from 'fs';
import path from 'path';
/* eslint-disable global-require, import/no-unresolved */
import getChartData from './getChartData';

function loadFixtures(directoryName) {
directoryName = path.join(__dirname, directoryName);
const fileNames = fs.readdirSync(directoryName);
return fileNames.map((fileName) => {
const str = fs.readFileSync(path.join(directoryName, fileName));
return JSON.parse(str);
});
}
describe('Visualizations', () => {
describe('Chart', () => {
describe('getChartData', () => {
test('Single series', () => {
const { input, output } = require('./fixtures/getChartData/single-series');
const data = getChartData(input.data, input.options);
expect(data).toEqual(output.data);
});

test('Multiple series: multipple Y mappings', () => {
const { input, output } = require('./fixtures/getChartData/multiple-series-multiple-y');
const data = getChartData(input.data, input.options);
expect(data).toEqual(output.data);
});

test('Multiple series: groupped', () => {
kravets-levko marked this conversation as resolved.
Show resolved Hide resolved
const { input, output } = require('./fixtures/getChartData/multiple-series-grouped');
const data = getChartData(input.data, input.options);
expect(data).toEqual(output.data);
});

describe('Visualizations - getChartData', () => {
const fixtures = loadFixtures('fixtures/getChartData');
fixtures.forEach(({ name, input, output }) => {
test(name, () => {
const data = getChartData(input.data, input.options);
expect(data).toEqual(output.data);
test('Multiple series: sorted', () => {
const { input, output } = require('./fixtures/getChartData/multiple-series-sorted');
const data = getChartData(input.data, input.options);
expect(data).toEqual(output.data);
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"input": {
"options": {
"globalSeriesType": "box",
"xAxis": { "type": "-", "labels": { "enabled": true } },
"yAxis": [
{ "type": "linear" },
{ "type": "linear", "opposite": true }
],
"series": { "stacking": null, "error_y": { "type": "data", "visible": true } }
},
"series": [
{ "name": "a" }
]
},
"output": {
"layout": {
"margin": { "l": 10, "r": 10, "b": 10, "t": 25, "pad": 4 },
"width": 400,
"height": 300,
"autosize": true,
"showlegend": true,
"boxmode": "group",
"boxgroupgap": 0.50,
"xaxis": {
"automargin": true,
"showticklabels": true,
"title": null,
"type": "-"
},
"yaxis": {
"automargin": true,
"title": null,
"type": "linear"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"input": {
"options": {
"globalSeriesType": "box",
"xAxis": { "type": "-", "labels": { "enabled": true } },
"yAxis": [
{ "type": "linear" },
{ "type": "linear", "opposite": true }
],
"series": { "stacking": null, "error_y": { "type": "data", "visible": true } }
},
"series": [
{ "name": "a" },
{ "name": "b", "yaxis": "y2" }
]
},
"output": {
"layout": {
"margin": { "l": 10, "r": 10, "b": 10, "t": 25, "pad": 4 },
"width": 400,
"height": 300,
"autosize": true,
"showlegend": true,
"boxmode": "group",
"boxgroupgap": 0.50,
"xaxis": {
"automargin": true,
"showticklabels": true,
"title": null,
"type": "-"
},
"yaxis": {
"automargin": true,
"title": null,
"type": "linear"
},
"yaxis2": {
"automargin": true,
"title": null,
"type": "linear",
"overlaying": "y",
"side": "right"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"input": {
"options": {
"globalSeriesType": "column",
"xAxis": { "type": "-", "labels": { "enabled": true } },
"yAxis": [
{ "type": "linear" },
{ "type": "linear", "opposite": true }
],
"series": { "stacking": null, "error_y": { "type": "data", "visible": true } }
},
"series": [
{ "name": "a" }
]
},
"output": {
"layout": {
"margin": { "l": 10, "r": 10, "b": 10, "t": 25, "pad": 4 },
"width": 400,
"height": 300,
"autosize": true,
"showlegend": true,
"xaxis": {
"automargin": true,
"showticklabels": true,
"title": null,
"type": "-"
},
"yaxis": {
"automargin": true,
"title": null,
"type": "linear"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"input": {
"options": {
"globalSeriesType": "column",
"xAxis": { "type": "-", "labels": { "enabled": true } },
"yAxis": [
{ "type": "linear" },
{ "type": "linear", "opposite": true }
],
"series": { "stacking": null, "error_y": { "type": "data", "visible": true } }
},
"series": [
{ "name": "a" },
{ "name": "b", "yaxis": "y2" }
]
},
"output": {
"layout": {
"margin": { "l": 10, "r": 10, "b": 10, "t": 25, "pad": 4 },
"width": 400,
"height": 300,
"autosize": true,
"showlegend": true,
"xaxis": {
"automargin": true,
"showticklabels": true,
"title": null,
"type": "-"
},
"yaxis": {
"automargin": true,
"title": null,
"type": "linear"
},
"yaxis2": {
"automargin": true,
"title": null,
"type": "linear",
"overlaying": "y",
"side": "right"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"input": {
"options": {
"globalSeriesType": "column",
"legend": { "enabled": false },
"xAxis": { "type": "-", "labels": { "enabled": true } },
"yAxis": [
{ "type": "linear" },
{ "type": "linear", "opposite": true }
],
"series": { "stacking": "stack", "error_y": { "type": "data", "visible": true } }
},
"series": [
{ "name": "a" }
]
},
"output": {
"layout": {
"margin": { "l": 10, "r": 10, "b": 10, "t": 25, "pad": 4 },
"width": 400,
"height": 300,
"autosize": true,
"showlegend": false,
"barmode": "relative",
"xaxis": {
"automargin": true,
"showticklabels": true,
"title": null,
"type": "-"
},
"yaxis": {
"automargin": true,
"title": null,
"type": "linear"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"input": {
"options": {
"globalSeriesType": "column",
"legend": { "enabled": false },
"xAxis": { "type": "-", "labels": { "enabled": true } },
"yAxis": [
{ "type": "linear" },
{ "type": "linear", "opposite": true }
],
"series": { "stacking": null, "error_y": { "type": "data", "visible": true } }
},
"series": [
{ "name": "a" }
]
},
"output": {
"layout": {
"margin": { "l": 10, "r": 10, "b": 10, "t": 25, "pad": 4 },
"width": 400,
"height": 300,
"autosize": true,
"showlegend": false,
"xaxis": {
"automargin": true,
"showticklabels": true,
"title": null,
"type": "-"
},
"yaxis": {
"automargin": true,
"title": null,
"type": "linear"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"input": {
"options": {
"globalSeriesType": "pie",
"textFormat": ""
},
"series": [
{ "name": "a" },
{ "name": "b" },
{ "name": "c" }
]
},
"output": {
"layout": {
"margin": { "l": 10, "r": 10, "b": 10, "t": 25, "pad": 4 },
"width": 400,
"height": 300,
"autosize": true,
"showlegend": true,
"annotations": [
{
"x": 0.24,
"y": 0.485,
"xanchor": "center",
"yanchor": "top",
"text": "a",
"showarrow": false
},
{
"x": 0.74,
"y": 0.485,
"xanchor": "center",
"yanchor": "top",
"text": "b",
"showarrow": false
},
{
"x": 0.24,
"y": 0.985,
"xanchor": "center",
"yanchor": "top",
"text": "c",
"showarrow": false
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"input": {
"options": {
"globalSeriesType": "pie",
"textFormat": "{{ @@name }}"
},
"series": [
{ "name": "a" }
]
},
"output": {
"layout": {
"margin": { "l": 10, "r": 10, "b": 10, "t": 25, "pad": 4 },
"width": 400,
"height": 300,
"autosize": true,
"showlegend": true,
"annotations": []
}
}
}
Loading