-
Notifications
You must be signed in to change notification settings - Fork 121
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: add band area chart #157
Conversation
bcb04db
to
81812fa
Compare
Codecov Report
@@ Coverage Diff @@
## master #157 +/- ##
==========================================
+ Coverage 95.66% 96.26% +0.59%
==========================================
Files 34 36 +2
Lines 1801 1848 +47
Branches 228 239 +11
==========================================
+ Hits 1723 1779 +56
+ Misses 65 60 -5
+ Partials 13 9 -4
Continue to review full report at Codecov.
|
Add a `y0Accessor` prop for each series to enable the possibility to add a lower limit to area and bars. close elastic#144
refactoring of the indexed geometries: removed the extra duplicated values in favour of a better rendering geometry.
This commit also remove the wrongly conceived seriesKey with an undefined element in there. It's now a clean empty array if you wrongly specified a wrong split accessor
The logic of data structure in stacked charts is changed a bit to reflect correctly what are the initial values of the datum and what are the current stacked data
6a01d0b
to
8e0bfe7
Compare
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.
one tiny comment but overall code lgtm & tested locally on firefox. there are some places where we might be able to refactor to help with test coverage also, but since we are going to take care of this in a separate PR already anyways, i think that can be handled there.
a couple of things that can be addressed in separate PRs but just mentioning them here:
when we go back to improve the test coverage, maybe we can also add data with only negative values & mixed negative/positive. i checked the stories with data like this and the bands look fine still but might still be nice to have those in the tests to check in the future.
the other thing is that right now only one of the band values appears next to the legend element as you're hovering, which is especially noticeable when you're hovering over the top part of the band and the value next to the legend element is the value is for the bottom part of the band:
y1: number | null; | ||
/** the optional y0 metric, used for bars or area with a lower bound */ | ||
y0?: number | null; | ||
/** the datum */ | ||
datum?: any; | ||
} | ||
|
||
export interface DataSeriesDatum { |
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.
Could DataSeriesDatum
extend RawDataSeriesDatum
? Seems like there is a lot of overlap and since they are related, might make it clearer for others in the codebase to draw this connection.
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.
They are similar but they have only few things in common. The raw, is more or less the initialY part of the DataSeriesDatum. I can check and rewrite a bit those
@emmacunningham thanks for the review. I will address those problems in 3 separated PRs: one for testing negative/mixed values, one for cleaning the DataSeriesDatum types and one to add either values of the band to the legend. |
🎉 This PR is included in version 3.10.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [3.10.0](elastic/elastic-charts@v3.9.0...v3.10.0) (2019-04-11) ### Features * add band area chart ([opensearch-project#157](elastic/elastic-charts#157)) ([5a7c740](elastic/elastic-charts@5a7c740)), closes [opensearch-project#144](elastic/elastic-charts#144)
Summary
close #144
This PR adds a
y0Accessors
prop for eachSeriesSpec
: this property can be used to describe a dataset with bands ( with a min and max value for each data point).It's mainly used for with
AreaSeries
to descibe a bounded area chart, bounded on the y axis. They0
value, is usually a lower value than they1
, it will be rendered perpendicularly to they1
point. On a standard area chart, they0
value usually correspond to0
or to the previous value in the stack. In a band-area chart, they0
can be any value below they1
value.It can also be applied to bar charts, with some limitations as described below. On a barchart, the
y0
value is the bottom edge of the bar.On a stacked bar/area chart a series with a
y0Accessor
will be stacked on top of the below series stacking the below seriesy1
value with the band seriesy0
value. This means that if the below series at a point X has an height of10
, and the bound series has the following values:y0: 2, y1: 5
the resulting chart will push the bound series to the top starting using the following values:y0:12, y1: 15
The
IndexedGeometry
object is also refactored. To limit amount of redundant code/memory object we used the sameGeometry
elements used on the highlight/hover process.The structure of
IndexedGeometry
is slightly changed, to avoid duplicate values and to simplify tooltip formatting when rendering either y1 and y0 values.A candlestick-like barchart can be also configured, but the y0 value is not currently displayed on the tooltip.
After few investigation on tests, I've currently removed from the
indexedGeometries
map all geometry withnull
values ony1
. This leads to a minor problem: we are not showing any tooltip on that interval, the tooltip of the crosshair is never shown.To Dos:
[ ] bring back animation on area chartssee Disable animation #161[ ] enable if possible the visualization of the y0 value for barssee Display y0 and y1 names on tooltip for band charts #162Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.