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

fix(core): fix minor bug with data values that are undefined #1007

Merged
merged 3 commits into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 2 additions & 22 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
All notable changes to this project will be documented in this file. See
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.41.61](https://github.com/carbon-design-system/carbon-charts/compare/v0.41.60...v0.41.61) (2021-04-28)

**Note:** Version bump only for package @carbon/charts





# Change Log

All notable changes to this project will be documented in this file. See
Expand All @@ -20,34 +16,18 @@ All notable changes to this project will be documented in this file. See

**Note:** Version bump only for package @carbon/charts





## [0.41.59](https://github.com/carbon-design-system/carbon-charts/compare/v0.41.58...v0.41.59) (2021-04-27)

**Note:** Version bump only for package @carbon/charts





## [0.41.58](https://github.com/carbon-design-system/carbon-charts/compare/v0.41.57...v0.41.58) (2021-04-26)

**Note:** Version bump only for package @carbon/charts





## [0.41.57](https://github.com/carbon-design-system/carbon-charts/compare/v0.41.56...v0.41.57) (2021-04-20)

**Note:** Version bump only for package @carbon/charts





# Change Log

All notable changes to this project will be documented in this file. See
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/essentials/tooltip-axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class AxisChartsTooltip extends Tooltip {
label: domainLabel,
value: domainValue,
},
...(value.length === 2
...(Array.isArray(value) && value.length === 2
? [
{
label: 'Start',
Expand Down
23 changes: 11 additions & 12 deletions packages/core/src/components/graphs/area-stacked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
import { Component } from '../component';
import { Tools } from '../../tools';
import * as Configuration from '../../configuration';
import {
Roles,
ScaleTypes,
Events,
ColorClassNameTypes,
CartesianOrientations,
} from '../../interfaces';
import { Roles, Events, ColorClassNameTypes } from '../../interfaces';

// D3 Imports
import { area } from 'd3-shape';
Expand Down Expand Up @@ -65,7 +59,7 @@ export class StackedArea extends Component {

const areas = svg
.selectAll('path.area')
.data(stackedData, (d) => d[0][groupMapsTo]);
.data(stackedData, (d) => Tools.getProperty(d, 0, groupMapsTo));

// D3 area generator function
this.areaGenerator = area()
Expand All @@ -86,16 +80,18 @@ export class StackedArea extends Component {

enteringAreas
.merge(areas)
.data(stackedData, (d) => d[0][groupMapsTo])
.data(stackedData, (d) => Tools.getProperty(d, 0, groupMapsTo))
.attr('class', 'area')
.attr('class', (d) =>
this.model.getColorClassName({
classNameTypes: [ColorClassNameTypes.FILL],
dataGroupName: d[0][groupMapsTo],
dataGroupName: Tools.getProperty(d, 0, groupMapsTo),
originalClassName: 'area',
})
)
.style('fill', (d) => self.model.getFillColor(d[0][groupMapsTo]))
.style('fill', (d) =>
self.model.getFillColor(Tools.getProperty(d, 0, groupMapsTo))
)
.attr('role', Roles.GRAPHICS_SYMBOL)
.attr('aria-roledescription', 'area')
.transition(
Expand All @@ -119,7 +115,10 @@ export class StackedArea extends Component {
this.services.transitions.getTransition('legend-hover-area')
)
.attr('opacity', (d) => {
if (d[0][groupMapsTo] !== hoveredElement.datum().name) {
if (
Tools.getProperty(d, 0, groupMapsTo) !==
hoveredElement.datum().name
) {
return Configuration.area.opacity.unselected;
}

Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/components/graphs/area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ export class Area extends Component {
);
}

const areas = svg.selectAll('path.area').data(groupedData);
const areas = svg
.selectAll('path.area')
.data(groupedData, (group) => group.name);

const chartprefix = Tools.getProperty(
this.getOptions(),
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/graphs/bar-simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class SimpleBar extends Bar {
barWidth / 2;
const x1 = x0 + barWidth;
let y0, y1;
if (value.length === 2) {
if (Array.isArray(value) && value.length === 2) {
y0 = this.services.cartesianScales.getRangeValue(value[0]);
y1 = this.services.cartesianScales.getRangeValue(
value[1],
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/graphs/bar-stacked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class StackedBar extends Bar {
// Update data on all bar groups
const barGroups = svg
.selectAll('g.bars')
.data(stackData, (d) => (d.length > 0 ? d[0][groupMapsTo] : null));
.data(stackData, (d) => Tools.getProperty(d, 0, groupMapsTo));

// Remove elements that need to be exited
// We need exit at the top here to make sure that
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/graphs/line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class Line extends Component {
d
);
return {
name: d[0][groupMapsTo],
name: Tools.getProperty(d, 0, groupMapsTo),
data: d.map((datum) => ({
[domainIdentifier]: datum.data.sharedStackKey,
[groupMapsTo]: datum[groupMapsTo],
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/graphs/scatter-stacked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class StackedScatter extends Scatter {
// Update data on dot groups
const circleGroups = svg
.selectAll('g.dots')
.data(stackedData, (d) => d[0][groupMapsTo]);
.data(stackedData, (d) => Tools.getProperty(d, 0, groupMapsTo));

// Remove dot groups that need to be removed
circleGroups.exit().attr('opacity', 0).remove();
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/configuration-non-customizable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const color = {

export const area = {
opacity: {
unselected: 0,
unselected: 0.05,
selected: 0.4,
},
};
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/services/scales-cartesian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ export class CartesianScales extends Service {

displayData.forEach((datum) => {
const value = datum[mapsTo];
if (value.length === 2) {
if (Array.isArray(value) && value.length === 2) {
allDataValues.push(value[0]);
allDataValues.push(value[1]);
} else {
Expand Down
24 changes: 2 additions & 22 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
All notable changes to this project will be documented in this file. See
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.41.61](https://github.com/carbon-design-system/carbon-charts/compare/v0.41.60...v0.41.61) (2021-04-28)

**Note:** Version bump only for package @carbon/charts-react





# Change Log

All notable changes to this project will be documented in this file. See
Expand All @@ -20,34 +16,18 @@ All notable changes to this project will be documented in this file. See

**Note:** Version bump only for package @carbon/charts-react





## [0.41.59](https://github.com/carbon-design-system/carbon-charts/compare/v0.41.58...v0.41.59) (2021-04-27)

**Note:** Version bump only for package @carbon/charts-react





## [0.41.58](https://github.com/carbon-design-system/carbon-charts/compare/v0.41.57...v0.41.58) (2021-04-26)

**Note:** Version bump only for package @carbon/charts-react





## [0.41.57](https://github.com/carbon-design-system/carbon-charts/compare/v0.41.56...v0.41.57) (2021-04-20)

**Note:** Version bump only for package @carbon/charts-react





# Change Log

All notable changes to this project will be documented in this file. See
Expand Down
20 changes: 0 additions & 20 deletions packages/vue/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,22 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @carbon/charts-vue





## [0.41.60](https://github.com/carbon-design-system/carbon-charts/compare/v0.41.59...v0.41.60) (2021-04-28)

**Note:** Version bump only for package @carbon/charts-vue





## [0.41.59](https://github.com/carbon-design-system/carbon-charts/compare/v0.41.58...v0.41.59) (2021-04-27)

**Note:** Version bump only for package @carbon/charts-vue





## [0.41.58](https://github.com/carbon-design-system/carbon-charts/compare/v0.41.57...v0.41.58) (2021-04-26)

**Note:** Version bump only for package @carbon/charts-vue





## [0.41.57](https://github.com/carbon-design-system/carbon-charts/compare/v0.41.56...v0.41.57) (2021-04-20)

**Note:** Version bump only for package @carbon/charts-vue





## [0.41.56](https://github.com/carbon-design-system/carbon-charts/compare/v0.41.55...v0.41.56) (2021-04-16)

**Note:** Version bump only for package @carbon/charts-vue
Expand Down