This week for Workout Wednesday we are getting familiar with the PlotlyJS visual by creating traces and annotations for a connected scatterplot.
Connected scatterplots are a cross between a scatterplot and a lineplot whereby two numeric variables are connected by a third ordered variable (often time).
Please be sure to cite the sources before sharing.
- Obtain the data here: https://raw.githubusercontent.com/vega/vega/main/docs/data/driving.json
- Import PlotlyJS custom visual from AppSource
- Drag the fields into the fields well
- Hover over the visual, select More Options then select Edit to edit the visual
- Add Trace
- Select Scatter option, add Miles to X Axis and Gas to Y Axis.
- Select Transform from the Left Menu Bar
- Sort by Year
- Under Traces, select Lines and Text options
- Set colour of points to Variable, select Inferno scheme and order by Year in reverse
- Change the colour of the line to black or a darker shade
- Change the shape of the line to smooth
- Encode Text with the Year field, adjust the font size and set custom text position using the Side field
- Label the Axes
- Add Annotations (tip: you may need to go into the JSON section to hardcode positioning if drag and drop is tetchy)
- Go to Save/Load >> JSON >> Save
This challenge uses the data for Vega and Vega-Lite example gallery available here: https://raw.githubusercontent.com/vega/vega/main/docs/data/driving.json
Or you can download the PBIX from the Data Stories Gallery
After you finish your workout, share on Twitter using the hashtags #WOW2022 and #PowerBI, and tag @JSBaucke, @MMarie, @shan_gsd, @KerryKolosko, and @NerdyWithData. Also make sure to fill out the Submission Tracker so that we can count you as a participant this week in order to track our participation throughout the year.
Please be sure to cite source before sharing.