Skip to content
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

Add food example #1548

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Add food example #1548

wants to merge 19 commits into from

Conversation

pamacha
Copy link

@pamacha pamacha commented Aug 5, 2024

No description provided.

@jaanli
Copy link

jaanli commented Aug 8, 2024

This rocks!!

@pamacha pamacha marked this pull request as ready for review August 16, 2024 15:02
@pamacha pamacha requested a review from pstuffa August 16, 2024 15:03
@mbostock mbostock requested a review from Fil August 16, 2024 20:26
// ],

// Content to add to the head of the page, e.g. for a favicon:
head: '<link rel="icon" href="observable.png" type="image/png" sizes="32x32">',
Copy link
Contributor

@Fil Fil Aug 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To deploy pass in a --config ../observablehq.config.js option which then adds the common header.

@@ -0,0 +1,101 @@
import * as d3 from "npm:d3";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have a marimekko component in examples/google-analytics/src/components/marimekkoChart.js and pangea; I haven't compared them, but it would feel useful to unify them if they're different (and take the best from each, if needs be).

examples/food-imports/src/index.md Outdated Show resolved Hide resolved
```js
// full palette from dictionary-of-colour-combinations by Sanzo Wada,
// source: https://github.com/mattdesl/dictionary-of-colour-combinations/blob/master/colors.json
const colors = FileAttachment("./data/colors.json").json();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need 16+ colors but we can materialize them; once that's done we can remove the colors.json file

examples/food-imports/src/index.md Outdated Show resolved Hide resolved
examples/food-imports/package.json Outdated Show resolved Hide resolved
import * as d3 from "npm:d3";

// adapted from @d3/marimekko-chart
// i.e. turned vertical, changed color scheme
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turned vertical is already an option in the other component I think(??)
the color scheme should be passed as a variable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe find a way to change the stacking orientation: x then y or y then x.

@@ -28,7 +28,7 @@ export function Sunburst(
startAngle = 0, // the starting angle for the sunburst
endAngle = 2 * Math.PI, // the ending angle for the sunburst
radius = Math.min(width - marginLeft - marginRight, height - marginTop - marginBottom) / 2, // outer radius
color = d3.interpolateRainbow, // color scheme, if any
color = d3.interpolateRainbow, // color scheme or scale, if any
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is the right approach—we need to make sure the same color scale is used here and in the marimekko

examples/food-imports/src/data/FoodImports.csv Outdated Show resolved Hide resolved
@@ -74,6 +91,8 @@ const nest = {
children: Array.from(children, ([name, value]) => ({name, value}))
}))
};
// reorder nodes to match category order established above
nest.children = d3.sort(nest.children, (a,b) => categories.indexOf(a.name) - categories.indexOf(b.name))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nest.children = d3.sort(nest.children, (a,b) => categories.indexOf(a.name) - categories.indexOf(b.name))
nest.children = d3.sort(nest.children, (d) => categories.indexOf(d.name))

d3.sort accepts an accessor, which is often simpler than using a comparator. You can inline this in L74.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants