Skip to content

Commit

Permalink
Revert axis_scale changes related to interval
Browse files Browse the repository at this point in the history
  • Loading branch information
DianaDerevyankina committed Jan 20, 2021
1 parent e752837 commit ba53abd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
18 changes: 4 additions & 14 deletions src/plugins/vis_type_vislib/public/vislib/lib/axis/axis_scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import d3 from 'd3';
import { range, isNumber, reduce, times } from 'lodash';
import { isNumber, reduce, times } from 'lodash';
import moment from 'moment';

import { InvalidLogScaleValues } from '../../errors';
Expand Down Expand Up @@ -38,20 +38,10 @@ export class AxisScale {
});
}

getDomainExtent(data) {
getTimeDomain(data) {
return [this.minExtent(data), this.maxExtent(data)];
}

getOrdinalDomain(values = []) {
if (this.ordered?.interval !== undefined) {
const [min, max] = this.getDomainExtent(values);
const valuesInterval = Math.ceil((max - min) / values.length);
return range(min, max + valuesInterval, valuesInterval);
}

return values;
}

minExtent(data) {
return this.calculateExtent(data || this.values, 'min');
}
Expand Down Expand Up @@ -148,8 +138,8 @@ export class AxisScale {

getExtents() {
if (this.axisConfig.get('type') === 'category') {
if (this.axisConfig.isTimeDomain()) return this.getDomainExtent(this.values);
if (this.axisConfig.isOrdinal()) return this.getOrdinalDomain(this.values);
if (this.axisConfig.isTimeDomain()) return this.getTimeDomain(this.values);
if (this.axisConfig.isOrdinal()) return this.values;
}

const min = this.axisConfig.get('scale.min', this.getYMin());
Expand Down
21 changes: 5 additions & 16 deletions src/plugins/vis_type_xy/public/chart_splitter.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* and the Server Side Public License, v 1; you may not use this file except in
* compliance with, at your election, the Elastic License or the Server Side
* Public License, v 1.
*/

import React from 'react';
Expand Down

0 comments on commit ba53abd

Please sign in to comment.