"TEST DB ACCESS"의 두 판 사이의 차이

1번째 줄: 1번째 줄:
{{Graph:Chart
+
{
| debug=1
+
  "version": 2,
| table=bls.gov/US Women's weekly earnings as a percent of men's by age, annual averages.tab
+
  "width": 200,
| type=year | xField=year
+
  "height": 100,
| series="age_16_24", "age_25_34", "age_35_44", "age_45_54"
+
 
| yZero=false | yMin=50 | yMax=100
+
  "data": [
}}
+
    {
 +
      "name": "table",
 +
      "values": [
 +
        {"C": -4,  "L": 0, "f":"Pre"}, {"C": 0,  "L": 3, "f":"Pre"},
 +
        {"C": -4,  "L": 0, "f":"Post"}, {"C": 0,  "L": 4, "f":"Post"}
 +
      ]
 +
    }
 +
  ],
 +
 
 +
  "scales": [
 +
    {
 +
      "name": "xscale",
 +
      "type": "linear",
 +
      "range": "width",
 +
      "nice": true,
 +
      "zero": true,
 +
      "domain": {"data": "table", "field": "C"},
 +
      "domainMax": 4,
 +
      "domainMin": -4
 +
    },
 +
    {
 +
      "name": "yscale",
 +
      "type": "linear",
 +
      "range": "height",
 +
      "domain": {"data": "table", "field": "L"},
 +
      "domainMax": 4,
 +
      "domainMin": 0
 +
    },
 +
    {
 +
      "name": "color",
 +
      "type": "ordinal",
 +
      "range":"ordinal",
 +
      "domain": {"data": "table", "field": "f"}
 +
    }
 +
  ],
 +
 
 +
  "axes": [
 +
    {"orient": "bottom", "scale": "xscale", "tickCount": 10 },
 +
    {"orient": "left", "scale": "yscale", "tickCount": 5, "offset": { "signal": "-width / 2" } }
 +
  ],
 +
 
 +
  "marks": [
 +
    {
 +
      "type": "group",
 +
      "from": {
 +
        "facet": {
 +
          "name": "series",
 +
          "data": "table",
 +
          "groupby": "f"
 +
        }
 +
      },
 +
    "marks": [
 +
    {
 +
      "type": "area",
 +
      "from": {"data": "series"},
 +
      "encode": {
 +
        "enter": {
 +
          "x": {"scale": "xscale", "field": "C" },
 +
          "y": {"scale": "yscale", "field": "L"},
 +
          "y2": {"scale": "yscale", "value": 0 },
 +
          "fillOpacity": [{ "test": "indata('series', 'f', 'Pre')", "value": 0.3 }, {"value": 0}],
 +
          "strokeWidth": [{ "test": "indata('series', 'f', 'Pre')", "value": 0 }, {"value": 2}],
 +
          "fill": { "signal": "datum.C > 0 ? 'green': 'red'"},
 +
          "stroke": { "signal": "datum.C > 0 ? 'green': 'red'"}
 +
        }       
 +
      }
 +
    }
 +
  ]
 +
    }
 +
  ]
 +
}

2023년 2월 27일 (월) 17:45 판

{

 "version": 2,
 "width": 200,
 "height": 100,
 "data": [
   {
     "name": "table",
     "values": [
       {"C": -4,  "L": 0, "f":"Pre"}, {"C": 0,  "L": 3, "f":"Pre"}, 
       {"C": -4,  "L": 0, "f":"Post"}, {"C": 0,  "L": 4, "f":"Post"}
     ]
   }
 ],
 "scales": [
   {
     "name": "xscale",
     "type": "linear",
     "range": "width",
     "nice": true,
     "zero": true,
     "domain": {"data": "table", "field": "C"},
     "domainMax": 4,
     "domainMin": -4
   },
   {
     "name": "yscale",
     "type": "linear",
     "range": "height",
     "domain": {"data": "table", "field": "L"},
     "domainMax": 4,
     "domainMin": 0
   },
   {
     "name": "color",
     "type": "ordinal",
     "range":"ordinal",
     "domain": {"data": "table", "field": "f"}
   }
 ],
 "axes": [
   {"orient": "bottom", "scale": "xscale", "tickCount": 10 },
   {"orient": "left", "scale": "yscale", "tickCount": 5, "offset": { "signal": "-width / 2" } }
 ],
 "marks": [
   {
     "type": "group",
     "from": {
       "facet": {
         "name": "series",
         "data": "table",
         "groupby": "f"
       }
     },
   "marks": [
   {
     "type": "area",
     "from": {"data": "series"},
     "encode": {
       "enter": {
         "x": {"scale": "xscale", "field": "C" },
         "y": {"scale": "yscale", "field": "L"},
         "y2": {"scale": "yscale", "value": 0 }, 
         "fillOpacity": [{ "test": "indata('series', 'f', 'Pre')", "value": 0.3 }, {"value": 0}],
         "strokeWidth": [{ "test": "indata('series', 'f', 'Pre')", "value": 0 }, {"value": 2}],
         "fill": { "signal": "datum.C > 0 ? 'green': 'red'"},
         "stroke": { "signal": "datum.C > 0 ? 'green': 'red'"}
       }        
     }
   }
 ]
   }
 ]

}