-
Notifications
You must be signed in to change notification settings - Fork 75
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
refactor(subject previews): allow for single series JSON data subjects #7123
base: master
Are you sure you want to change the base?
refactor(subject previews): allow for single series JSON data subjects #7123
Conversation
function getXYData(data) { | ||
return { | ||
data: data.x.map((x, index) => ({ x, y: data.y[index] })), | ||
pointStyle: 'circle', | ||
backgroundColor: '#ffffff', | ||
borderColor: '#000000' | ||
} | ||
} |
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 new, to handle subjects with { data: { x: number[], y: number[] }}
. Otherwise, the rest of the code in this PR should be unchanged from the original, just refactored into smaller functions.
if(data.x && data.y) { | ||
return { | ||
data: { | ||
x: data.x, | ||
y: data.y | ||
} | ||
}); | ||
} | ||
if (data.datasets) { | ||
datasets = data.datasets | ||
}, | ||
{ | ||
chartOptions: { | ||
xAxisLabel: 'Days', | ||
yAxisLabel: 'Brightness' | ||
} | ||
}; |
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 converts PH-TESS subjects from { x, y }
to { data: { x, y }, chartOptions }
(when the location MIME type is application/json
.)
9b1096c
to
c901cfe
Compare
09fb922
to
b863e9b
Compare
b863e9b
to
e11b0e8
Compare
Refactor previews for JSON data subjects to include subjects with a single `x,y` data series. `getDatasets(data)` reflects on the type of data, then calls an appropriate helper function to convert `data` into an array of `chart.js` datasets.
e11b0e8
to
939d235
Compare
Refactor previews for JSON data subjects to include subjects with a single
x,y
data series eg. PH-TESS subjects.getDatasets(data)
reflects on the type of data, then calls an appropriate helper function to convertdata
into an array ofchart.js
datasets.You can check the subject viewer for a JSON data subject on Black Hole Hunters Talk
eg. https://local.zooniverse.org:3735/projects/cobalt-lensing/black-hole-hunters/talk/subjects/96013284?env=production
d.map is not a function
for subject previews, when you pass an{ x, y }
subject to the chart plotter. See Issue with Json data charts Preview front-end-monorepo#6118.Required Manual Testing
Review Checklist
npm ci
and app works as expected?Optional
ChangeListener
orPromiseRenderer
components with code that updates component state?