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

Radar #581

Merged
merged 96 commits into from
May 8, 2020
Merged

Radar #581

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
40bf95a
Radar setup
ilariaventurini Apr 16, 2020
6ff0c54
Radar: create center and spokes
ilariaventurini Apr 16, 2020
9af448d
Radar refactor
ilariaventurini Apr 16, 2020
52efcac
Radar: Do not render anything if width or height are 0
ilariaventurini Apr 16, 2020
6180439
Radar: create blobs (wip)
ilariaventurini Apr 17, 2020
f42d611
Radar: set colors
ilariaventurini Apr 17, 2020
0905acc
Radar: refactor
ilariaventurini Apr 17, 2020
312ab23
Radar: create x axes
ilariaventurini Apr 17, 2020
1ccd8b4
Radar: refactor
ilariaventurini Apr 17, 2020
6e6f254
Radar: fix color opacity
ilariaventurini Apr 17, 2020
c152a90
Radar: Compute ticks with a minimum value
ilariaventurini Apr 20, 2020
27dd531
Radar: draw y axis
ilariaventurini Apr 20, 2020
de45c83
Radar: y axes start from the min tick value
ilariaventurini Apr 20, 2020
d1b240f
Radar: add exit for x axes
ilariaventurini Apr 20, 2020
9dae270
Radar: blob creation refactor
ilariaventurini Apr 20, 2020
7be6201
Radar: rename classes
ilariaventurini Apr 20, 2020
2168108
Radar: fix class name
ilariaventurini Apr 20, 2020
e67481e
Radar: mini refactor
ilariaventurini Apr 21, 2020
083b5ed
Radar: fix blobs bind
ilariaventurini Apr 21, 2020
fe97673
Radar: style changes
ilariaventurini Apr 21, 2020
0ad42c6
Radar: fix min radius logic
ilariaventurini Apr 21, 2020
118d8f0
Radar: bind displayData to x axes not data
ilariaventurini Apr 21, 2020
127847d
Radar: add transitions
ilariaventurini Apr 21, 2020
83ebbb5
Radar: add key labels (wip)
ilariaventurini Apr 21, 2020
bc9d5b8
Radar: change margin value
ilariaventurini Apr 21, 2020
6878a53
Radar: fix labels position
ilariaventurini Apr 22, 2020
e1d0a2c
fix(core): fix backwards compatibility for pie/donut (#576)
natashadecoste Apr 17, 2020
e0e994c
provide all datapoint info to stacked bar tooltips (#573)
theiliad Apr 17, 2020
9788a82
Merge pull request #574 from theiliad/axis-formatters
theiliad Apr 17, 2020
c384d3a
v0.30.12
carbon-bot Apr 17, 2020
13d48c9
fix line graph update issues
theiliad Apr 20, 2020
66af81e
v0.30.13
carbon-bot Apr 20, 2020
a9740d1
fix(core): Support for Horizontal Line and Scatter Chart
SerenaG Apr 20, 2020
e8462be
Change method name
SerenaG Apr 21, 2020
58d7683
v0.30.14
carbon-bot Apr 21, 2020
904bc83
Fix linting problem about methods order
ilariaventurini Apr 22, 2020
e50224f
v0.30.15
carbon-bot Apr 22, 2020
b845a7f
Code comments for tools.ts (#416)
natashadecoste Apr 23, 2020
dc0ffae
Merge pull request #588 from accurat/invalid-time-value-bug
ilariaventurini Apr 23, 2020
5c2a1c6
v0.30.16
carbon-bot Apr 23, 2020
1c3dae3
remove bbox dependency on pie labels
theiliad Apr 23, 2020
783822d
v0.30.17
carbon-bot Apr 23, 2020
99c1e0a
Radar: fix y axes transitions
ilariaventurini Apr 23, 2020
77db7e1
Radar: use the new .join d3 method
ilariaventurini Apr 24, 2020
bf0cdc1
Use join to manage enter, update, exit logic
ilariaventurini Apr 27, 2020
62ef537
Radar: fill missing data
ilariaventurini Apr 27, 2020
df4bf57
Radar: fix animations but need a refactor
ilariaventurini Apr 27, 2020
99c25b0
Radar: add events
ilariaventurini Apr 27, 2020
d86ebbd
Radar: add tooltip
ilariaventurini Apr 28, 2020
2cfbf97
Radar: miss an import
ilariaventurini Apr 28, 2020
3c0a100
Radar: use groupMapsTo
ilariaventurini Apr 29, 2020
aa394f8
Radar: number of spokes doesn't change
ilariaventurini Apr 29, 2020
b4ab00e
Radar: use groupMapsTo for data mapping
ilariaventurini Apr 29, 2020
c22baa4
Radar: show NA when data are missing
ilariaventurini Apr 29, 2020
8564cec
Radar: add y labels
ilariaventurini Apr 29, 2020
875044f
Radar: remove events on blobs
ilariaventurini Apr 29, 2020
4ec6441
Radar: left align
ilariaventurini Apr 29, 2020
c86ef05
Radar: create rectangles over x axis
ilariaventurini Apr 30, 2020
0640d69
Radar: make x axis dashed on mouse over
ilariaventurini Apr 30, 2020
a8e4572
Radar: add dots
ilariaventurini May 1, 2020
24fed6f
Radar: move utility functions in another file
ilariaventurini May 1, 2020
542021d
Radar: fix radial label placement for negative angles
ilariaventurini May 2, 2020
96ff06c
Radar: refactor
ilariaventurini May 2, 2020
82cc37a
Radar: radialLabelPlacement refactor
ilariaventurini May 4, 2020
f4232bc
Radar: better logic to center chart
ilariaventurini May 4, 2020
989858e
Radar: fix x axis style when overed
ilariaventurini May 4, 2020
4b16783
Radar: change blobs opacity
ilariaventurini May 4, 2020
bf8b8eb
Radar: create y axes transition
ilariaventurini May 4, 2020
fa2f064
Radar: create x axes transition
ilariaventurini May 4, 2020
5d063aa
Radar: create blobs transition
ilariaventurini May 4, 2020
687db10
Radar: x and y labels transition
ilariaventurini May 4, 2020
3f7cc75
Radar: fix transitions
ilariaventurini May 4, 2020
e34147f
Radar: more left space for y labels
ilariaventurini May 4, 2020
343a5de
Radar: remove unused imports
ilariaventurini May 4, 2020
5fb07f8
Radar: use the right transitions
ilariaventurini May 4, 2020
f548da6
Radar: remove logs
ilariaventurini May 4, 2020
245e3a6
Radar: remove debug stuff
ilariaventurini May 4, 2020
d111848
Merge branch 'master' into radar
ilariaventurini May 4, 2020
33e016e
Radar: update y labels
ilariaventurini May 4, 2020
13ca9db
Radar: fix Firefox bug
ilariaventurini May 5, 2020
7f93d98
Radar: move constants to configuration
ilariaventurini May 5, 2020
b89dae0
Radar: rename variables
ilariaventurini May 5, 2020
f3bfc05
Radar: fix typo
ilariaventurini May 5, 2020
e29769e
Radar: update comments
ilariaventurini May 5, 2020
b95a96e
Radar: move lodash methods inside Tools
ilariaventurini May 5, 2020
6abb99d
Radar: add examples and make radar more generic
ilariaventurini May 6, 2020
7c2e47d
Radar: fix tooltip value
ilariaventurini May 6, 2020
7066dc2
Radar: fix tooltip data order
ilariaventurini May 6, 2020
158be11
Radar: fix radar default formatter
ilariaventurini May 6, 2020
f5e64df
Radar: fix showing dots
ilariaventurini May 6, 2020
ee6bf99
Radar: use variable instead of recompute value
ilariaventurini May 6, 2020
2dd2b3f
Radar: create enums from textAnchor and dominantBaseline values
ilariaventurini May 7, 2020
3f349c3
Radar: put dots radius to radar configuration
ilariaventurini May 7, 2020
d2db359
Radar: use tabs instead of spaces
ilariaventurini May 7, 2020
3a94dbf
Radar: use helper function for accesing properties
ilariaventurini May 7, 2020
7cdc17c
Radar: get property from options
ilariaventurini May 7, 2020
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
27 changes: 27 additions & 0 deletions packages/core/demo/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as pieDemos from "./pie";
import * as scatterDemos from "./scatter";
import * as stepDemos from "./step";
import * as timeSeriesAxisDemos from "./time-series-axis";
import * as radarDemos from "./radar";

export * from "./bar";
export * from "./bubble";
Expand All @@ -14,6 +15,7 @@ export * from "./line";
export * from "./pie";
export * from "./scatter";
export * from "./step";
export * from "./radar";

import {
createChartSandbox,
Expand Down Expand Up @@ -66,6 +68,11 @@ export const chartTypes = {
vanilla: "DonutChart",
angular: "ibm-donut-chart",
vue: "ccv-donut-chart"
},
RadarChart: {
vanilla: "RadarChart",
angular: "ibm-radar-chart",
vue: "ccv-radar-chart"
}
};

Expand Down Expand Up @@ -336,6 +343,26 @@ let allDemoGroups = [
chartType: chartTypes.LineChart
}
]
},
{
title: "Radar",
demos: [
{
data: radarDemos.radarData,
options: radarDemos.radarOptions,
chartType: chartTypes.RadarChart
},
{
data: radarDemos.radarWithMissingDataData,
options: radarDemos.radarWithMissingDataOptions,
chartType: chartTypes.RadarChart
},
{
data: radarDemos.radarDenseData,
options: radarDemos.radarDenseOptions,
chartType: chartTypes.RadarChart
}
]
}
] as any;

