-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/carbon-design-system/carb…
…on-charts into pie-align-center
- Loading branch information
Showing
44 changed files
with
897 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,5 @@ | |
] | ||
} | ||
}, | ||
"version": "0.34.2" | ||
"version": "0.34.3" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.