-
Notifications
You must be signed in to change notification settings - Fork 133
fix: disable x filling for line and areas #833
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,24 +16,47 @@ | |
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| import { SpecId } from '../../../utils/ids'; | ||
| import { ScaleType } from '../../../scales/constants'; | ||
| import { SpecId, GroupId } from '../../../utils/ids'; | ||
| import { YBasicSeriesSpec } from '../domains/y_domain'; | ||
| import { getSpecsById } from '../state/utils/spec'; | ||
| import { DataSeries } from './series'; | ||
| import { SeriesSpecs, StackMode, BasicSeriesSpec, isLineSeriesSpec, isAreaSeriesSpec } from './specs'; | ||
|
|
||
| /** | ||
| * Fill missing x values in all data series | ||
| * @param series | ||
| * @param xValues | ||
| * @internal | ||
| */ | ||
| export function fillSeries( | ||
| series: Map<SpecId, DataSeries[]>, | ||
| xValues: Set<string | number>, | ||
| seriesSpecs: SeriesSpecs, | ||
| groupScaleType: ScaleType, | ||
| specsByGroupIds: Map< | ||
| GroupId, | ||
| { | ||
| stackMode: StackMode | undefined; | ||
| stacked: YBasicSeriesSpec[]; | ||
| nonStacked: YBasicSeriesSpec[]; | ||
| } | ||
| >, | ||
| ): Map<SpecId, DataSeries[]> { | ||
| const sortedXValues = [...xValues.values()]; | ||
| const filledSeries: Map<SpecId, DataSeries[]> = new Map(); | ||
| series.forEach((dataSeries, key) => { | ||
| const spec = getSpecsById(seriesSpecs, key); | ||
| if (!spec) { | ||
| return; | ||
| } | ||
| const group = specsByGroupIds.get(spec.groupId); | ||
| if (!group) { | ||
| return; | ||
| } | ||
| const isStacked = Boolean(group.stacked.find(({ id }) => id === key)); | ||
| const noFillRequired = isXFillNotRequired(spec, groupScaleType, isStacked); | ||
|
|
||
| const filledDataSeries = dataSeries.map(({ data, ...rest }) => { | ||
| if (data.length === xValues.size) { | ||
| if (data.length === xValues.size || noFillRequired) { | ||
| return { | ||
| ...rest, | ||
| data, | ||
|
|
@@ -74,3 +97,9 @@ export function fillSeries( | |
| }); | ||
| return filledSeries; | ||
| } | ||
|
|
||
| function isXFillNotRequired(spec: BasicSeriesSpec, groupScaleType: ScaleType, isStacked: boolean) { | ||
| const onlyNoFitAreaLine = (isAreaSeriesSpec(spec) || isLineSeriesSpec(spec)) && !spec.fit; | ||
| const onlyContinuous = groupScaleType === ScaleType.Linear || groupScaleType === ScaleType.Time; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this affect
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that's fine. The fitting function logic does account for ordinal values, I was just wondering if this eliminated that functionality. Looks like it is still working as it was.... |
||
| return onlyNoFitAreaLine && onlyContinuous && !isStacked; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.