Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…on-charts into pie-align-center
  • Loading branch information
Fei committed Jul 20, 2020
2 parents 7311338 + c1e36c0 commit 0fd785e
Show file tree
Hide file tree
Showing 44 changed files with 897 additions and 47 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.34.3](https://github.com/carbon-design-system/carbon-charts/compare/v0.34.2...v0.34.3) (2020-07-20)

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





## [0.34.2](https://github.com/carbon-design-system/carbon-charts/compare/v0.34.1...v0.34.2) (2020-07-15)

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

## [0.34.3](https://github.com/carbon-design-system/carbon-charts/compare/v0.34.2...v0.34.3) (2020-07-20)

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





## [0.34.2](https://github.com/carbon-design-system/carbon-charts/compare/v0.34.1...v0.34.2) (2020-07-15)

**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.34.2",
"version": "0.34.3",
"description": "Carbon charting components for Angular",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -40,7 +40,7 @@
"scss"
],
"dependencies": {
"@carbon/charts": "^0.34.2"
"@carbon/charts": "^0.34.3"
},
"peerDependencies": {
"@angular/common": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/angular/src/charts.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { GaugeChartComponent } from "./gauge-chart.component";
import { LineChartComponent } from "./line-chart.component";
import { PieChartComponent } from "./pie-chart.component";
import { ScatterChartComponent } from "./scatter-chart.component";
import { MeterChartComponent } from "./meter-chart.component";
import { RadarChartComponent } from "./radar-chart.component";

@NgModule({
Expand All @@ -32,6 +33,7 @@ import { RadarChartComponent } from "./radar-chart.component";
LineChartComponent,
PieChartComponent,
ScatterChartComponent,
MeterChartComponent,
RadarChartComponent
],
exports: [
Expand All @@ -47,6 +49,7 @@ import { RadarChartComponent } from "./radar-chart.component";
LineChartComponent,
PieChartComponent,
ScatterChartComponent,
MeterChartComponent,
RadarChartComponent
]
})
Expand Down
1 change: 1 addition & 0 deletions packages/angular/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export * from "./gauge-chart.component";
export * from "./line-chart.component";
export * from "./pie-chart.component";
export * from "./scatter-chart.component";
export * from "./meter-chart.component";
export * from "./radar-chart.component";
33 changes: 33 additions & 0 deletions packages/angular/src/meter-chart.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {
Component,
AfterViewInit
} from "@angular/core";

import { BaseChart } from "./base-chart.component";
import { MeterChart } from "@carbon/charts";

/**
* Wrapper around `MeterChart` in carbon charts library
*
* Most functions just call their equivalent from the chart library.
*/
@Component({
selector: "ibm-meter-chart",
template: ``
})
export class MeterChartComponent extends BaseChart implements AfterViewInit {
/**
* Runs after view init to create a chart, attach it to `elementRef` and draw it.
*/
ngAfterViewInit() {
this.chart = new MeterChart(
this.elementRef.nativeElement,
{
data: this.data,
options: this.options
}
);

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

## [0.34.3](https://github.com/carbon-design-system/carbon-charts/compare/v0.34.2...v0.34.3) (2020-07-20)

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





## [0.34.2](https://github.com/carbon-design-system/carbon-charts/compare/v0.34.1...v0.34.2) (2020-07-15)

**Note:** Version bump only for package @carbon/charts
Expand Down
49 changes: 48 additions & 1 deletion packages/core/demo/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as pieDemos from "./pie";
import * as gaugeDemos from "./gauge";
import * as scatterDemos from "./scatter";
import * as stepDemos from "./step";
import * as meterDemos from "./meter";
import * as timeSeriesAxisDemos from "./time-series-axis";
import * as radarDemos from "./radar";

Expand All @@ -15,6 +16,7 @@ export * from "./bar";
export * from "./bubble";
export * from "./donut";
export * from "./line";
export * from "./meter";
export * from "./pie";
export * from "./gauge";
export * from "./scatter";
Expand Down Expand Up @@ -88,6 +90,11 @@ export const chartTypes = {
angular: "ibm-donut-chart",
vue: "ccv-donut-chart"
},
MeterChart: {
vanilla: "MeterChart",
angular: "ibm-meter-chart",
vue: "ccv-meter-chart"
},
RadarChart: {
vanilla: "RadarChart",
angular: "ibm-radar-chart",
Expand Down Expand Up @@ -444,6 +451,21 @@ let allDemoGroups = [
}
]
},
{
title: "Area",
demos: [
{
options: areaDemos.stackedAreaTimeSeriesOptions,
data: areaDemos.stackedAreaTimeSeriesData,
chartType: chartTypes.StackedAreaChart
},
{
options: areaDemos.stackedAreaPercentageTimeSeriesOptions,
data: areaDemos.stackedAreaTimeSeriesData,
chartType: chartTypes.StackedAreaChart
}
]
},
{
title: "Pie",
demos: [
Expand Down Expand Up @@ -562,6 +584,29 @@ let allDemoGroups = [
}
]
},
{
title: "Meter",
demos: [
{
options: meterDemos.meterOptionsWithStatus,
data: meterDemos.meterData,
chartType: chartTypes.MeterChart,
isDemoExample: true
},
{
options: meterDemos.meterOptionsCustomColor,
data: meterDemos.meterData,
chartType: chartTypes.MeterChart,
isDemoExample: true
},
{
options: meterDemos.meterOptionsNoStatus,
data: meterDemos.meterData,
chartType: chartTypes.MeterChart,
isDemoExample: true
}
]
},
{
title: "Time series axis",
demos: [
Expand Down Expand Up @@ -709,7 +754,9 @@ allDemoGroups = allDemoGroups.map((demoGroup) => {
demo.id = `${formatTitleString(demoGroup.title)}--${formatTitleString(
demo.options.title
)}`;
demo.options.height = "400px";

// if there isnt a height set in the chart options, use 400
demo.options.height = demo.options.height ?? "400px";

if (!demo.codesandbox) {
demo.codesandbox = {};
Expand Down
50 changes: 50 additions & 0 deletions packages/core/demo/data/meter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
export const meterData = [
{
group: "Dataset 1",
value: 56
}
];

export const meterOptionsWithStatus = {
title: "Meter Chart - with statuses",
meter: {
peak: 80,
status: {
ranges: [
{ range: [0, 50], status: "success" },
{ range: [50, 60], status: "warning" },
{ range: [60, 100], status: "danger" }
]
}
},
height: "100px"
};

export const meterOptionsCustomColor = {
title: "Meter Chart - statuses and custom color",
meter: {
peak: 70,
status: {
ranges: [
{ range: [0, 40], status: "success" },
{ range: [40, 60], status: "warning" },
{ range: [60, 100], status: "danger" }
]
}
},
color: {
scale: {
"Dataset 1": "#925699"
}
},
height: "100px"
};


export const meterOptionsNoStatus = {
title: "Meter Chart - no status",
meter: {
peak: 70
},
height: "100px"
};
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.34.2",
"version": "0.34.3",
"description": "Carbon charting components",
"main": "./bundle.js",
"module": "./index.js",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/charts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export * from "./line";
export * from "./scatter";
export * from "./pie";
export * from "./donut";
export * from "./meter";
export * from "./radar";
export * from "./gauge";
100 changes: 100 additions & 0 deletions packages/core/src/charts/meter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Internal Imports
import { MeterChartModel } from "../model-meter";
import { Chart } from "../chart";
import * as Configuration from "../configuration";
import {
ChartConfig,
MeterChartOptions,
LayoutGrowth,
LayoutDirection
} from "../interfaces/index";
import { Tools } from "../tools";
import { Meter } from "./../components/graphs/meter";

// Components
import {
Pie,
// the imports below are needed because of typescript bug (error TS4029)
Tooltip,
Legend,
LayoutComponent,
MeterTitle,
Spacer
} from "../components/index";

export class MeterChart extends Chart {
model = new MeterChartModel(this.services);

constructor(holder: Element, chartConfigs: ChartConfig<MeterChartOptions>) {
super(holder, chartConfigs);

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

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

getComponents() {
// Specify what to render inside the graph only
const graph = {
id: "meter-graph",
components: [
new Meter(this.model, this.services)
],
growth: {
x: LayoutGrowth.STRETCH,
y: LayoutGrowth.FIXED
}
};

// Meter has an unique dataset title within the graph
const titleComponent = {
id: "title",
components: [
new MeterTitle(this.model, this.services)
],
growth: {
x: LayoutGrowth.PREFERRED,
y: LayoutGrowth.FIXED
}
};

// create the title spacer
const titleSpacerComponent = {
id: "spacer",
components: [
new Spacer(this.model, this.services, {size: 8})
],
growth: {
x: LayoutGrowth.PREFERRED,
y: LayoutGrowth.FIXED
}
};

// the graph frame for meter includes the custom title (and spacer)
const graphFrame = [new LayoutComponent(
this.model,
this.services,
[
titleComponent,
titleSpacerComponent,
graph
],
{
direction: LayoutDirection.COLUMN
}
)];

// add the meter title as a top level component
const components: any[] = this.getChartComponents(graphFrame);

return components;
}
}
Loading

0 comments on commit 0fd785e

Please sign in to comment.