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

Commit 31a22eb

Browse files
author
j.r.dalenberg
committed
wip
1 parent cf076f8 commit 31a22eb

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

src/env/development.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ import { TimeSeriesSingle } from '../examples/timeseries_single';
7171
*/
7272
// import { AllTypes } from "../examples/all_types";
7373

74-
const data = VideoRectangles;
74+
const data = TimeSeries;
7575

7676
function getData(task) {
7777
if (task && task.data) {

src/tags/object/TimeSeries.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import { AnnotationMixin } from '../../mixins/AnnotationMixin';
6666
* @param {string} [durationDisplayFormat] Format used to display temporal duration value for brush range. If the temporal column is a date, use strftime to format it. If it's a number, use [d3 number](https://github.com/d3/d3-format#locale_format) formatting.
6767
* @param {string} [sep=,] Separator for your CSV file.
6868
* @param {string} [overviewChannels] Comma-separated list of channel names or indexes displayed in overview.
69+
* @param {string} [ylim] Comma-separated list of y axis limits.
6970
* @param {string} [overviewWidth=25%] Default width of overview window in percents
7071
* @param {boolean} [fixedScale=false] Whether to scale y-axis to the maximum to fit all the values. If false, current view scales to fit only the displayed values.
7172
*/
@@ -80,6 +81,7 @@ const TagAttrs = types.model({
8081
durationdisplayformat: '.0f',
8182
overviewchannels: '', // comma-separated list of channels to show
8283
overviewwidth: '25%',
84+
ylim: '-5,5', // comma-separated list of y axis limits
8385

8486
fixedscale: false,
8587

src/tags/object/TimeSeries/Channel.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ 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
3839
* @param {string=} [showAxis] show or bide both axis
3940
* @param {boolean} [fixedScale] if false current view scales to fit only displayed values; if given overwrites TimeSeries' fixedScale
4041
*/
@@ -74,6 +75,7 @@ const TagAttrs = types.model({
7475
markersymbol: types.optional(types.string, 'circle'),
7576

7677
datarange: types.maybe(types.string),
78+
ylim: types.maybe(types.string),
7779
timerange: types.maybe(types.string),
7880

7981
showaxis: types.optional(types.boolean, true),
@@ -745,21 +747,33 @@ class ChannelD3 extends React.Component {
745747
}
746748

747749
if (item.datarange) {
750+
console.log('OUTPUT')
751+
console.log(item.datarange)
748752
const datarange = item.datarange.split(',');
749753

750754
if (datarange[0] !== '') min = new Number(datarange[0]);
751755
if (datarange[1] !== '') max = new Number(datarange[1]);
752756
}
753757

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

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

760-
this.y.domain([min, max]);
761-
}
765+
this.y.domain([min, max]);
766+
767+
} else {
768+
// calc scale and shift
769+
const diffY = d3.extent(values).reduce((a, b) => b - a); // max - min
770+
771+
scaleY = diffY / (max - min);
772+
translateY = min / diffY;
762773

774+
this.y.domain([min, max]);
775+
}
776+
}
763777
// zoomStep - zoom level when we need to switch between optimized and original data
764778
const strongZoom = scale > this.zoomStep;
765779
const haveToSwitchData = strongZoom === this.useOptimizedData;

0 commit comments

Comments
 (0)