Expand Down
103 changes: 103 additions & 0 deletions packages/core/demo/data/radar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@

// simple radar
export const radarData = [
{ product: "Product 1", feature: "Price", score: 60 },
{ product: "Product 1", feature: "Usability", score: 92 },
{ product: "Product 1", feature: "Availability", score: 5 },
{ product: "Product 1", feature: "Performance", score: 85 },
{ product: "Product 1", feature: "Quality", score: 60 },
{ product: "Product 2", feature: "Price", score: 70 },
{ product: "Product 2", feature: "Usability", score: 63 },
{ product: "Product 2", feature: "Availability", score: 78 },
{ product: "Product 2", feature: "Performance", score: 50 },
{ product: "Product 2", feature: "Quality", score: 30 }
];
export const radarOptions = {
title: "Radar",
radar: {
axes: {
angle: "feature",
value: "score"
}
},
data: {
groupMapsTo: "product"
}
};

// radar with missing data
export const radarWithMissingDataData = [
{ group: "Sugar", key: "London", value: 25 },
{ group: "Oil", key: "London", value: 6 },
{ group: "Water", key: "London", value: 12 },
{ group: "Sugar", key: "Milan", value: 13 },
{ group: "Oil", key: "Milan", value: 6 },
{ group: "Water", key: "Milan", value: 28 },
{ group: "Sugar", key: "Paris", value: 19 },
{ group: "Oil", key: "Paris", value: 16 },
{ group: "Water", key: "Paris", value: 10 },
{ group: "Sugar", key: "New York", value: 11 },
{ group: "Oil", key: "New York", value: 18 },
{ group: "Water", key: "New York", value: 8 },
{ group: "Sugar", key: "Sydney", value: 12 },
{ group: "Oil", key: "Sydney", value: 16 }
];
export const radarWithMissingDataOptions = {
title: "Radar - Missing data"
};

