-
-
Notifications
You must be signed in to change notification settings - Fork 111
[WIP] Trace picker updates #311
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
Conversation
do you mean by this: put these icons into the |
@VeraZab possibly -- these svgs are a lot more complex (various strokes, different colors) -- but it might make sense to add them there. I'll have to either manually make them into components or adjust our generating scripts for them. |
To make the Modal change the plot, you have the updateContainer prop, you can pass it the value of the chart that the user clicks on. So for ex, for a timeseries chart, we have to make sure the timeseries value is passed on. It's a custom type. Careful with the custom types. We have that function |
yup, I think it does make sense to add them there, that repos purpose is really to take care of all our icons |
A few comments:
|
src/DefaultEditor.js
Outdated
<StyleColorbarsPanel group={_('Style')} name={_('Color Bars')} /> | ||
</PanelMenuWrapper> | ||
<Fragment> | ||
<PanelMenuWrapper> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is Fragment needed there?
If I understand correctly, Fragment's used to group elements in place of wrapping them in a div, but I don't see why it'd be useful here..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops that's left over from when I was exploring ways of adding the modal :)
src/PlotlyEditor.js
Outdated
import {bem} from './lib'; | ||
import {noShame, maybeClearAxisTypes} from './shame'; | ||
import {EDITOR_ACTIONS} from './lib/constants'; | ||
import isNumeric from 'fast-isnumeric'; | ||
import nestedProperty from 'plotly.js/src/lib/nested_property'; | ||
import {CATEGORY_LAYOUT, TRACE_TYPES} from 'lib/constants'; | ||
import {ModalProvider} from 'components/containers'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have a modal system in webapp, and I think that with a modal system being present now in the editor, this just means that both modal systems will have to coexist. Because the biggest thing in webapp with Modals was that we wanted to have Modal action chains.
One modal appears, then based on user's action, another one displays. But I think it's ok not to worry about it too much here. I think that what will most likely happen is that there's 2 modal systems that will exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I was curious about that, I figured that in this version of the editor we didn't need chained modals, but I think we could merge it into one when the time comes :)
this.context.openModal(<TraceTypeSelector {...props} />) | ||
} | ||
> | ||
<UnconnectedDropdown {...props} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just from a UI and visual standpoint, maybe it should look more like a button here, instead of an UnconnectedDropdown?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool -- I will build out a button similar to what is in the workspace currently :)
re how to wire things in to the bigger context, take a look at how the other widget/field pairs work. basically your Edit: right now |
aria-label="View tutorials on this chart type." | ||
data-microtip-position={`top${position}`} | ||
role="tooltip" | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, you'd add the tutorial link later? just a reminder :) it should be an a
tag?
and actually, I think this text _('View tutorials on this chart type') has to be localized.
There's a few places in here where text needs to be localized : )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think I am going to abstract these out anyway to they are a part of the config that a user can pass through... enable them, change them, etc
<div | ||
className="trace-item__actions__item" | ||
aria-label="See a basic example." | ||
data-microtip-position={`bottom${position}`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
localized
src/lib/constants.js
Outdated
STATISTICS: 'STATISTICS', | ||
MAPS: 'MAPS', | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could these structures be simpler, like:
export const CHART_CLASS = {
GEOGRAPHIC: ['atlas', 'choropleth', 'scattermapbox']
}
CHART_CATEGORY is needed for the picker and CHART_CLASS for compatibility and disabling and enabling different plots. So I see why both are needed. But I don't see why we should repeat that whole object that lists all chart types..
src/lib/constants.js
Outdated
}; | ||
|
||
export const CATEGORY_LAYOUT = [ | ||
{category: CHART_CATEGORY.BUSINESS, label: 'Business'}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These Category layouts need to be localized
src/lib/constants.js
Outdated
|
||
export const TRACE_TYPES = { | ||
scatter: { | ||
meta: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is kind of repeating, with more detail, what we have here:
https://github.com/plotly/react-plotly.js-editor/blob/master/src/components/fields/TraceSelector.js#L21
I don't see it's necessity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much of these consts were pulled from streambed
I was not sure how much of it should stay / how much of it should go.
What do you think about moving https://github.com/plotly/react-plotly.js-editor/blob/master/src/components/fields/TraceSelector.js#L21 into the constants.js
file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have to use what streambed has : ) we just need the logic (basically which chart types go into which categories). Plus our new requirement now is that users can make that configurable. So the best data structure is the one that's simplest to use in an API.
About https://github.com/plotly/react-plotly.js-editor/blob/master/src/components/fields/TraceSelector.js#L21 I think they're here because trace names need localization, and that localize function must wrap a component to make the localize prop available to it.
We should probably be making localize available at the very top level of our app, localizing component per component is a bit rough and unecesary..
I don't mind moving all trace types to the constants folder though..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should definitely be one canonical mapping from trace type to localized trace name, so that if I have access to "scatter"
and _
I should be able to get at the localized name. Makes sense to move that into constants
and pack in the default categorization as well IMO.
@@ -0,0 +1,99 @@ | |||
.modal { | |||
$c: &; | |||
position: fixed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a forgotten variable?
hey @aulneau! And finally decided not to put these as separate trace types into the chart picker: 'error bars', 'animations', 'timeseries'. Would you remove them from the picker, please. |
Okay I've started going through and creating lists based off of the icons that Fab has made, and the list I pulled from streambed, and the list contained here in this editor and this is what I've got so far: Trace types with category and icon -> here Trace types with icon but no category -> here Trace types with no icons and no category -> here Also @VeraZab and @nicolaskruchten do we want to couple the category type in with the trace type, eg: A
or do we want to keep trace types clean and do something like: B
I am leaning more towards A. |
I like A, it's DRYer |
Okay -- I have added all the trace types that have icons into categories. cc @VeraZab @nicolaskruchten @jackparmer for any suggestions on moving trace types to a more appropriate category: |
Hmmm. How attached are we to our existing categorization scheme, @jackparmer ? It seems a bit limiting at this point if we're adding all the other trace types... Maybe we want to use a more function-oriented approach like this? https://datavizcatalogue.com/search.html or https://visual.ly/community/infographic/how/graphic-continuum There are bunch of other organization types here https://github.com/widged/data-for-good/wiki/Visualisation-::-Choosing-a-chart |
Not attached to it at all. I'm sure y'all can come up with something much better. Edit: I think the "functional" categorization is too high brow though. Is there a 7th categorization to take the weight off of the "Science" column? Maybe a "Heatmaps" column where we put heatmap, countour, 2d histogram, and 2d histogram contour. There's also a bit of shuffling to do in the current screenshot: |
Here's a slightly different typology which includes all 3 carpet types and might fit into a 4-row/8-column grid.
|
I like it! Only thing is |
I was thinking that the GL types would be like a checkbox or something rather than a first-class citizen in this trace-picker. The user looking at this might not want to make the "underlying technology" choice at this point...? What's pointcloud if not 3-d? |
+1 Checkbox/switch sounds great to me. Maybe on the top-right here? One side of the switch says D3/SVG and the other side says WebGL?
This magical trace type that @monfera wrote for uber refresh rates with lots of 2d scatter data: https://codepen.io/monfera/pen/BLjJVZ If users want to plot a stupid # of x-y points interactively, we point them to |
One downside to the SVG vs WebGL thing at the trace-picker level is that then 3D would need to go under WebGL, right? |
I would label it "2d WebGL" and keep 3d charts under both views |
OK so my initial thinking about the checkbox was outside of this modal. If we want to have the GL versions on this modal, I would go with a separate section called "WebGL accelerated" or something with those trace types in there. |
👍 "WebGL accelerated" column. I don't have a strong preference about the WebGL display as long as they are easy to access like the other trace types. |
} | ||
if ( | ||
plotlyTraceToCustomTrace(context.container) === 'timeseries' && | ||
(!context.layout.xaxis || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh.. we removed this code.. maybe time for a little rebase?..
href: `#`, | ||
icon: <GraphIcon />, | ||
}, | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it's ok, we can add these in another pr : )
function computeTraceOptionsFromSchema(schema, _, context) { | ||
// Filter out Polar "area" type as it is fairly broken and we want to present | ||
// scatter with fill as an "area" chart type for convenience. | ||
const traceTypes = Object.keys(schema.traces).filter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, when is this code activated now?
When advancedTraceTypeSelector
is not provided as a prop to the PlotlyEditor Component?
I think the user should still be able to configure the plot types even if they don't choose the advancedTraceTypeSelector
.
So this should be adjusted and only read from schema if a trace config was not given.
And these should be the excluded types for now: 'area', 'violin', 'pointcloud', 'parcoords', 'sankey', 'carpet', 'scattercarpet', 'contourcarpet', 'scatterpolar'
src/lib/customTraceType.js
Outdated
@@ -25,6 +25,8 @@ export function traceTypeToPlotlyInitFigure(traceType) { | |||
return {type: 'scatter', mode: 'markers', fill: 'none'}; | |||
case 'area': | |||
return {type: 'scatter', fill: 'tozeroy'}; | |||
case 'cartesianArea': | |||
return {type: 'scatter', fill: 'tozeroy'}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why was cartesianArea added?,
and btw, these:
https://github.com/plotly/react-plotly.js-editor/blob/caf87d269d8bc270054bae0fc99b66bed464f64f/src/lib/customTraceType.js#L8
have to match these:
https://github.com/plotly/react-plotly.js-editor/blob/caf87d269d8bc270054bae0fc99b66bed464f64f/src/lib/customTraceType.js#L26
So area's already in there, we don't need 'cartesianArea'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove :) it was held over from when I ported some stuff over from streambed
src/lib/traceTypes.js
Outdated
label: _('Heatmap GL'), | ||
category: chartCategory(_).WEB_GL, | ||
}, | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great : ) thanks!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, well, as this was almost ready for a rereview, except for new icons, I think it needs a few readjustments as per comments, but looks great, and almost ready!! 🎉 thanks @aulneau !
I think I'd vote here to make these adjustments, and merge this pr in. We have all the icons for the currently integrated traces in the editor. We can make smaller prs to integrate the rest, and make layout improvements as we go. |
@@ -83,6 +83,7 @@ class App extends Component { | |||
dataSources={dataSources} | |||
dataSourceOptions={dataSourceOptions} | |||
plotly={plotly} | |||
advancedTraceTypeSelector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this flag? this is basically going to be the default config right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore this comment, i have no objection here :)
@aulneau checked out your branch and played around with it, looks good! let's merge! |
064d0a9
to
dddd62b
Compare
ok, I think I resolved all rebase issues here, going to merge and if anything was missed then we'll see pretty soon :) |
dddd62b
to
391957d
Compare
Okay!
So this is not quite ready yet. I've built out the views and I built out a little modal provider that we can use with other modals if we want to keep it.
General structure of the updates:
I've added two new props to
PlotlyEditor
:advancedTraceTypeSelector
which enables everything, andtraceSelectorConfig
which passes our default configs to the enhanced trace type selector. The default config values are coming from some constants I ported over fromstreambed
which you can see here. Let me know if this data structure should change.I have created a
ModalProvider.js
which passes two functions through context to anywhere in the application:openModal(component)
andcloseModal()
. We callopenModal
and pass it a component -> see here.I have also created a
Modal.js
component that we can pass params to. Currently it accepts atitle
param for the header, and then we can pass it content viachildren
wrapped in<ModalContent>...</ModalContent>
I might just bake this in rather than using a sep wrapper component for this. TheModal.js
takes care of animating in/out.Where I need help // cc @VeraZab @nicolaskruchten
I am not exactly sure the best way to hook up the
TraceTypeSelector.js
to be able to affect the larger application state (change chart types, only allow X type charts if Y type chart is already selected (see here), etc. Currently I am passing the same props that we pass to the drop down to theTraceTypeSelector.js
, but I will need some guidance moving forward.Things I still need to do:
Will resolve: #238