Skip to content

Commit c614f02

Browse files
committed
Charts bug fixed: 1. when table removed - chart is not in sync, 2. empty string in xy options min-max (when changed from another value) is interpreted as 0.
1 parent a793d50 commit c614f02

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/firefly/js/charts/ui/XYPlotOptions.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function resultsSuccess(callback, flds, tblId) {
7777
const nbinsY = get(flds, ['nbins.y']);
7878

7979
let {xMin, xMax, yMin, yMax} = flds; // string values
80-
[xMin, xMax, yMin, yMax] = [xMin, xMax, yMin, yMax].map((v) => { return (isFinite(v)) ? Number(v) : undefined; });
80+
[xMin, xMax, yMin, yMax] = [xMin, xMax, yMin, yMax].map((v) => { return isFinite(parseFloat(v)) ? Number(v) : undefined; });
8181
let userSetBoundaries = omitBy({xMin, xMax, yMin, yMax}, isUndefined);
8282
userSetBoundaries = isEmpty(userSetBoundaries) ? undefined : userSetBoundaries;
8383
const xyRatio = parseFloat(flds.xyRatio);

src/firefly/js/visualize/saga/ChartsSync.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {PLOT2D, DEFAULT_PLOT2D_VIEWER_ID, dispatchAddViewerItems, dispatchRemove
1919
*/
2020
export function* syncCharts() {
2121
while (true) {
22-
const action= yield take([ChartsCntlr.CHART_ADD, ChartsCntlr.CHART_MOUNTED, ChartsCntlr.CHART_REMOVE, TablesCntlr.TBL_RESULTS_ACTIVE, TablesCntlr.TABLE_LOADED]);
22+
const action= yield take([ChartsCntlr.CHART_ADD, ChartsCntlr.CHART_MOUNTED, ChartsCntlr.CHART_REMOVE, TablesCntlr.TABLE_LOADED]);
2323
switch (action.type) {
2424
case ChartsCntlr.CHART_ADD:
2525
case ChartsCntlr.CHART_MOUNTED:
@@ -60,11 +60,13 @@ export function* syncCharts() {
6060
*/
6161
export function* syncChartViewer() {
6262
while (true) {
63-
const action = yield take([ChartsCntlr.CHART_ADD, TablesCntlr.TBL_RESULTS_ACTIVE]);
63+
const action = yield take([ChartsCntlr.CHART_ADD, TablesCntlr.TBL_RESULTS_ACTIVE, TablesCntlr.TABLE_REMOVE]);
6464
switch (action.type) {
6565
case ChartsCntlr.CHART_ADD:
66+
case TablesCntlr.TABLE_REMOVE:
6667
case TablesCntlr.TBL_RESULTS_ACTIVE:
67-
updateDefaultViewer();
68+
const {chartId} = action.payload;
69+
updateDefaultViewer(chartId);
6870
break;
6971
}
7072
}
@@ -98,13 +100,14 @@ export function* addDefaultScatter() {
98100
}
99101

100102

101-
function updateDefaultViewer() {
103+
function updateDefaultViewer(chartId) {
102104
const tblId = TableUtil.getActiveTableId();
103105
const chartIds = [];
104106
chartIds.push(...ChartsCntlr.getChartIdsInGroup(tblId), ...ChartsCntlr.getChartIdsInGroup('default'));
105107
const currentIds = getViewerItemIds(getMultiViewRoot(),DEFAULT_PLOT2D_VIEWER_ID);
106108
if (!isEqual(chartIds, currentIds)) {
107-
dispatchUpdateCustom(DEFAULT_PLOT2D_VIEWER_ID, {activeItemId: undefined});
109+
const activeItemId = chartIds.includes(chartId) ? chartId : undefined;
110+
dispatchUpdateCustom(DEFAULT_PLOT2D_VIEWER_ID, {activeItemId});
108111
dispatchRemoveViewerItems(DEFAULT_PLOT2D_VIEWER_ID,currentIds);
109112
dispatchAddViewerItems(DEFAULT_PLOT2D_VIEWER_ID, chartIds, PLOT2D);
110113
}

0 commit comments

Comments
 (0)