-
Notifications
You must be signed in to change notification settings - Fork 841
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
WIP New EUISeriesChart implementation #1250
Closed
Closed
Conversation
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
Fixes the wrong chart dimension computation.
Reordered old js code and new ts code Correctly typed Ids for axis, group and specs
Move linear (area, line) stacking code to a reusable function Fix missing ordinal scale for grouped only bars Add multiple examples of barchart use
Fix ordinal domain sorting. Fix showing overlapping labels Refactored visualization playground
Is required to find the right way to clip only the transposed grup of chart data
We will execute this method only after collecting all domains from our data.
Split between rendering bars and interactive areas. Interactive areas will bring the data information, where the rendered bars only the main rendering configuration
This refactor change the previous way on how we are dealing with data series and specification. Now all specifications are first formatted and than merged together to clean as much as possible the dataset. Then the spaces and axis are computed. Finally the geometries are generated. The tooltip is now a single tooltip, no more crosshair, similar to the one that exist on visualize (that follow the mouse cursor) on a single element.
Aligned the style to the one existing in Kibana. Add smooth fadeIn/fadeOut transitions. Add formatted values based on axis formatters.
@markov00 Can we close this one in EUI now? |
Closed in favour of https://github.com/elastic/elastic-charts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR refactor the implementation of the EUISeriesChart.
The rationale behind this refactoring is the need of a more testable and decoupled architecture of the charts. The existing implementation is based on ReactVis that directly manipulate data series inside components, without a clear rendering pipeline and without a clean way to extend it. Some of the down side of using react vis are:
This new implementation revisit the concept of charting library and tries to apply an unidirectional rendering flow to the concept of charting. The rendering flow is the following:
This controlled flows allows us to achieve the following points:
The rendering pipeline is achieved revisiting the way on how a chart library is built. Instead of create a chart library around a set of rendering components: bar series, axis etc, this new implementation decouple the specification of the chart from the rendering components. The rendering components are part of the internals of the library. We are exposing
empty
react components to the developer, using the JSX format just as a declarative language to describe the specification of your chart and not as a set of real react component that will render something.That is achieved using the following render function on the main
Chart
component:Where all the children passed are rendered inside the
SpecsParser
, that signal a state manager that we are updating the specification of the chart, but doesn't render anything.The actual rendering is done by one of the rendered like the
ReactChart
that is rendered after the rendering pipeline produced and saved the geometries on the state manager.A spec can be something like the following:
Concepts
Axes
The concept of axes in this library follow the following constraints:
As a constraint we allow only one X axis, but we provide the ability to add multiple Y axis (also if it's a discouraged practice (see https://blog.datawrapper.de/dualaxis/ or http://www.storytellingwithdata.com/blog/2016/2/1/be-gone-dual-y-axis)
Dataset Domains:
Related to a dataset, is the extent of a variable. It usually used to draw the position of the specific value/datum along one axis (vertical or horizontal).
On a series chart, we always needs to have at least two domain, representing the 2 dimensions of the data we are drawing.
Data
It's an array of values, that will be used to compute the chart. Usually each element must have at least 2 values to be charted. Multiple values can be used to specify how we want to split the chart by series and by y values.
Examples of datasets:
These datasets can be used as input for any type of chart specification. These are the interfaces that makes up a
BasicSpec
(some sort of abstract specification)A
BarSeriesSpec
for example is the following union type:A chart can be feed with data in the following ways:
data
props configured.data
props configured. In these case the data arrays are merged together as the following rules:xScaleType
s, the main x scale type is coerced toScaleType.Linear
if all the scales are continuous or toScaleType.Ordinal
if one scale type is ordinal. Also temporal scale is, in specific case coerched to linear, so be carefull to configure correctly the scales.splitAccessors
are splitted into diffenent series. Each specification is treathed in a separated manner: if you have one chart with 3 series merged to one chart with 1 series, this results in the a chart like that has each x value splitted in two (the number of specification used, two charts) than on split is used to accomodate 3 series and the other to accomodate the remaining series. If you want to threat each series on the same way, split your chart before and create 4 different BarSeries specs, so that these are rendered evenly on the x axis.stackAccessor
are stacked together each stacked above their respective group (areas with areas, bars with bars, lines with lines. You cannot mix stacking bars above lines above areas).stackAccessors
are clustered together for the same x valuestackAccessors
are just drawn each one on their own layer (not stacked nor clustered).groupId
. For e.g. two bar charts, and two y axis, each for a spec, one per bar value. The rendered bar height are independent each other, because of the two axis.On the current
Visualize Editor
, you can stack or cluster in the following cases:Multiple charts/Split charts/Small Multiples (phase 2)
Small multiples are created using the
<SmallMultiples>
component, that takes multiple<SplittedSeries>
component with the usual element inside.<SplittedSeries>
can contains onlyBarSeries
AreaSeries
andLineSeries
Axis and other configuration needs to be configured outside theSplittedSeries
element.In case of small multiples, each
SplittedSeries
compute its own x and y domains. Than the x domains are merged and expanded. The same happens with the main Y domains, they are merged together.Colors
Each data series can have its own color.
The color is assigned through the
colorAccessors
prop that specify which data attributes are used to define the color,for example:
colorAccessors
.colorAccessors
colorAccessors
will have only 3 colors.colorAccessors
is specified, it will be usedsplitAccessors
to identifiy how to coloring the seriesTo do list
Paddings/Margins
Scales
Colors
Axis
phase 2:
Charts
phase 2:
Interaction/Animation
phase 2
General
phase 2:
Legends
phase 2:
Limitations
To use a time base series, the data must be dense: every time interval must be present on the dataset. Use an ordinal scale type and add a data formatter for the x axis values.Checklist