|
|
(7 intermediate revisions by 2 users not shown) |
Line 2: |
Line 2: |
| | | |
| == Food Grid == | | == Food Grid == |
| + | |
| + | |
| <graph> | | <graph> |
| { | | { |
− | "width": 1200, | + | "width": 800, |
| "height": 800, | | "height": 800, |
| "padding": 50, | | "padding": 50, |
Line 207: |
Line 209: |
| "x": {"scale": "x","field": "X"}, | | "x": {"scale": "x","field": "X"}, |
| "y": {"scale": "y","field": "Y"}, | | "y": {"scale": "y","field": "Y"}, |
− | "fill": {"value": "steelblue"}, | + | "fill": {"value": "black"}, |
| "text": {"field": "Ingredient"}, | | "text": {"field": "Ingredient"}, |
| "size": {"signal": "pointSize"} | | "size": {"signal": "pointSize"} |
| } | | } |
| } | | } |
− | }
| |
− | ]
| |
− | }
| |
− | ]
| |
− | }
| |
− | </graph>
| |
− |
| |
− | == Testing ==
| |
− |
| |
− | <graph>
| |
− | {
| |
− | "width": 1200,
| |
− | "height": 800,
| |
− | "padding": 50,
| |
− | "data": [
| |
− | {
| |
− | "name": "points",
| |
− | "url": "https://docs.google.com/spreadsheets/d/e/2PACX-1vT0_0qj3qt7mCL5I_7n_2knB3ryGPnjJHcGo57cLFAAS1BlomsJzvRrhP9AEfIErQsoPV99Q5owF8sw/pub?gid=265099091&single=true&output=csv",
| |
− | "format": {"type": "csv"}
| |
− | }
| |
− | ],
| |
− | "signals": [
| |
− | {
| |
− | "name": "point",
| |
− | "init": 0,
| |
− | "streams": [
| |
− | {
| |
− | "type": "mousedown",
| |
− | "expr": "{x: eventX(), y: eventY()}"
| |
− | }
| |
− | ]
| |
− | },
| |
− | {
| |
− | "name": "delta",
| |
− | "init": 0,
| |
− | "streams": [
| |
− | {
| |
− | "type": "[mousedown, window:mouseup] > window:mousemove",
| |
− | "expr": "{x: point.x - eventX(), y: eventY() - point.y}"
| |
− | }
| |
− | ]
| |
− | },
| |
− | {
| |
− | "name": "xAnchor",
| |
− | "init": 0,
| |
− | "streams": [
| |
− | {
| |
− | "type": "mousemove",
| |
− | "expr": "eventX()",
| |
− | "scale": {"name": "x","invert": true}
| |
− | }
| |
− | ]
| |
− | },
| |
− | {
| |
− | "name": "yAnchor",
| |
− | "init": 0,
| |
− | "streams": [
| |
− | {
| |
− | "type": "mousemove",
| |
− | "expr": "eventY()",
| |
− | "scale": {"name": "y","invert": true}
| |
− | }
| |
− | ]
| |
− | },
| |
− | {
| |
− | "name": "zoom",
| |
− | "init": 1,
| |
− | "verbose": true,
| |
− | "streams": [
| |
− | {
| |
− | "type": "wheel",
| |
− | "expr": "pow(1.001, event.deltaY*pow(16, event.deltaMode))"
| |
− | }
| |
− | ]
| |
− | },
| |
− | {
| |
− | "name": "xs",
| |
− | "streams": [
| |
− | {
| |
− | "type": "mousedown, mouseup, wheel",
| |
− | "expr": "{min: xMin, max: xMax}"
| |
− | }
| |
− | ]
| |
− | },
| |
− | {
| |
− | "name": "ys",
| |
− | "streams": [
| |
− | {
| |
− | "type": "mousedown, mouseup, wheel",
| |
− | "expr": "{min: yMin, max: yMax}"
| |
− | }
| |
− | ]
| |
− | },
| |
− | {
| |
− | "name": "xMin",
| |
− | "init": -1000.6,
| |
− | "streams": [
| |
− | {
| |
− | "type": "delta",
| |
− | "expr": "xs.min + (xs.max-xs.min)*delta.x/width"
| |
| }, | | }, |
| { | | { |
− | "type": "zoom",
| + | "type": "symbol", |
− | "expr": "(xs.min-xAnchor)*zoom + xAnchor"
| + | "from": {"data": "points"}, |
− | }
| |
− | ]
| |
− | },
| |
− | {
| |
− | "name": "xMax",
| |
− | "init": 1000.6,
| |
− | "streams": [
| |
− | { | |
− | "type": "delta",
| |
− | "expr": "xs.max + (xs.max-xs.min)*delta.x/width"
| |
− | },
| |
− | {
| |
− | "type": "zoom",
| |
− | "expr": "(xs.max-xAnchor)*zoom + xAnchor"
| |
− | }
| |
− | ]
| |
− | },
| |
− | {
| |
− | "name": "yMin",
| |
− | "init": -1000,
| |
− | "streams": [
| |
− | {
| |
− | "type": "delta",
| |
− | "expr": "ys.min + (ys.max-ys.min)*delta.y/height"
| |
− | },
| |
− | {
| |
− | "type": "zoom",
| |
− | "expr": "(ys.min-yAnchor)*zoom + yAnchor"
| |
− | }
| |
− | ]
| |
− | },
| |
− | {
| |
− | "name": "yMax",
| |
− | "init": 1000,
| |
− | "streams": [
| |
− | {
| |
− | "type": "delta",
| |
− | "expr": "ys.max + (ys.max-ys.min)*delta.y/height"
| |
− | },
| |
− | {
| |
− | "type": "zoom",
| |
− | "expr": "(ys.max-yAnchor)*zoom + yAnchor"
| |
− | }
| |
− | ]
| |
− | },
| |
− | {
| |
− | "name": "pointSize",
| |
− | "init": 50,
| |
− | "streams": [
| |
− | {
| |
− | "type": "xMin",
| |
− | "expr": "clamp(60/(xMax-xMin), 50, 1000)"
| |
− | }
| |
− | ]
| |
− | }
| |
− | ],
| |
− | "scales": [
| |
− | {
| |
− | "name": "x",
| |
− | "type": "linear",
| |
− | "range": "width",
| |
− | "zero": false,
| |
− | "domainMin": {"signal": "xMin"},
| |
− | "domainMax": {"signal": "xMax"}
| |
− | },
| |
− | {
| |
− | "name": "y",
| |
− | "type": "linear",
| |
− | "range": "height",
| |
− | "zero": false,
| |
− | "domainMin": {"signal": "yMin"},
| |
− | "domainMax": {"signal": "yMax"}
| |
− | }
| |
− | ],
| |
− | "axes": [
| |
− | {
| |
− | "type": "x",
| |
− | "scale": "x",
| |
− | "grid": true,
| |
− | "layer": "back",
| |
− | "properties": {"labels": {"fontSize": {"value": 14}}}
| |
− | },
| |
− | {
| |
− | "type": "y",
| |
− | "scale": "y",
| |
− | "grid": true,
| |
− | "layer": "back",
| |
− | "properties": {"labels": {"fontSize": {"value": 14}}}
| |
− | }
| |
− | ],
| |
− | "marks": [
| |
− | {
| |
− | "type": "group",
| |
− | "properties": {
| |
− | "enter": {
| |
− | "x": {"value": 0},
| |
− | "width": {"field": {"group": "width"}},
| |
− | "y": {"value": 0},
| |
− | "height": {"field": {"group": "height"}},
| |
− | "clip": {"value": true}
| |
− | } | |
− | },
| |
− | "marks": [
| |
− | {
| |
− | "type": "symbol",
| |
− | "from": {"data": "points"},
| |
| "properties": { | | "properties": { |
| "update": { | | "update": { |
| "x": {"scale": "x","field": "X"}, | | "x": {"scale": "x","field": "X"}, |
| "y": {"scale": "y","field": "Y"}, | | "y": {"scale": "y","field": "Y"}, |
− | "fill": {"value": "steelblue"}, | + | "fill": {"field": "Color"}, |
| "size": {"signal": "pointSize"} | | "size": {"signal": "pointSize"} |
| } | | } |
| } | | } |
− | } | + | } |
| + | |
| ] | | ] |
| } | | } |