FIREFLY-2006: Charts Grouping functionality - #1992
Conversation
c480db1 to
6a601e7
Compare
|
Updates, PR updated as of 8/14, bug free from all my tesing:
Please report any new bugs, style fix suggestions, etc. |
robyww
left a comment
There was a problem hiding this comment.
This is looking really good! I think it will be a very nice feature.
Code
- Several small things to clean up.
- Glad you added stuff to ChartUtil, I have a concern there is a lot of redundancy in the chart code.
Testing and UI.
- Test when very well. I did not run into any issues.
- I looks and works very nice! Easy to use!
- UI change? Maybe in the grouping case we do not need the trace selection on the toolbar. I don't really see what it does.
| fields && Object.entries(fields).forEach( ([k,v]) => { | ||
| // do not let an empty histogram label erase the shared X-axis label while overplotting | ||
| if (k === 'layout.xaxis.title.text' && | ||
| (!v || v === 'undefined') && |
There was a problem hiding this comment.
(!v || v === 'undefined')
I don't understand this line. can it just be !v. Am I missing something?
|
|
||
| // The field can be undefined for one render while the dialog mounts | ||
| // Use live form state when present, otherwise fall back to chart state | ||
| const isEnabledField = useStoreConnector(() => getFieldVal(groupKey, ENABLED_KEY), [groupKey]); |
There was a problem hiding this comment.
just use, you don't need groupKey it is picked up from the context.
const isEnabledField- useFieldValueOnly(ENABLED_KEY)|
|
||
| // TODO: combine different source tables to a client-side table | ||
| const sourceOptions = useFieldValueOnly(SOURCE_OPTIONS_KEY, initialSourceOptions); | ||
| const sourceOptions = useStoreConnector(() => getFieldVal(groupKey, SOURCE_OPTIONS_KEY), [groupKey]) ?? initialSourceOptions; |
There was a problem hiding this comment.
same here but also takes default value
const sourceOptions = useFieldValueOnly(SOURCE_OPTIONS_KEY, initialSourceOptions)| redshift: fields[sfFieldKeys.redshift] ?? currentSFOptionFields.redshift, | ||
| userSpecified: fields[sfFieldKeys.userSpecified] ?? currentSFOptionFields.userSpecified | ||
| }; | ||
| const xUnitChanged = xUnit !== undefined && xUnit !== fireflyData?.[activeTrace]?.xUnit; |
There was a problem hiding this comment.
use isDefined(xUnit) (in WebUtil.js) it is easier to read
| const {tbl_id} = tablesources[activeDataTrace] || {}; | ||
| if (!tbl_id) return; | ||
| const tbl_id = getTblIdFromChart(chartId, activeDataTrace); | ||
| if (!tbl_id || !getTblById(tbl_id)) return; |
There was a problem hiding this comment.
I think you can just say getTblById(tbl_id) if not modify getTblById to have a
if (!tbl_id) return;
| const chartData = cloneDeep(omit(getChartData(chartId), ['_original', 'mounted'])); | ||
| chartData?.tablesources?.forEach((ts) => Reflect.deleteProperty(ts, '_cancel')); | ||
| const chartData = cloneDeep(omit(getChartData(chartId), ['_original', 'mounted', 'selection'])); | ||
| if (chartData?.layout) delete chartData.layout.selections; |
There was a problem hiding this comment.
if you are going to use Reflect.deleteProperty you should do it here as well.
| }; | ||
|
|
||
| return (chartIds?.length > 1) | ||
| const unresolvedChartIds = chartIds?.[0] instanceof Promise; |
There was a problem hiding this comment.
I have read doing an instanceof Promise was not very reliable. I look it up on AI and it pointed out some issues.
Why don't you make a isPromsie in WebUtil.js that looks something like
const isPromise = (p) => isFunction(p?.then);line 245 is the other place it is use.
In out code base we only use instanceof Promise in this file.
| }; | ||
|
|
||
| return (chartIds?.length > 1) | ||
| const unresolvedChartIds = chartIds?.[0] instanceof Promise; |
There was a problem hiding this comment.
I have read doing an instanceof Promise was not very reliable. I look it up on AI and it pointed out some issues.
Why don't you make a isPromsie in WebUtil.js that looks something like
const isPromise = (p) => isFunction(p?.then);line 245 is the other place it is use.
In out code base we only use instanceof Promise in this file.
| ...(traceTS.options || {}), | ||
| ...(fireflyData?.[traceNum]?.options || {}) |
There was a problem hiding this comment.
using ... is safe on undefined object so you don't need || {}
example
const a={};
const b=undefined;
const c= {...a,...b};| @@ -212,7 +230,7 @@ export function addScatterChanges({changes, chartId, traceNum, tablesource, tabl | |||
|
|
|||
| const colors = get(changes, [`data.${traceNum}.marker.color`]); | |||
| let cTipLabel = isArray(colors) ? get(mappings, 'marker.color') : ''; | |||
There was a problem hiding this comment.
take out the get in the above two lines.
6a601e7 to
6c9ad64
Compare
|
@robyww Thanks! I will address your feedback. Meanwhile, I found that when opening the chart dialog, the |
Ticket: FIREFLY-2006
makeScatterGroupByChangesis the main function handling grouping logic (inChartUtil). Some other supporting functions are also inChartUtil. My reasoning behind keeping these here was that even though we only offer grouping for scatter plots, it's general enough to belong inChartUtil.ScatterOptions.Testing:
Group by: Order, and all other scatter plots should load withGroup by: NoneGroup Bywith any column. Select any trace and try changing trace style/symbol, etc. Set backGroup BytoNone.select the enclosed points, andFilter on the selected points. And then remove the selection/filter. Do this after you setGroup Byto a column and also after you set it back toNone.Trace OptionsandChart Optionsin the charts dialog. To make sure none of your selections changes (filtering would sometimes remove reverse from X/Y axes, even on ops - underChart Options, as an example of a bug).