Skip to content

Commit 68e8754

Browse files
Merge pull request #106 from sjdrew/master
feat: added markers/ticks/labels and bg color for ranges
2 parents c0372fe + 7a21f3f commit 68e8754

File tree

6 files changed

+18001
-55
lines changed

6 files changed

+18001
-55
lines changed

apps/demo/src/app/documentation/documentation.component.html

+19-2
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,28 @@ <h4>Configuration Options</h4>
116116
</tr>
117117
<tr>
118118
<td>thresholds</td>
119-
<td>Specifies an object of threshold values at which the gauge's color changes.</td>
119+
<td>Specifies an object of threshold values at which the gauge's color changes. Also if you specify a bgOpacity, this color will be applied the opacity value and shown as the background for that range, otherwise the backgroundColor is used.</td>
120120
<td>No</td>
121121
<td>None</td>
122-
<td>A special object</td>
122+
<td>A special object of the format
123+
<code>{{ '{ "20": { color: "red", bgOpacity: .2 } , ... }' }}</code></td>
123124
</tr>
125+
<tr>
126+
<td>markers</td>
127+
<td>Specifies an object of marker values at which value to place a marker. Can be a line or triangle and optionally may specify color, size and label. Note if you use labels you should add to margin value to the gauge using the margin option.</td>
128+
<td>No</td>
129+
<td>None</td>
130+
<td>A special object of the format shown. Currently type supports "line" or "triangle" marker.<br>
131+
<code>{{ '{ "50": { color: "#555", type: "triangle", size: 8, label: "Goal", font: "12px arial" } , ... }' }}</code>
132+
</td>
133+
</tr>
134+
<tr>
135+
<td>margin</td>
136+
<td>Specifies an optional margin for the chart.</td>
137+
<td>No</td>
138+
<td>0</td>
139+
<td>A positive integer. If using markers, you should set at least a 8 margin or more if using labels.</td>
140+
</tr>
124141
<tr>
125142
<td>animate</td>
126143
<td>toggles the gauge animation</td>

apps/demo/src/app/playground/playground.component.html

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ <h1>Playground - <small>Get your hands dirty!</small> </h1>
102102
<ngx-gauge [type]="type" [size]="size" [thick]="thick" [label]="label" [append]="append"
103103
[prepend]="prepend" [cap]="cap" [foregroundColor]="foregroundColor"
104104
[backgroundColor]="backgroundColor" [value]="value" [min]="min" [max]="max"
105+
[markers]="markers" [margin]="12"
105106
[thresholds]="enableThresholds ? thresholdConfig : {}"></ngx-gauge>
106107
</div>
107108
</section>

apps/demo/src/app/playground/playground.component.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,17 @@ export class PlaygroundComponent implements OnInit {
2727
backgroundColor: string = '#ebebeb';
2828

2929
thresholdConfig = {
30-
'0': { color: 'green' },
31-
'40': { color: 'orange' },
32-
'75.5': { color: 'red' }
30+
'0': { color: 'green', bgOpacity: .2 },
31+
'40': { color: 'orange', bgOpacity: .2 },
32+
'75.5': { color: 'red', bgOpacity: .2 }
3333
};
3434

35+
markers = {
36+
"30": { color: '#555', size: 8, label: '30', type: 'line'},
37+
"70": { color: '#555', size: 8, label: '60', type: 'line'},
38+
"100": { color: '#555', size: 8, label: '100', type: 'line'},
39+
}
40+
3541
onClick(e) {
3642
console.log(this.foregroundColor, this.backgroundColor);
3743
this.foregroundColor = 'red';

0 commit comments

Comments
 (0)