Skip to content

Commit

Permalink
Merge branch 'test-tooltip' into title-truncation
Browse files Browse the repository at this point in the history
  • Loading branch information
natashadecoste committed Oct 28, 2019
2 parents a4bda5e + 0d04b04 commit e515734
Show file tree
Hide file tree
Showing 23 changed files with 220 additions and 62 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.16.24](https://github.com/IBM/carbon-charts/compare/v0.16.23...v0.16.24) (2019-10-25)


### Bug Fixes

* **core, react, angular, vue:** default width & height to 100%, and call setOptions on option change ([db251b4](https://github.com/IBM/carbon-charts/commit/db251b4))





## [0.16.23](https://github.com/IBM/carbon-charts/compare/v0.16.22...v0.16.23) (2019-10-25)

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





## [0.16.22](https://github.com/IBM/carbon-charts/compare/v0.16.21...v0.16.22) (2019-10-25)

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





## [0.16.21](https://github.com/IBM/carbon-charts/compare/v0.16.20...v0.16.21) (2019-10-24)


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.16.21"
"version": "0.16.24"
}
27 changes: 27 additions & 0 deletions packages/angular/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.16.24](https://github.com/IBM/carbon-charts/compare/v0.16.23...v0.16.24) (2019-10-25)


### Bug Fixes

* **core, react, angular, vue:** default width & height to 100%, and call setOptions on option change ([db251b4](https://github.com/IBM/carbon-charts/commit/db251b4))





## [0.16.23](https://github.com/IBM/carbon-charts/compare/v0.16.22...v0.16.23) (2019-10-25)

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





## [0.16.22](https://github.com/IBM/carbon-charts/compare/v0.16.21...v0.16.22) (2019-10-25)

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





## [0.16.21](https://github.com/IBM/carbon-charts/compare/v0.16.20...v0.16.21) (2019-10-24)


Expand Down
4 changes: 2 additions & 2 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "../../node_modules/ng-packagr/package.schema.json",
"name": "@carbon/charts-angular",
"version": "0.16.21",
"version": "0.16.24",
"description": "Carbon charting components for Angular",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -40,7 +40,7 @@
"scss"
],
"dependencies": {
"@carbon/charts": "^0.16.21"
"@carbon/charts": "^0.16.24"
},
"peerDependencies": {
"@angular/common": "^6.0.0 || ^7.0.0",
Expand Down
8 changes: 2 additions & 6 deletions packages/angular/src/base-chart.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class BaseChart implements AfterViewInit, OnInit {
this._data = newData;

if (dataExistsAlready) {
this.chart.setData(newData);
this.chart.model.setData(newData);
}
}

Expand All @@ -47,7 +47,7 @@ export class BaseChart implements AfterViewInit, OnInit {
this._options = newOptions;

if (optionsExistAlready) {
this.chart.setOptions(newOptions);
this.chart.model.setOptions(newOptions);
}
}

Expand Down Expand Up @@ -85,15 +85,11 @@ export class BaseChart implements AfterViewInit, OnInit {
// Width prop is mandatory for the wrappers
if (this.width) {
this.options.width = this.width;
} else if (!this.options.width) {
console.error("Missing `width` Input!");
}

// Height prop is mandatory for the wrappers
if (this.height) {
this.options.height = this.height;
} else if (!this.options.height) {
console.error("Missing `height` Input!");
}
}

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

## [0.16.24](https://github.com/IBM/carbon-charts/compare/v0.16.23...v0.16.24) (2019-10-25)


### Bug Fixes

* **core, react, angular, vue:** default width & height to 100%, and call setOptions on option change ([db251b4](https://github.com/IBM/carbon-charts/commit/db251b4))





## [0.16.23](https://github.com/IBM/carbon-charts/compare/v0.16.22...v0.16.23) (2019-10-25)

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





## [0.16.22](https://github.com/IBM/carbon-charts/compare/v0.16.21...v0.16.22) (2019-10-25)

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





## [0.16.21](https://github.com/IBM/carbon-charts/compare/v0.16.20...v0.16.21) (2019-10-24)


Expand Down
30 changes: 15 additions & 15 deletions packages/core/demo/chart-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ export const chartTypes = [
options: simpleBarOptions,
data: simpleBarData
},
{
id: "scatter-time-series",
options: scatterTimeSeriesOptions,
data: scatterTimeSeriesData
},
{
id: "scatter",
options: scatterOptions,
Expand All @@ -63,6 +68,16 @@ export const chartTypes = [
options: stackedBarTimeSeriesOptions,
data: stackedBarTimeSeriesData
},
{
id: "pie",
options: pieOptions,
data: pieData
},
{
id: "donut",
options: donutOptions,
data: donutData
},
{
id: "line-time-series",
options: lineTimeSeriesOptions,
Expand All @@ -82,20 +97,5 @@ export const chartTypes = [
id: "line-step-time-series",
options: stepTimeSeriesOptions,
data: stepTimeSeriesData
},
{
id: "pie",
options: pieOptions,
data: pieData
},
{
id: "donut",
options: donutOptions,
data: donutData
},
{
id: "scatter-time-series",
options: scatterTimeSeriesOptions,
data: scatterTimeSeriesData
}
];
7 changes: 2 additions & 5 deletions packages/core/demo/demo-data/line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,10 @@ export const scatterTimeSeriesData = lineTimeSeriesData;

export const scatterTimeSeriesOptions = {
title: "Scatter (time series)",
legend: {
position: "top"
},
axes: {
bottom: {
title: "2018 Annual Sales Figures",
type: "labels",
title: "2019 Annual Sales Figures",
type: "time",
secondary: true
},
left: {
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.16.21",
"version": "0.16.24",
"description": "Carbon charting components",
"main": "./bundle.js",
"module": "./index.js",
Expand Down
28 changes: 15 additions & 13 deletions packages/core/src/components/essentials/tooltip-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,25 @@ export class TooltipBar extends Tooltip {

const hoveredElement = e.detail.hoveredElement.node();

// if there is a provided tooltip HTML function
if (Tools.getProperty(this.model.getOptions(), "tooltip", "customHTML")) {
tooltipTextContainer.html(this.model.getOptions().tooltip.customHTML(hoveredElement));
} else if (e.detail.multidata) {
let defaultTooltip;
if (e.detail.multidata) {
// multi tooltip
tooltipTextContainer.html(this.getMultilineTooltipHTML(e.detail.multidata));
// Position the tooltip
this.positionTooltip();
defaultTooltip = this.getMultilineTooltipHTML(e.detail.multidata);
} else {
const data = e.detail.hoveredElement.datum();
tooltipTextContainer.html(this.getTooltipHTML(data));

const position = this.getTooltipPosition(hoveredElement);
defaultTooltip = this.getTooltipHTML(e.detail.hoveredElement.datum());
}

// Position the tooltip relative to the bars
this.positionTooltip(position);
// if there is a provided tooltip HTML function call it and pass the defaultTooltip
if (Tools.getProperty(this.model.getOptions(), "tooltip", "customHTML")) {
tooltipTextContainer.html(this.model.getOptions().tooltip.customHTML(hoveredElement, defaultTooltip));
} else {
// default tooltip
tooltipTextContainer.html(defaultTooltip);
}

const position = this.getTooltipPosition(hoveredElement);
// Position the tooltip relative to the bars
this.positionTooltip(e.detail.multidata ? undefined : position );
// Fade in
this.tooltip.classed("hidden", false);
}
Expand Down
18 changes: 12 additions & 6 deletions packages/core/src/components/essentials/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,21 @@ export class Tooltip extends Component {

let data = select(event.target).datum() as any;

// if there is a provided tooltip HTML function
if (Tools.getProperty(this.model.getOptions(), "tooltip", "customHTML")) {
tooltipTextContainer.html(this.model.getOptions().tooltip.customHTML(data));
} else if (e.detail.multidata) {
// Generate default tooltip
let defaultTooltip;
if (e.detail.multidata) {
// multi tooltip
data = e.detail.multidata;
tooltipTextContainer.html(this.getMultilineTooltipHTML(data));
defaultTooltip = this.getMultilineTooltipHTML(data);
} else {
defaultTooltip = this.getTooltipHTML(data);
}
// if there is a provided tooltip HTML function call it
if (Tools.getProperty(this.model.getOptions(), "tooltip", "customHTML")) {
tooltipTextContainer.html(this.model.getOptions().tooltip.customHTML(data, defaultTooltip));
} else {
tooltipTextContainer.html(this.getTooltipHTML(data));
// Use default tooltip
tooltipTextContainer.html(defaultTooltip);
}

// Position the tooltip
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ export const timeScale: TimeScaleOptions = {
* Base chart options common to any chart
*/
const chart: BaseChartOptions = {
width: "100%",
height: "100%",
resizable: true,
theme: ChartTheme.DEFAULT,
tooltip: baseTooltip,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/interfaces/charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export interface BaseChartOptions {
/**
* Optionally specify a width for the chart
*/
width?: number;
width?: number | string;
/**
* Optionally specify a height for the chart
*/
height?: number;
height?: number | string;
/**
* Optional function to generate the fill color based on datasetLabel, label, and/or value
*/
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/interfaces/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface TooltipOptions {
formatter?: Function;
/**
* custom function for returning tooltip HTML
* passed an array or object with the data, and then the default tooltip markup
*/
customHTML?: Function;
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/core/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module.exports = {
devServer: {
contentBase: "./demo",
host: "0.0.0.0",
port: 9001,
port: process.env.PORT || 9001,
historyApiFallback: true,
disableHostCheck: true
}
Expand Down
27 changes: 27 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.16.24](https://github.com/IBM/carbon-charts/compare/v0.16.23...v0.16.24) (2019-10-25)


### Bug Fixes

* **core, react, angular, vue:** default width & height to 100%, and call setOptions on option change ([db251b4](https://github.com/IBM/carbon-charts/commit/db251b4))





## [0.16.23](https://github.com/IBM/carbon-charts/compare/v0.16.22...v0.16.23) (2019-10-25)

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





## [0.16.22](https://github.com/IBM/carbon-charts/compare/v0.16.21...v0.16.22) (2019-10-25)

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





## [0.16.21](https://github.com/IBM/carbon-charts/compare/v0.16.20...v0.16.21) (2019-10-24)

**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.16.21",
"version": "0.16.24",
"description": "Carbon charting components for React",
"main": "./bundle.js",
"scripts": {
Expand Down Expand Up @@ -44,7 +44,7 @@
},
"homepage": "https://github.com/IBM/carbon-charts#readme",
"dependencies": {
"@carbon/charts": "^0.16.21"
"@carbon/charts": "^0.16.24"
},
"peerDependencies": {
"react": "^16.6.3",
Expand Down
Loading

0 comments on commit e515734

Please sign in to comment.