-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
ref(charts): Move ECharts options as top level component props #9652
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4b69f7a
ref(charts): Move ECharts options as top level component props
billyvg e40ea8c
add comments, some tidying
billyvg 9c0e8b8
only merge series with previousPeriod if necessary
billyvg f55ccfb
move dateformatting into xAxis component
billyvg f9e3fa2
lint fix
billyvg 34e0c52
use filter only
billyvg 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
66 changes: 19 additions & 47 deletions
66
src/sentry/static/sentry/app/components/charts/areaChart.jsx
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -14,5 +14,7 @@ export default function Grid(props = {}) { | |
| left: '10%', | ||
|
|
||
| right: '10%', | ||
|
|
||
| ...props, | ||
| }; | ||
| } | ||
62 changes: 61 additions & 1 deletion
62
src/sentry/static/sentry/app/components/charts/components/tooltip.jsx
This file contains hidden or 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 |
|---|---|---|
| @@ -1,9 +1,69 @@ | ||
| import moment from 'moment'; | ||
| import 'echarts/lib/component/tooltip'; | ||
|
|
||
| export default function Tooltip(props = {}) { | ||
| const DEFAULT_TRUNCATE_LENGTH = 80; | ||
|
|
||
| // Truncates labels for tooltip | ||
| function truncateLabel(seriesName, truncate) { | ||
| if (!truncate) { | ||
| return seriesName; | ||
| } | ||
|
|
||
| let result = seriesName; | ||
| let truncateLength = typeof truncate === 'number' ? truncate : DEFAULT_TRUNCATE_LENGTH; | ||
| 0; | ||
|
|
||
| if (seriesName.length > truncateLength) { | ||
| result = seriesName.substring(0, truncateLength) + '…'; | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| function formatAxisLabel(value, isTimestamp) { | ||
| if (!isTimestamp) { | ||
| return value; | ||
| } | ||
|
|
||
| return moment(value).format('MMM D, YYYY'); | ||
| } | ||
|
|
||
| function getFormatter({filter, isGroupedByDate, truncate}) { | ||
| const getFilter = seriesParam => { | ||
| const value = seriesParam.data[1]; | ||
| if (typeof filter === 'function') { | ||
| return filter(value); | ||
| } | ||
|
|
||
| return true; | ||
| }; | ||
|
|
||
| return seriesParams => { | ||
| const label = | ||
| seriesParams.length && | ||
| formatAxisLabel(seriesParams[0].axisValueLabel, isGroupedByDate); | ||
| return [ | ||
| `<div>${truncateLabel(label, truncate)}</div>`, | ||
| seriesParams | ||
| .filter(getFilter) | ||
| .map( | ||
| s => | ||
| `<div>${s.marker} ${truncateLabel(s.seriesName, truncate)}: ${s | ||
| .data[1]}</div>` | ||
| ) | ||
| .join(''), | ||
| ].join(''); | ||
| }; | ||
| } | ||
|
|
||
| export default function Tooltip( | ||
| {filter, isGroupedByDate, formatter, truncate, ...props} = {} | ||
| ) { | ||
| formatter = formatter || getFormatter({filter, isGroupedByDate, truncate}); | ||
|
|
||
| return { | ||
| show: true, | ||
| trigger: 'axis', | ||
| formatter, | ||
| ...props, | ||
| }; | ||
| } | ||
Oops, something went wrong.
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.
These functions are moved from
app/organizationDiscover/result/utils