Skip to content

Commit 3f038af

Browse files
committed
#58, support fixed ratio
1 parent 4c380f2 commit 3f038af

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ env GITHUB_TOKEN=your_token yarn release-it patch
4343
- Add basic annotations support #57 (tchernobog)
4444
- Improve loading times for plotly.js and support loading from CDN
4545
- Assume date x-axis when 'auto' and the mapping has 'time'
46+
- Support Fixed-Ratio Axes
47+
4648

4749
##### v0.0.5
4850

src/module.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ class PlotlyPanelCtrl extends MetricsPanelCtrl {
7777
static defaults = {
7878
pconfig: {
7979
loadFromCDN: false,
80+
showAnnotations: true,
81+
fixScale: '',
8082
traces: [PlotlyPanelCtrl.defaultTrace],
8183
settings: {
8284
type: 'scatter',
@@ -390,6 +392,19 @@ class PlotlyPanelCtrl extends MetricsPanelCtrl {
390392
// Set the second axis
391393
layout.yaxis2 = PlotlyPanelCtrl.yaxis2;
392394
}
395+
396+
if(this.cfg.fixScale) {
397+
if('x'=== this.cfg.fixScale) {
398+
layout.yaxis.scaleanchor = 'x';
399+
}
400+
else if('y'=== this.cfg.fixScale) {
401+
layout.xaxis.scaleanchor = 'y';
402+
}
403+
else if('z'=== this.cfg.fixScale) {
404+
layout.xaxis.scaleanchor = 'z';
405+
layout.yaxis.scaleanchor = 'z';
406+
}
407+
}
393408
return layout;
394409
}
395410

@@ -561,7 +576,7 @@ class PlotlyPanelCtrl extends MetricsPanelCtrl {
561576

562577
// Support Annotations
563578
let annotationPromise = Promise.resolve();
564-
if (this.is3d()) {
579+
if (!this.cfg.showAnnotations || this.is3d()) {
565580
this.annotations.clear();
566581
if (this.layout) {
567582
if (this.layout.shapes) {
@@ -738,6 +753,10 @@ class PlotlyPanelCtrl extends MetricsPanelCtrl {
738753

739754
// Updates the layout and redraw
740755
if (this.initialized && this.graphDiv) {
756+
if(!this.cfg.showAnnotations) {
757+
this.annotations.clear();
758+
}
759+
741760
const s = this.cfg.settings;
742761
const options = {
743762
showLink: false,

src/partials/tab_display.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ <h5 class="section-heading">Options</h5>
3131
</div>
3232
</div>
3333

34+
<div class="gf-form">
35+
<label class="gf-form-label width-7">Fix Scale</label>
36+
<div class="gf-form-select-wrapper max-width-14">
37+
<select class="gf-form-input"
38+
ng-model="ctrl.cfg.fixScale"
39+
ng-change="ctrl.editor.onConfigChanged()">
40+
<option value="">independent</option>
41+
<option value="x">X Axis (1:1)</option>
42+
<option value="y">Y Axis (1:1)</option>
43+
</select>
44+
</div>
45+
</div>
46+
47+
<gf-form-switch
48+
class="gf-form"
49+
label="Annotations"
50+
label-class="gf-form-label width-7"
51+
checked="ctrl.cfg.showAnnotations"
52+
on-change="ctrl.editor.onConfigChanged()"></gf-form-switch>
53+
3454
<gf-form-switch
3555
class="gf-form"
3656
label="Use CDN"

0 commit comments

Comments
 (0)