Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit 9dfe3fc

Browse files
author
j.r.dalenberg
committed
add ylim parameter to TimeSeries
1 parent 31a22eb commit 9dfe3fc

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/tags/object/TimeSeries.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const TagAttrs = types.model({
8181
durationdisplayformat: '.0f',
8282
overviewchannels: '', // comma-separated list of channels to show
8383
overviewwidth: '25%',
84-
ylim: '-5,5', // comma-separated list of y axis limits
84+
ylim: '', // comma-separated list of y axis limits
8585

8686
fixedscale: false,
8787

src/tags/object/TimeSeries/Channel.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import { FF_DEV_3391, isFF } from '../../../utils/feature-flags';
3535
* @param {number=} [markerSymbol=circle] plot stroke width
3636
* @param {string=} [timeRange] data range of x-axis / time axis
3737
* @param {string=} [dataRange] data range of y-axis / data axis
38-
* @param {string=} [ylim] custom data range of y-axis / data axis
3938
* @param {string=} [showAxis] show or bide both axis
4039
* @param {boolean} [fixedScale] if false current view scales to fit only displayed values; if given overwrites TimeSeries' fixedScale
4140
*/
@@ -75,7 +74,6 @@ const TagAttrs = types.model({
7574
markersymbol: types.optional(types.string, 'circle'),
7675

7776
datarange: types.maybe(types.string),
78-
ylim: types.maybe(types.string),
7977
timerange: types.maybe(types.string),
8078

8179
showaxis: types.optional(types.boolean, true),
@@ -747,33 +745,37 @@ class ChannelD3 extends React.Component {
747745
}
748746

749747
if (item.datarange) {
750-
console.log('OUTPUT')
751-
console.log(item.datarange)
752748
const datarange = item.datarange.split(',');
753749

754750
if (datarange[0] !== '') min = new Number(datarange[0]);
755751
if (datarange[1] !== '') max = new Number(datarange[1]);
756752
}
757753

758-
if (item.ylim) {
759-
// use custom range
760-
const datarange = item.ylim.split(',');
754+
// calc scale and shift
755+
const diffY = d3.extent(values).reduce((a, b) => b - a); // max - min
761756

762-
if (datarange[0] !== '') min = new Number(datarange[0]);
763-
if (datarange[1] !== '') max = new Number(datarange[1]);
757+
scaleY = diffY / (max - min);
758+
translateY = min / diffY;
764759

765-
this.y.domain([min, max]);
760+
this.y.domain([min, max]);
761+
762+
} else {
763+
const ylim = item.parent?.ylim
766764

767-
} else {
768-
// calc scale and shift
769-
const diffY = d3.extent(values).reduce((a, b) => b - a); // max - min
765+
if (ylim !== '') {
766+
// use custom range
767+
const datarange = ylim.split(',');
770768

771-
scaleY = diffY / (max - min);
772-
translateY = min / diffY;
769+
let min = 0
770+
let max = 1
771+
772+
if (datarange[0] !== '') min = Number(datarange[0]);
773+
if (datarange[1] !== '') max = Number(datarange[1]);
773774

774775
this.y.domain([min, max]);
775776
}
776777
}
778+
777779
// zoomStep - zoom level when we need to switch between optimized and original data
778780
const strongZoom = scale > this.zoomStep;
779781
const haveToSwitchData = strongZoom === this.useOptimizedData;

0 commit comments

Comments
 (0)