mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) move client code to core
Summary: This moves all client code to core, and makes minimal fix-ups to get grist and grist-core to compile correctly. The client works in core, but I'm leaving clean-up around the build and bundles to follow-up. Test Plan: existing tests pass; server-dev bundle looks sane Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2627
This commit is contained in:
20
app/client/lib/chartUtil.ts
Normal file
20
app/client/lib/chartUtil.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import {typedCompare} from 'app/common/SortFunc';
|
||||
import {Datum} from 'plotly.js';
|
||||
|
||||
/**
|
||||
* Sort all values in a list of series according to the values in the first one.
|
||||
*/
|
||||
export function sortByXValues(series: Array<{values: Datum[]}>): void {
|
||||
// The order of points matters for graph types that connect points with lines: the lines are
|
||||
// drawn in order in which the points appear in the data. For the chart types we support, it
|
||||
// only makes sense to keep the points sorted. (The only downside is that Grist line charts can
|
||||
// no longer produce arbitrary line drawings.)
|
||||
if (!series[0]) { return; }
|
||||
const xValues = series[0].values;
|
||||
const indices = xValues.map((val, i) => i);
|
||||
indices.sort((a, b) => typedCompare(xValues[a], xValues[b]));
|
||||
for (const s of series) {
|
||||
const values = s.values;
|
||||
s.values = indices.map((i) => values[i]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user