Skip to content

Commit 19d0256

Browse files
authored
Merge pull request #49 from drdmitry/feature/bar-plots
Added demo of Bar plots
2 parents 78b9385 + 4534c51 commit 19d0256

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div>
2+
<plotly-plot [data]="barPlot.data" [layout]="barPlot.layout" [revision]="0" [debug]="debug" [useResizeHandler]="useResizeHandler"></plotly-plot>
3+
<p>&nbsp;</p>
4+
<plotly-plot [data]="horizontalBarPlot.data" [layout]="horizontalBarPlot.layout" [revision]="0" [debug]="debug" [useResizeHandler]="useResizeHandler"></plotly-plot>
5+
<p>&nbsp;</p>
6+
<plotly-plot [data]="groupedBarPlot.data" [layout]="groupedBarPlot.layout" [revision]="0" [debug]="debug" [useResizeHandler]="useResizeHandler"></plotly-plot>
7+
</div>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'plotly-bar-plot',
5+
templateUrl: './bar-plots.component.html',
6+
})
7+
export class BarPlotComponent {
8+
public debug = true;
9+
public useResizeHandler = true;
10+
11+
public barPlot = {
12+
data: [
13+
{ y: [10, 15, 13, 17], type: 'bar' },
14+
{ y: [16, 5, 11, 9], type: 'bar' },
15+
],
16+
layout: {
17+
title: 'Simple Bar Plot',
18+
}
19+
};
20+
21+
public horizontalBarPlot = {
22+
data: [
23+
{ x: [1, 2, 3, 4, 4, 4, 8, 9, 10], type: 'bar', name: 'Set 1' },
24+
{ x: [2, 3, 3, 3, 3, 5, 6, 6, 7], type: 'bar', name: 'Set 2' },
25+
],
26+
layout: {
27+
title: 'Horizontal Bar Plot',
28+
},
29+
};
30+
31+
private x = ['day 1', 'day 1', 'day 1', 'day 1', 'day 1', 'day 1',
32+
'day 2', 'day 2', 'day 2', 'day 2', 'day 2', 'day 2'];
33+
34+
public groupedBarPlot = {
35+
data: [{
36+
y: [0.2, 0.2, 0.6, 1.0, 0.5, 0.4, 0.2, 0.7, 0.9, 0.1, 0.5, 0.3],
37+
x: this.x,
38+
name: 'kale',
39+
marker: { color: '#3D9970' },
40+
type: 'bar'
41+
},
42+
{
43+
y: [0.6, 0.7, 0.3, 0.6, 0.0, 0.5, 0.7, 0.9, 0.5, 0.8, 0.7, 0.2],
44+
x: this.x,
45+
name: 'radishes',
46+
marker: { color: '#FF4136' },
47+
type: 'bar'
48+
},
49+
{
50+
y: [0.1, 0.3, 0.1, 0.9, 0.6, 0.6, 0.9, 1.0, 0.3, 0.6, 0.8, 0.5],
51+
x: this.x,
52+
name: 'carrots',
53+
marker: { color: '#FF851B' },
54+
type: 'bar'
55+
}],
56+
layout: {
57+
title: 'Grouped Bar Plot',
58+
yaxis: {
59+
title: 'normalized moisture',
60+
zeroline: false
61+
},
62+
barmode: 'stack'
63+
}
64+
};
65+
66+
}

src/app/demo/demo.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ <h5>Angular Plotly</h5>
77

88
<ul class="vertical menu">
99
<li><a [routerLink]="['/home']">Home</a></li>
10+
<li><a [routerLink]="['/bar-plots']">Bar Plots</a></li>
1011
<li><a [routerLink]="['/box-plots']">Box Plots</a></li>
1112
<li><a [routerLink]="['/linear-charts']">Linear Charts</a></li>
1213
<li><a [routerLink]="['/ajax']">Ajax</a></li>

src/app/demo/demo.module.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { PlotlyModule } from '../plotly/plotly.module';
1111
// import { PlotlyViaWindowModule } from '../plotly-via-window/plotly-via-window.module';
1212

1313
// Examples
14+
import { BarPlotComponent } from './bar-plots/bar-plots.component';
1415
import { BoxPlotComponent } from './box-plots/box-plots.component';
1516
import { LinearChartsComponent } from './linear-charts/linear-charts.component';
1617
import { AjaxComponent } from './ajax/ajax.component';
@@ -21,6 +22,7 @@ import { FramesComponent } from './frames/frames.component';
2122

2223
const demoRoutes: Routes = [
2324
{ path: 'home', component: HomeComponent, data: { title: 'Home' } },
25+
{ path: 'bar-plots', component: BarPlotComponent, data: { title: 'Bar Plots' } },
2426
{ path: 'box-plots', component: BoxPlotComponent, data: { title: 'Box Plots' } },
2527
{ path: 'linear-charts', component: LinearChartsComponent, data: { title: 'Linear Charts' } },
2628
{ path: 'ajax', component: AjaxComponent, data: { title: 'Ajax' } },
@@ -43,6 +45,7 @@ const demoRoutes: Routes = [
4345
declarations: [
4446
HomeComponent,
4547
DemoComponent,
48+
BarPlotComponent,
4649
BoxPlotComponent,
4750
LinearChartsComponent,
4851
AjaxComponent,

0 commit comments

Comments
 (0)