mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Fix error when creating chart with a single column
Summary: The routine that makes sure that new charts are created with at least one non-numeric series did not handle correctly when the table has one single column. This diff fixes it. Test Plan: Adds test case to ChartView3.ts Reviewers: alexmojaki Reviewed By: alexmojaki Subscribers: alexmojaki, jarek Differential Revision: https://phab.getgrist.com/D3224
This commit is contained in:
parent
c714d09eb8
commit
1b4580d92e
@ -925,12 +925,17 @@ export class GristDoc extends DisposableWithEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes sure sure that the first y-series (ie: the view fields at index 1) is a numeric
|
* Makes sure that the first y-series (ie: the view fields at index 1) is a numeric series. Does
|
||||||
* series. Does not handle chart with the group by option on: it is only intended to be used to
|
* not handle chart with the group by option on: it is only intended to be used to make sure that
|
||||||
* make sure that newly created chart do have a visible y series.
|
* newly created chart do have a visible y series.
|
||||||
*/
|
*/
|
||||||
private async _ensureOneNumericSeries(id: number) {
|
private async _ensureOneNumericSeries(id: number) {
|
||||||
const viewSection = this.docModel.viewSections.getRowModel(id);
|
const viewSection = this.docModel.viewSections.getRowModel(id);
|
||||||
|
const viewFields = viewSection.viewFields.peek().peek();
|
||||||
|
|
||||||
|
// If no y-series, then simply return.
|
||||||
|
if (viewFields.length === 1) { return; }
|
||||||
|
|
||||||
const field = viewSection.viewFields.peek().peek()[1];
|
const field = viewSection.viewFields.peek().peek()[1];
|
||||||
if (isNumericOnly(viewSection.chartTypeDef.peek()) &&
|
if (isNumericOnly(viewSection.chartTypeDef.peek()) &&
|
||||||
!isNumericLike(field.column.peek())) {
|
!isNumericLike(field.column.peek())) {
|
||||||
|
Loading…
Reference in New Issue
Block a user