// radar dense
export const radarDenseData = [
{ month: "January", activity: "Eating", hoursAvg: 2 },
{ month: "January", activity: "Drinking", hoursAvg: 6 },
{ month: "January", activity: "Sleeping", hoursAvg: 6 },
{ month: "January", activity: "Working", hoursAvg: 8 },
{ month: "January", activity: "Walking", hoursAvg: 1 },
{ month: "January", activity: "Running", hoursAvg: 0.5 },
{ month: "January", activity: "Cycling", hoursAvg: 1 },
{ month: "January", activity: "Swimming", hoursAvg: 0 },
{ month: "February", activity: "Eating", hoursAvg: 1.5 },
{ month: "February", activity: "Drinking", hoursAvg: 9 },
{ month: "February", activity: "Sleeping", hoursAvg: 7 },
{ month: "February", activity: "Working", hoursAvg: 9 },
{ month: "February", activity: "Walking", hoursAvg: 2 },
{ month: "February", activity: "Running", hoursAvg: 2 },
{ month: "February", activity: "Cycling", hoursAvg: 0 },
{ month: "February", activity: "Swimming", hoursAvg: 1.5 },
{ month: "March", activity: "Eating", hoursAvg: 3 },
{ month: "March", activity: "Drinking", hoursAvg: 5 },
{ month: "March", activity: "Sleeping", hoursAvg: 5 },
{ month: "March", activity: "Working", hoursAvg: 6 },
{ month: "March", activity: "Walking", hoursAvg: 3 },
{ month: "March", activity: "Running", hoursAvg: 9 },
{ month: "March", activity: "Cycling", hoursAvg: 1 },
{ month: "March", activity: "Swimming", hoursAvg: 7 },
{ month: "April", activity: "Eating", hoursAvg: 5 },
{ month: "April", activity: "Drinking", hoursAvg: 1 },
{ month: "April", activity: "Sleeping", hoursAvg: 4 },
{ month: "April", activity: "Working", hoursAvg: 2 },
{ month: "April", activity: "Walking", hoursAvg: 5 },
{ month: "April", activity: "Running", hoursAvg: 4 },
{ month: "April", activity: "Cycling", hoursAvg: 6 },
{ month: "April", activity: "Swimming", hoursAvg: 3 },
{ month: "May", activity: "Eating", hoursAvg: 7 },
{ month: "May", activity: "Drinking", hoursAvg: 0 },
{ month: "May", activity: "Sleeping", hoursAvg: 5 },
{ month: "May", activity: "Working", hoursAvg: 4 },
{ month: "May", activity: "Walking", hoursAvg: 8 },
{ month: "May", activity: "Running", hoursAvg: 2 },
{ month: "May", activity: "Cycling", hoursAvg: 3 },
{ month: "May", activity: "Swimming", hoursAvg: 1 }
];
export const radarDenseOptions = {
title: "Radar - Dense",
radar: {
axes: {
angle: "activity",
value: "hoursAvg"
}
},
data: {
groupMapsTo: "month"
}
};
1 change: 1 addition & 0 deletions packages/core/src/charts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from "./line";
export * from "./scatter";
export * from "./pie";
export * from "./donut";
export * from "./radar";
53 changes: 53 additions & 0 deletions packages/core/src/charts/radar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Internal Imports
import { Chart } from "../chart";
import * as Configuration from "../configuration";
import {
ChartConfig,
RadarChartOptions
} from "../interfaces/index";
import { Tools } from "../tools";

