-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: remove duplicate tick labels from axis #577
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
f784b2b
fix: add helper function to remove duplicate tickLabels from axis
rshen91 e71ac18
test: set utc time for test
rshen91 f4eafa5
refactor: clean up removeDupeTickLabels
rshen91 f7a1aa0
refactor: add filter after formatting
rshen91 a0c8839
feat: adding duplicate ticks story
rshen91 d6fb645
test: add missing snapshot
rshen91 f263fbf
Merge remote-tracking branch 'upstream/master' into duplicate-ticks
rshen91 d5abfd7
fix: add license heading to story file
rshen91 591c603
docs: correct x axis format for duplicates
rshen91 dc9a38f
test: update snapshot for x axis
rshen91 efce9bf
Merge remote-tracking branch 'upstream/master' into duplicate-ticks
rshen91 60664b9
feat: implement duplicate tick functionality
rshen91 af7c506
Merge remote-tracking branch 'upstream/master' into duplicate-ticks
rshen91 935e64a
style: clean up comments
rshen91 4976be7
test: add unit tests
rshen91 1b76c69
test: set timezone to clean up tests
rshen91 5037110
refactor: update naming and remove from scales spec
rshen91 1d888f7
Merge remote-tracking branch 'upstream/master' into duplicate-ticks
rshen91 ead2e9e
refactor: add timeZone prop to story
rshen91 c5ac664
refactor: improve filter() with a set and return allTicks earlier
rshen91 4e88447
refactor: refactor to reduce() implementation
rshen91 054c088
Merge remote-tracking branch 'upstream/master' into duplicate-ticks
rshen91 55bf6ee
refactor: use moment library for time calculations
rshen91 6ba6751
refactor: change config prop name to show vs enable
rshen91 9aa1329
fix: fix moment in duplicate ticks
rshen91 4952e6b
refactor: revert moment changes in brush stories
rshen91 8a9739c
Merge remote-tracking branch 'upstream/master' into duplicate-ticks
rshen91 594c6f6
feat: refactor getUniqueValues to be reusable
rshen91 a63b9eb
Merge remote-tracking branch 'upstream/master' into duplicate-ticks
rshen91 9ed79f0
refactor: refactored generics in getUniqueValues
rshen91 506bf0b
style: remove export from computeTickDimensions
rshen91 d0ff3c8
test: move story to axes stories and update vrt
rshen91 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+16.8 KB
...al-tests-for-all-stories-axes-duplicate-ticks-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* 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. */ | ||
|
||
import React from 'react'; | ||
import { Axis, Chart, LineSeries, Position, ScaleType, niceTimeFormatter } from '../../src'; | ||
import { KIBANA_METRICS } from '../../src/utils/data_samples/test_dataset_kibana'; | ||
import { boolean } from '@storybook/addon-knobs'; | ||
import { DateTime } from 'luxon'; | ||
import moment from 'moment-timezone'; | ||
|
||
export const example = () => { | ||
const now = DateTime.fromISO('2019-01-11T00:00:00.000') | ||
.setZone('utc+1') | ||
.toMillis(); | ||
const oneDay = moment.duration(1, 'd'); | ||
const twoDays = moment.duration(2, 'd'); | ||
const oneMonth = moment.duration(31, 'd'); | ||
const threeDays = moment.duration(3, 'd'); | ||
const fourDays = moment.duration(4, 'd'); | ||
const fiveDays = moment.duration(5, 'd'); | ||
const formatter = niceTimeFormatter([now, oneMonth.add(now).asMilliseconds()]); | ||
const duplicateTicksInAxis = boolean('Show duplicate ticks in x axis', false); | ||
return ( | ||
<Chart className="story-chart"> | ||
<Axis id="bottom" position={Position.Bottom} tickFormat={formatter} showDuplicatedTicks={duplicateTicksInAxis} /> | ||
<Axis | ||
id="left" | ||
title={KIBANA_METRICS.metrics.kibana_os_load[0].metric.title} | ||
position={Position.Left} | ||
tickFormat={(d) => `${Number(d).toFixed(1)}`} | ||
/> | ||
<LineSeries | ||
id="lines" | ||
xScaleType={ScaleType.Time} | ||
yScaleType={ScaleType.Linear} | ||
xAccessor="x" | ||
yAccessors={['y']} | ||
data={[ | ||
{ x: now, y: 2 }, | ||
{ x: oneDay.add(now).asMilliseconds(), y: 3 }, | ||
{ x: twoDays.add(now).asMilliseconds(), y: 3 }, | ||
{ x: threeDays.add(now).asMilliseconds(), y: 4 }, | ||
{ x: fourDays.add(now).asMilliseconds(), y: 8 }, | ||
{ x: fiveDays.add(now).asMilliseconds(), y: 6 }, | ||
]} | ||
timeZone="local" | ||
/> | ||
</Chart> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
enableX
to me sounds like you are toggling a config option or something of that nature. Also, your config property and this method have the same name, these should usually be different.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out - changed the config property naming in commit
6ba6751