-
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
Stacked area charts render with gaps when the X coordinates are not continuous #388
Comments
@markov00 would this be a non-standard behaviour through a prop or should it always ignore discontinuous data? |
As a consumer of elastic-charts I would expect stacking to work regardless of the input data. I would expect that the stacking is always cumulative, so that every vertex in the bottom stack will create a vertex in stacks above. |
Ok cool, that makes sense! I'll make it happen. Thanks @wylieconlon |
@wylieconlon what is the expected output for the above example? Do you expect that, by default, the missing value is configured as a zero as in the following screenshot The second one shows better the fact that there is no value at x = 10, where the first imply that there is a value and it's 0. I think we could go with something configurable by the consumer/user @nickofthyme I think we can partially resume this: #55 |
@markov00 I see cases where both of those charts are correct. I just tried recreating this in google sheets and found that they do the first behavior, treating missing values as 0 and connecting the lines. Elasticsearch aggregations support both behaviors, they are null by default but can be configured to have a value: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html#_missing_value I actually think I was expecting a rendering that is in between the two, because the "gaps" rendering would look very strange in the example I gave at the top, or with any other stacks. Imagine the shape I've drawn here, but with a fill underneath the dotted line: |
@wylieconlon I like the idea of having a dashed line that describe the missing part of the chart. I think the segmented/dashed line can take a bit more time to implement because we need to separate that line from the rest of the chart but we can work on adding the fitting function to that. |
For the meantime, the style of the "fitted" line should be dashed and area fill, if applicable, will be the same as the "non-fitted" fill color. Later improvement could pass a style to be applied. Edge cases:
Codeimport React from 'react';
import {
Axis,
Chart,
getAxisId,
getSpecId,
Position,
ScaleType,
Settings,
LineSeries,
AreaSeries,
DataGenerator,
} from '../src';
const dg = new DataGenerator();
const data = dg.generateGroupedSeries(10);
export class Playground extends React.Component {
render() {
return (
<>
<div className="chart">
<Chart className="story-chart">
<Settings
theme={{
areaSeriesStyle: {
point: {
visible: true,
},
},
}}
/>
<Axis
id={getAxisId('bottom')}
position={Position.Bottom}
title={'Bottom axis'}
showOverlappingTicks={true}
/>
<Axis id={getAxisId('left')} title={'Left axis'} position={Position.Left} />
<AreaSeries
id={getSpecId('test')}
xScaleType={ScaleType.Linear}
yScaleType={ScaleType.Linear}
xAccessor={'x'}
yAccessors={['y']}
splitSeriesAccessors={['g']}
stackAccessors={['x']}
data={data.map((d, i) => {
if (i === 5) {
return {
...d,
y: null,
};
}
return d;
})}
/>
</Chart>
</div>
</>
);
}
} |
Yeah that's a good point, I think would be the case for fit of On a related note...I think the should not be points for the fitted data points. This is misleading because it could be assumed as actual data points but they are not. I was thinking to draw a line with not points for all fit functions. Then the line would be dashed and area filled below, depending on the fit type. |
@wylieconlon the example shown already works in elastic-chart (infra is using elastic charts). The problem here is more on how to handle stacked area chart more than single area chart that work as expected (the main difference is that the style of the area chart is configured to shoiw the area points) |
@markov00 Sorry if I was unclear, but I showed that screenshot not because it's a problem in isolation but because I'm not sure what the correct stacking behavior would be there. Imagine that we're tracking total network traffic and want to split it by machine, and the traffic looks like above. How would it stack? |
@wylieconlon I'm working on a PR to fix that behaviour. My quick fix will be: fill all the missing points with a 0 y value and hide the 0 point. I will work on adding a better representation of missing data points on area/line chart that will fill the gaps with "missing" areas: I've already partially implemented this second behaviour but we need to understand a bit better how to handle the case with curved area charts |
@markov00 Thanks for the update! The "quick fix" behavior you've described will work for us as long as we are able to get it in for 7.5 |
When displaying a stacked area/line chart with multiple data sets we need to fill the dataset with zeros on missing data points. The rendering is affected also: it will hide the filled missing point but will continue to show the area beneath it. fix elastic#388
🎉 This issue has been resolved in version 13.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Add ability to fit data of non-stacked line and area charts with a specified fit function type * add fit functions for null y1 values * allow end values to be explicitly set as fallback * add visual regression tests * add unit tests and better testing utils Note: Does not *yet* support stacked charts or `y0` values. This is a future enhancement is being tracked in #450. related to #388
🎉 This issue has been resolved in version 14.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [13.5.0](elastic/elastic-charts@v13.4.1...v13.5.0) (2019-10-09) ### Features * **data:** fill datasets with zeros with missing points when stacked ([opensearch-project#409](elastic/elastic-charts#409)) ([b989074](elastic/elastic-charts@b989074)), closes [opensearch-project#388](elastic/elastic-charts#388)
# [14.1.0](elastic/elastic-charts@v14.0.0...v14.1.0) (2019-11-13) ### Features * fit functions for null y1 values ([opensearch-project#416](elastic/elastic-charts#416)) ([6462cff](elastic/elastic-charts@6462cff)), closes [opensearch-project#450](elastic/elastic-charts#450) [opensearch-project#388](elastic/elastic-charts#388)
Describe the bug
Gaps appear in the rendering when you skip an X coordinate in your stacked area chart. It only appears in stacked areas, since stacked bars render correctly.
To Reproduce
This is an example of discontinuous data:
Expected behavior
With the data above, I would expect the chart library to insert an extra vertex at the missing X coordinates.
The text was updated successfully, but these errors were encountered: