Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…to scatter-option

* 'master' of https://github.com/JennChao/carbon-charts:
  v0.36.4
  Merge pull request carbon-design-system#761 from JennChao/sparkline
  Merge pull request carbon-design-system#793 from hlyang397/update-initial-zoom-domain
  fix the defect of label tooltip not showing when using custom tooltip (carbon-design-system#787)
  v0.36.3
  Merge pull request carbon-design-system#785 from sophiiae/skeleton-with-data
  • Loading branch information
JennChao committed Sep 11, 2020
2 parents 77ebcf3 + 7201a08 commit e26af21
Show file tree
Hide file tree
Showing 21 changed files with 211 additions and 41 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.36.4](https://github.com/carbon-design-system/carbon-charts/compare/v0.36.3...v0.36.4) (2020-09-10)

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





## [0.36.3](https://github.com/carbon-design-system/carbon-charts/compare/v0.36.2...v0.36.3) (2020-09-10)

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





## [0.36.2](https://github.com/carbon-design-system/carbon-charts/compare/v0.36.1...v0.36.2) (2020-09-02)

**Note:** Version bump only for package @carbon/charts-monorepo
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
]
}
},
"version": "0.36.2"
"version": "0.36.4"
}
16 changes: 16 additions & 0 deletions packages/angular/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.36.4](https://github.com/carbon-design-system/carbon-charts/compare/v0.36.3...v0.36.4) (2020-09-10)

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





## [0.36.3](https://github.com/carbon-design-system/carbon-charts/compare/v0.36.2...v0.36.3) (2020-09-10)

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





## [0.36.2](https://github.com/carbon-design-system/carbon-charts/compare/v0.36.1...v0.36.2) (2020-09-02)

**Note:** Version bump only for package @carbon/charts-angular
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@carbon/charts-angular",
"version": "0.36.2",
"version": "0.36.4",
"description": "Carbon charting components for Angular",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -40,7 +40,7 @@
"scss"
],
"dependencies": {
"@carbon/charts": "^0.36.2"
"@carbon/charts": "^0.36.4"
},
"peerDependencies": {
"@angular/common": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0",
Expand Down
16 changes: 16 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.36.4](https://github.com/carbon-design-system/carbon-charts/compare/v0.36.3...v0.36.4) (2020-09-10)

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





## [0.36.3](https://github.com/carbon-design-system/carbon-charts/compare/v0.36.2...v0.36.3) (2020-09-10)

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





## [0.36.2](https://github.com/carbon-design-system/carbon-charts/compare/v0.36.1...v0.36.2) (2020-09-02)

**Note:** Version bump only for package @carbon/charts
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@carbon/charts",
"version": "0.36.2",
"version": "0.36.4",
"description": "Carbon charting components",
"main": "./bundle.js",
"module": "./index.js",
Expand Down
8 changes: 1 addition & 7 deletions packages/core/src/axis-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,8 @@ export class AxisChart extends Chart {
}
};

// if the chart is loading but has data, don't enable legend until loading is false
const isDataLoading = Tools.getProperty(
this.model.getOptions(),
"data",
"loading"
);
const isLegendEnabled =
this.model.getOptions().legend.enabled !== false && !isDataLoading;
this.model.getOptions().legend.enabled !== false;

