사용자:Hwangjy9/연습장5: 두 판 사이의 차이

편집 요약 없음
 
1번째 줄: 1번째 줄:
<graph>
<graph>
{
{
   "$schema": "https://vega.github.io/schema/vega/v4.json",
   "version": 2, "width": 400, "height": 200,
  "width": 400,
   "padding": {"top": 10, "left": 30, "bottom": 30, "right": 10},
  "height": 200,
   "padding": 5,
 
   "data": [
   "data": [
     {
     {
       "name": "table",
       "name": "table",
       "values": [
       "values": [
         {"category": "A", "amount": 28},
         {"x": 1,  "y": 28}, {"x": 2,  "y": 55},
         {"category": "B", "amount": 55},
        {"x": 3,  "y": 43}, {"x": 4,  "y": 91},
         {"category": "C", "amount": 43},
        {"x": 5,  "y": 81}, {"x": 6,  "y": 53},
         {"category": "D", "amount": 91},
         {"x": 7,  "y": 19}, {"x": 8, "y": 87},
         {"category": "E", "amount": 81},
         {"x": 9,  "y": 52}, {"x": 10, "y": 48},
         {"category": "F", "amount": 53},
         {"x": 11, "y": 24}, {"x": 12, "y": 49},
         {"category": "G", "amount": 19},
         {"x": 13, "y": 87}, {"x": 14, "y": 66},
         {"category": "H", "amount": 87}
         {"x": 15, "y": 17}, {"x": 16, "y": 27},
         {"x": 17, "y": 68}, {"x": 18, "y": 16},
         {"x": 19, "y": 49}, {"x": 20, "y": 15}
       ]
       ]
     }
     }
   ],
   ],
  "signals": [
    {
      "name": "tooltip",
      "value": {},
      "on": [
        {"events": "rect:mouseover", "update": "datum"},
        {"events": "rect:mouseout",  "update": "{}"}
      ]
    }
  ],
   "scales": [
   "scales": [
     {
     {
       "name": "xscale",
       "name": "x",
       "type": "band",
       "type": "ordinal",
      "domain": {"data": "table", "field": "category"},
       "range": "width",
       "range": "width",
       "padding": 0.05,
       "domain": {"data": "table", "field": "x"}
      "round": true
     },
     },
     {
     {
       "name": "yscale",
       "name": "y",
       "domain": {"data": "table", "field": "amount"},
       "range": "height",
       "nice": true,
       "nice": true,
       "range": "height"
       "domain": {"data": "table", "field": "y"}
     }
     }
   ],
   ],
   "axes": [
   "axes": [
     { "orient": "bottom", "scale": "xscale" },
     {"type": "x", "scale": "x"},
     { "orient": "left", "scale": "yscale" }
     {"type": "y", "scale": "y"}
   ],
   ],
   "marks": [
   "marks": [
     {
     {
       "type": "rect",
       "type": "rect",
       "from": {"data":"table"},
       "from": {"data": "table"},
       "encode": {
       "properties": {
         "enter": {
         "enter": {
           "x": {"scale": "xscale", "field": "category"},
           "x": {"scale": "x", "field": "x"},
           "width": {"scale": "xscale", "band": 1},
           "width": {"scale": "x", "band": true, "offset": -1},
           "y": {"scale": "yscale", "field": "amount"},
           "y": {"scale": "y", "field": "y"},
           "y2": {"scale": "yscale", "value": 0}
           "y2": {"scale": "y", "value": 0}
         },
         },
         "update": {
         "update": {
71번째 줄: 55번째 줄:
         "hover": {
         "hover": {
           "fill": {"value": "red"}
           "fill": {"value": "red"}
        }
      }
    },
    {
      "type": "text",
      "encode": {
        "enter": {
          "align": {"value": "center"},
          "baseline": {"value": "bottom"},
          "fill": {"value": "#333"}
        },
        "update": {
          "x": {"scale": "xscale", "signal": "tooltip.category", "band": 0.5},
          "y": {"scale": "yscale", "signal": "tooltip.amount", "offset": -2},
          "text": {"signal": "tooltip.amount"},
          "fillOpacity": [
            {"test": "datum === tooltip", "value": 0},
            {"value": 1}
          ]
         }
         }
       }
       }
     }
     }
   ]
   ]
}
}</graph>
</graph>

2019년 2월 6일 (수) 10:59 기준 최신판