// Components
import {
// the imports below are needed because of typescript bug (error TS4029)
Legend,
LayoutComponent,
TooltipRadar
} from "../components/index";
import { Radar } from "../components/graphs/radar";

export class RadarChart extends Chart {
// TODO - Optimize the use of "extending"
constructor(holder: Element, chartConfigs: ChartConfig<RadarChartOptions>, extending = false) {
super(holder, chartConfigs);

// TODO - Optimize the use of "extending"
if (extending) {
return;
}

// Merge the default options for this chart
// With the user provided options
this.model.setOptions(
Tools.mergeDefaultChartOptions(
Configuration.options.radarChart,
chartConfigs.options
)
);

// Initialize data, services, components etc.
this.init(holder, chartConfigs);
}

getComponents() {
// Specify what to render inside the graph-frame
const graphFrameComponents = [
new Radar(this.model, this.services)
];

// get the base chart components and export with tooltip
const components: any[] = this.getChartComponents(graphFrameComponents);
components.push(new TooltipRadar(this.model, this.services));
return components;
}
}
33 changes: 33 additions & 0 deletions packages/core/src/components/essentials/tooltip-radar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Tooltip } from "./tooltip";
import { Tools } from "../../tools";

export class TooltipRadar extends Tooltip {
getMultilineTooltipHTML(data: any) {
const options = this.model.getOptions();
const { groupMapsTo } = options.data;
const { angle, value } = options.radar.axes;

// sort them so they are in the same order as the graph
data.sort((a, b) => b[value] - a[value]);

return "<ul class='multi-tooltip'>" +
data.map(datum => {
const userProvidedValueFormatter = Tools.getProperty(options, "tooltip", "valueFormatter");
const formattedValue = userProvidedValueFormatter
? userProvidedValueFormatter(datum[value])
: datum[value];

// For the tooltip color, we always want the normal stroke color, not dynamically determined by data value.
const indicatorColor = this.model.getStrokeColor(datum[groupMapsTo]);

return `
<li>
<div class="datapoint-tooltip">
<a style="background-color:${indicatorColor}" class="tooltip-color"></a>
<p class="label">${datum[groupMapsTo]}</p>
<p class="value">${formattedValue}</p>
</div>
</li>`;
}).join("") + "</ul>";
}
}
Loading