// Decide the position of the legend in reference to the chart
let fullFrameComponentDirection = LayoutDirection.COLUMN;
Expand Down
37 changes: 30 additions & 7 deletions packages/core/src/components/axes/grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,34 @@ export class Grid extends Component {
backdrop: any;

render(animate = true) {
const isXGridEnabled = Tools.getProperty(
this.model.getOptions(),
"grid",
"x",
"enabled"
);
const isYGridEnabled = Tools.getProperty(
this.model.getOptions(),
"grid",
"y",
"enabled"
);

if (!isXGridEnabled && !isYGridEnabled) {
return;
}
// Draw the backdrop
this.drawBackdrop();
DOMUtils.appendOrSelect(this.backdrop, "g.x.grid");
DOMUtils.appendOrSelect(this.backdrop, "g.y.grid");
this.drawBackdrop(isXGridEnabled, isYGridEnabled);

this.drawXGrid(animate);
this.drawYGrid(animate);
if (isXGridEnabled) {
DOMUtils.appendOrSelect(this.backdrop, "g.x.grid");
this.drawXGrid(animate);
}

if (isYGridEnabled) {
DOMUtils.appendOrSelect(this.backdrop, "g.y.grid");
this.drawYGrid(animate);
}
}

drawXGrid(animate: boolean) {
Expand Down Expand Up @@ -184,7 +205,7 @@ export class Grid extends Component {
return xGridlines;
}

drawBackdrop() {
drawBackdrop(isXGridEnabled, isYGridEnabled) {
const svg = this.parent;

const mainXScale = this.services.cartesianScales.getMainXScale();
Expand All @@ -197,7 +218,9 @@ export class Grid extends Component {
this.backdrop = DOMUtils.appendOrSelect(svg, "svg.chart-grid-backdrop");
const backdropRect = DOMUtils.appendOrSelect(
this.backdrop,
"rect.chart-grid-backdrop"
isXGridEnabled || isYGridEnabled
? "rect.chart-grid-backdrop.stroked"
: "rect.chart-grid-backdrop"
);

this.backdrop
Expand Down
16 changes: 15 additions & 1 deletion packages/core/src/components/axes/ruler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ export class Ruler extends Component {
domainValue: number;
originalData: any;
}[];
isXGridEnabled = Tools.getProperty(
this.model.getOptions(),
"grid",
"x",
"enabled"
);
isYGridEnabled = Tools.getProperty(
this.model.getOptions(),
"grid",
"y",
"enabled"
);

render() {
this.drawBackdrop();
Expand Down Expand Up @@ -231,7 +243,9 @@ export class Ruler extends Component {
this.backdrop = DOMUtils.appendOrSelect(svg, "svg.chart-grid-backdrop");
const backdropRect = DOMUtils.appendOrSelect(
this.backdrop,
"rect.chart-grid-backdrop"
this.isXGridEnabled || this.isYGridEnabled
? "rect.chart-grid-backdrop.stroked"
: "rect.chart-grid-backdrop"
);

this.backdrop
Expand Down
48 changes: 34 additions & 14 deletions packages/core/src/components/axes/zoom-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,6 @@ export class ZoomBar extends Component {
Events.ZoomBar.UPDATE,
this.render.bind(this)
);

// get initZoomDomain
const initialZoomDomain = Tools.getProperty(
this.model.getOptions(),
"zoomBar",
"top",
"initialZoomDomain"
);
if (initialZoomDomain !== null) {
this.model.set(
{ zoomDomain: initialZoomDomain },
{ skipUpdate: true }
);
}
}

render(animate = true) {
Expand Down Expand Up @@ -128,6 +114,40 @@ export class ZoomBar extends Component {
// add value 0 to the extended domain for zoom bar area graph
this.compensateDataForDefaultDomain(zoomBarData, defaultDomain);

// get old initialZoomDomain from model
const oldInitialZoomDomain = this.model.get("initialZoomDomain");
// get new initialZoomDomain from option
const newInitialZoomDomain = Tools.getProperty(
this.model.getOptions(),
"zoomBar",
"top",
"initialZoomDomain"
);

// update initialZoomDomain and set zoomDomain in model only if the option is changed
// not the same object, and both start date and end date are not equal
if (
!(
oldInitialZoomDomain === newInitialZoomDomain ||
(oldInitialZoomDomain &&
newInitialZoomDomain &&
oldInitialZoomDomain[0].valueOf() ===
newInitialZoomDomain[0].valueOf() &&
oldInitialZoomDomain[1].valueOf() ===
newInitialZoomDomain[1].valueOf())
)
) {
this.model.set(
{
initialZoomDomain: newInitialZoomDomain,
zoomDomain: newInitialZoomDomain
? newInitialZoomDomain
: defaultDomain
},
{ skipUpdate: true }
);
}

this.xScale.range([axesLeftMargin, width]).domain(defaultDomain);

// keep max selection range
Expand Down
9 changes: 7 additions & 2 deletions packages/core/src/components/essentials/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,16 @@ export class Tooltip extends Component {
"customHTML"
)
) {
tooltipTextContainer.html(
if (e.detail.content) {
const labelHTML = `<div class="title-tooltip">${e.detail.content}</div>`;
tooltipTextContainer.html(labelHTML);
} else {
tooltipTextContainer.html(
this.model
.getOptions()
.tooltip.customHTML(data, defaultHTML)
);
);
}
} else {
// Use default tooltip
tooltipTextContainer.html(defaultHTML);
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ const legend: LegendOptions = {
*/
export const grid: GridOptions = {
x: {
// set enable to false will not draw grid and stroke of grid backdrop
enabled: true,
numberOfTicks: 15
},
y: {
// set enable to false will not draw grid and stroke of grid backdrop
enabled: true,
numberOfTicks: 5
}
};
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/interfaces/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ export interface ThresholdOptions {

export interface GridOptions {
y?: {
enabled?: boolean;
numberOfTicks?: number;
};
x?: {
enabled?: boolean;
numberOfTicks?: number;
};
}
Expand Down
10 changes: 10 additions & 0 deletions packages/core/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ export class ChartModel {
}

getDataGroups() {
const isDataLoading = Tools.getProperty(
this.getOptions(),
"data",
"loading"
);

// No data should be displayed while data is still loading
if (isDataLoading) {
return [];
}
return this.get("dataGroups");
}

Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/styles/components/_grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
} @else {
fill: $ui-background;
}
}
rect.chart-grid-backdrop.stroked {
stroke: $ui-03;
}

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

## [0.36.4](https://github.com/carbon-design-system/carbon-charts/compare/v0.36.3...v0.36.4) (2020-09-10)

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





## [0.36.3](https://github.com/carbon-design-system/carbon-charts/compare/v0.36.2...v0.36.3) (2020-09-10)

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





## [0.36.2](https://github.com/carbon-design-system/carbon-charts/compare/v0.36.1...v0.36.2) (2020-09-02)

**Note:** Version bump only for package @carbon/charts-react
Expand Down
4 changes: 2 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@carbon/charts-react",
"version": "0.36.2",
"version": "0.36.4",
"description": "Carbon charting components for React",
"main": "./bundle.js",
"module": "./index.js",
Expand Down Expand Up @@ -46,7 +46,7 @@
},
"homepage": "https://github.com/carbon-design-system/carbon-charts#readme",
"dependencies": {
"@carbon/charts": "^0.36.2"
"@carbon/charts": "^0.36.4"
},
"peerDependencies": {
"react": "^16.6.3",
Expand Down
Loading

0 comments on commit e26af21

Please sign in to comment.