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

D3fc plugin - Sunburst, color styles and bug fixes #511

Merged
merged 66 commits into from
Apr 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
46b0ed5
Put color styles in settings so that they can be scoped to a chart
andy-lee-eng Mar 26, 2019
0fa2d19
Use `ShadyCSS` component to get style variables directly
andy-lee-eng Mar 26, 2019
51a355a
Merge pull request #125 from redbearsam/feature/scoped-color-styles
matt-hooper Mar 27, 2019
6966638
Implemented themable color ranges for heatmap and X/Y
andy-lee-eng Mar 27, 2019
83251e2
Merge pull request #133 from redbearsam/feature/themable-heatmap
andy-lee-eng Mar 28, 2019
b186e16
update screenshot results with new colours
matt-hooper Mar 28, 2019
ab67217
Merge pull request #134 from redbearsam/test/heatmap_colours
matt-hooper Mar 28, 2019
6e4ffee
Hide labels that would be clipped by the window bounds
andy-lee-eng Mar 28, 2019
d670397
Merge pull request #135 from redbearsam/feature/hide-clipped-labels
andy-lee-eng Apr 1, 2019
970f7e5
Merge pull request #138 from jpmorganchase/master
matt-hooper Apr 1, 2019
2b976ce
replace reference to _config with get_config
matt-hooper Apr 1, 2019
aa33136
update screenshots where labels are now away from axis slightly
matt-hooper Apr 1, 2019
a0c6c79
Merge pull request #139 from redbearsam/fix/use_getConfig
Ro4052 Apr 1, 2019
ef08487
Added inital sunburst chart code
Ro4052 Mar 27, 2019
5b0ca72
Added scrolling to sunburst chart
Ro4052 Mar 27, 2019
ed28823
Fixed color domain
Ro4052 Mar 27, 2019
74dfe44
Match color scheme to heatmap
Ro4052 Mar 27, 2019
4bc6765
Removed unecessary import
Ro4052 Mar 27, 2019
4dd2f3e
Refactored sunburst chart creation
Ro4052 Mar 27, 2019
6418bcb
Renamed arc drawing function
Ro4052 Mar 28, 2019
291d0f8
Support resizing
Ro4052 Mar 28, 2019
b1e4f77
Refactored invariant enter attributes
Ro4052 Mar 28, 2019
64f158b
Support streaming data
Ro4052 Mar 28, 2019
7527396
Add support for side-by-side splits view
Ro4052 Mar 29, 2019
4f8bb05
Wrap svgs in divs and use grid layout
Ro4052 Mar 29, 2019
da02cb9
Added titles to splits
Ro4052 Mar 29, 2019
c6cccd0
Moved some styling into css
Ro4052 Mar 29, 2019
75c6d95
Fixed title on re-size
Ro4052 Mar 29, 2019
156d426
Added legend to sunburst
Ro4052 Mar 29, 2019
a47b0b7
Added label overflow ellipses
Ro4052 Apr 1, 2019
1fc907e
Added tooltip to sunburst
Ro4052 Apr 1, 2019
e3ecae0
Integrated series color range function into sunburst
Ro4052 Apr 1, 2019
f4bf7b8
Fixed tooltip on scroll
Ro4052 Apr 1, 2019
14faea0
Support dark theme
Ro4052 Apr 1, 2019
acf8180
Moved some data modification into treeData
Ro4052 Apr 1, 2019
b739061
Created sunburstSeries file
Ro4052 Apr 1, 2019
d5a2fe7
Use css for default fill color
Ro4052 Apr 1, 2019
a7f2cd8
Moved color function to sunburstSeries
Ro4052 Apr 1, 2019
1c718ac
Made sunburstSeries more component-like
Ro4052 Apr 1, 2019
1a7045c
Merge pull request #129 from redbearsam/feature/sunburst
Ro4052 Apr 2, 2019
51cad54
Refactor axis to use common implementation for x and y (#140)
andy-lee-eng Apr 2, 2019
f1b6fc5
Fixed themed tests
Ro4052 Apr 2, 2019
f443e75
Added sunburst integration tests
Ro4052 Apr 2, 2019
ba05ffe
Merge pull request #142 from jpmorganchase/master
matt-hooper Apr 2, 2019
8b7af78
Merge pull request #141 from redbearsam/test/sunburst-integration
matt-hooper Apr 2, 2019
cd06f1a
Improved colour-legend display and labels (#143)
andy-lee-eng Apr 2, 2019
83360b6
Tweaked sizing code for sunburst charts` (#144)
andy-lee-eng Apr 2, 2019
b5bee26
Fixed sunburst legend overlap (#145)
andy-lee-eng Apr 2, 2019
1d5f959
Match arc opacity
Ro4052 Apr 2, 2019
9350fb9
Merge pull request #146 from redbearsam/fix/sunburst-opacity
Ro4052 Apr 2, 2019
e48fac3
Sunburst centre now shows current level instead of parent
Ro4052 Apr 2, 2019
5081a36
sunburst - add labels, don't display if no crossValue is supplied
matt-hooper Apr 2, 2019
9760eae
Merge pull request #147 from redbearsam/feature/sunburst-centre
Ro4052 Apr 2, 2019
9152dfb
Merge pull request #148 from redbearsam/fix/value_labels
matt-hooper Apr 2, 2019
f41e561
update screenshots
matt-hooper Apr 2, 2019
7d4f9b7
Merge pull request #149 from redbearsam/test/update_screenshots
matt-hooper Apr 2, 2019
b7d3f82
Merge pull request #150 from redbearsam/develop
matt-hooper Apr 2, 2019
8955dc0
Allow for 2-column display when only 2 charts (#151)
andy-lee-eng Apr 2, 2019
fa05036
Merge pull request #152 from redbearsam/develop
matt-hooper Apr 2, 2019
2bf487b
Fix occasional integration test failure and some IE issues
andy-lee-eng Apr 3, 2019
ec08bd5
Merge pull request #155 from redbearsam/feature/fix-tests-and-ie
matt-hooper Apr 3, 2019
a5fa94e
merge jpmorganchase-master
matt-hooper Apr 3, 2019
e4c9e71
add parameter names for sunburst
matt-hooper Apr 3, 2019
2773b18
remove unnecessary initialiseStyles and refresh screenshots
matt-hooper Apr 3, 2019
d84ef26
Merge pull request #156 from redbearsam/feature/parameter_names
matt-hooper Apr 3, 2019
db1908a
Merge pull request #157 from redbearsam/develop
matt-hooper Apr 3, 2019
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
134 changes: 134 additions & 0 deletions packages/perspective-viewer-d3fc/src/js/axis/axisFactory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
import * as fc from "d3fc";
import {axisType} from "./axisType";
import * as none from "./noAxis";
import * as linear from "./linearAxis";
import * as time from "./timeAxis";
import * as ordinal from "./ordinalAxis";

const axisTypes = {
none,
ordinal,
time,
linear
};

export const axisFactory = settings => {
let excludeType = null;
let orient = "horizontal";
let settingName = "crossValues";
let settingValue = null;
let valueNames = ["crossValue"];

const optionalParams = ["include", "paddingStrategy", "pad"];
const optional = {};

const _factory = data => {
const useType = axisType(settings)
.excludeType(excludeType)
.settingName(settingName)
.settingValue(settingValue)();

const axis = axisTypes[useType];
const domainFunction = axis.domain().valueNames(valueNames);

optionalParams.forEach(p => {
if (optional[p] && domainFunction[p]) domainFunction[p](optional[p]);
});
if (domainFunction.orient) domainFunction.orient(orient);

const domain = domainFunction(data);
const component = axis.component ? createComponent(axis, domain, data) : defaultComponent();

return {
scale: axis.scale(),
domain,
labelFunction: axis.labelFunction,
component: {
bottom: component.bottom,
left: component.left
},
size: component.size,
decorate: component.decorate,
label: settings[settingName].map(v => v.name).join(", ")
};
};

const createComponent = (axis, domain, data) =>
axis
.component(settings)
.orient(orient)
.settingName(settingName)
.domain(domain)(data);

const defaultComponent = () => ({
bottom: fc.axisBottom,
left: fc.axisLeft,
decorate: () => {}
});

_factory.excludeType = (...args) => {
if (!args.length) {
return excludeType;
}
excludeType = args[0];
return _factory;
};

_factory.orient = (...args) => {
if (!args.length) {
return orient;
}
orient = args[0];
return _factory;
};

_factory.settingName = (...args) => {
if (!args.length) {
return settingName;
}
settingName = args[0];
return _factory;
};
_factory.settingValue = (...args) => {
if (!args.length) {
return settingValue;
}
settingValue = args[0];
return _factory;
};

_factory.valueName = (...args) => {
if (!args.length) {
return valueNames[0];
}
valueNames = [args[0]];
return _factory;
};
_factory.valueNames = (...args) => {
if (!args.length) {
return valueNames;
}
valueNames = args[0];
return _factory;
};

optionalParams.forEach(p => {
_factory[p] = (...args) => {
if (!args.length) {
return optional[p];
}
optional[p] = args[0];
return _factory;
};
});

return _factory;
};
42 changes: 42 additions & 0 deletions packages/perspective-viewer-d3fc/src/js/axis/axisLabel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
import {rebindAll} from "d3fc";
import {axisType} from "./axisType";
import {labelFunction as noLabel} from "./noAxis";
import {labelFunction as timeLabel} from "./timeAxis";
import {labelFunction as linearLabel} from "./linearAxis";
import {labelFunction as ordinalLabel} from "./ordinalAxis";

const labelFunctions = {
none: noLabel,
ordinal: ordinalLabel,
time: timeLabel,
linear: linearLabel
};

export const labelFunction = settings => {
const base = axisType(settings);
let valueName = "__ROW_PATH__";

const label = (d, i) => {
return labelFunctions[base()](valueName)(d, i);
};

rebindAll(label, base);

label.valueName = (...args) => {
if (!args.length) {
return valueName;
}
valueName = args[0];
return label;
};

return label;
};
73 changes: 73 additions & 0 deletions packages/perspective-viewer-d3fc/src/js/axis/axisType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/

export const AXIS_TYPES = {
none: "none",
ordinal: "ordinal",
time: "time",
linear: "linear"
};

export const axisType = settings => {
let settingName = "crossValues";
let settingValue = null;
let excludeType = null;

const getType = () => {
const checkTypes = types => {
const list = settingValue ? settings[settingName].filter(s => settingValue == s.name) : settings[settingName];

if (settingName == "crossValues" && list.length > 1) {
// can't do multiple values on non-ordinal cross-axis
return false;
}

return list.some(s => types.includes(s.type));
};

if (settings[settingName].length === 0) {
return AXIS_TYPES.none;
} else if (excludeType != AXIS_TYPES.time && checkTypes(["datetime"])) {
return AXIS_TYPES.time;
} else if (excludeType != AXIS_TYPES.linear && checkTypes(["integer", "float"])) {
return AXIS_TYPES.linear;
}

if (excludeType == AXIS_TYPES.ordinal) {
return AXIS_TYPES.linear;
}
return AXIS_TYPES.ordinal;
};

getType.settingName = (...args) => {
if (!args.length) {
return settingName;
}
settingName = args[0];
return getType;
};

getType.settingValue = (...args) => {
if (!args.length) {
return settingValue;
}
settingValue = args[0];
return getType;
};

getType.excludeType = (...args) => {
if (!args.length) {
return excludeType;
}
excludeType = args[0];
return getType;
};

return getType;
};
38 changes: 38 additions & 0 deletions packages/perspective-viewer-d3fc/src/js/axis/chartFactory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
import * as fc from "d3fc";

export const chartSvgFactory = (xAxis, yAxis) => chartFactory(xAxis, yAxis, fc.chartSvgCartesian);
export const chartCanvasFactory = (xAxis, yAxis) => chartFactory(xAxis, yAxis, fc.chartCanvasCartesian);

const chartFactory = (xAxis, yAxis, cartesian) => {
const chart = cartesian({
xScale: xAxis.scale,
yScale: yAxis.scale,
xAxis: xAxis.component,
yAxis: yAxis.component
})
.xDomain(xAxis.domain)
.xLabel(xAxis.label)
.xAxisHeight(xAxis.size)
.xDecorate(xAxis.decorate)
.yDomain(yAxis.domain)
.yLabel(yAxis.label)
.yAxisWidth(yAxis.size)
.yDecorate(yAxis.decorate)
.yOrient("left");

// Padding defaults can be overridden
chart.xPaddingInner && chart.xPaddingInner(1);
chart.xPaddingOuter && chart.xPaddingOuter(0.5);
chart.yPaddingInner && chart.yPaddingInner(1);
chart.yPaddingOuter && chart.yPaddingOuter(0.5);

return chart;
};
Loading