틀:Graph:Lines: 두 판 사이의 차이

위키백과, 우리 모두의 백과사전.
내용 삭제됨 내용 추가됨
편집 요약 없음
Yurik (토론 | 기여)
mw:Template:Graph:Lines에서 Bouzinac,Timbaaa: "Syncing from sandbox - with two new parameters"에 의한 편집 한 개를 복사함. (docs, translate)
1번째 줄: 1번째 줄:
<includeonly>{{#tag:{{#if:{{{debug|}}}|syntaxhighlight|graph}}|</includeonly><noinclude>{{설명문서}}<syntaxhighlight lang=html><graph></syntaxhighlight>{{#tag:syntaxhighlight|</noinclude>
<includeonly>{{#tag:{{#if:{{{debug|}}}|syntaxhighlight|graph}}|</includeonly><noinclude>{{설명문서}}<syntaxhighlight lang=html><graph mode="interactive" title=""></syntaxhighlight>{{#tag:syntaxhighlight|</noinclude>
{
{
//
//
37번째 줄: 37번째 줄:
| "datum.{{{xField}}}"
| "datum.{{{xField}}}"
}}
}}
},
}
{"type": "sort", "by": ["_xfield"]},
, {"type": "sort", "by": ["_xfield"]}
{{#if:{{{series|}}}
{{#if:{{{series|}}}
| {"type": "fold", "fields": [{{{series}}}]}
| , {"type": "fold", "fields": [{{{series}}}]}
}}
{{#if:{{{replaceZerosWith|}}}
| , {"type": "formula", "field": "_yfield", "expr": "max(datum.{{#if:{{{series|}}}|value|{{{value|value}}}}}, {{{replaceZerosWith}}})" }
| , {"type": "formula", "field": "_yfield", "expr": "datum.{{#if:{{{series|}}}|value|{{{value|value}}}}}" }
}}
{{#ifeq:{{{yScale|}}}|log
| , {"type": "filter", "test": "datum._yfield != 0"}
}}
}}
]
]
67번째 줄: 74번째 줄:
{
{
"name": "y",
"name": "y",
"type": "linear",
"type": "{{{yScale|linear}}}",
"range": "height",
"range": "height",
"domain": {"data": "chart", "field": "{{{value|value}}}"},
"domain": {"data": "chart", "field": "_yfield"},
{{#if:{{{yZero|}}}|"zero": {{{yZero}}},}}
{{#if:{{{yZero|}}}|"zero": {{{yZero}}},}}
{{#if:{{{yMin|}}}|"domainMin": {{{yMin}}},}}
{{#if:{{{yMin|}}}|"domainMin": {{{yMin}}},}}
129번째 줄: 136번째 줄:
"properties": {
"properties": {
"enter": {
"enter": {
"y": {"scale": "y", "field": "{{{value|value}}}"},
"y": {"scale": "y", "field": "_yfield"},
"x": {"scale": "x", "field": "_xfield"},
"x": {"scale": "x", "field": "_xfield"},
"stroke": {"scale": "color", "field": "{{{group|key}}}"},
"stroke": {"scale": "color", "field": "{{{group|key}}}"},

2020년 9월 16일 (수) 14:57 판

<graph mode="interactive" title="">
{
  //
  // ATTENTION: This code is maintained at https://www.mediawiki.org/wiki/Template:Graph:Lines
  //            Please do not modify it anywhere else, as it may get copied and override your changes.
  //            Suggestions can be made at https://www.mediawiki.org/wiki/Template_talk:Graph:Lines
  //
  // Template translation is in https://commons.wikimedia.org/wiki/Data:Original/Template:Graphs.tab
  //

  "version": 2,
  "width": 400,
  "height": 300,
  "padding": "strict",

  "signals": [{"name": "rightwidth", "expr": "width + padding.right"}],
  "data": [{
    "name": "chart",

"url": "tabular:///{{{table}}}",
    "format": {"type": "json"
, "property": "data"

    },
    "transform": [
      // Convert xField parameter into a field "_xfield"
      {"type": "formula", "field": "_xfield", "expr":
"datetime(datum.year, 0, 1)"
      }
      , {"type": "sort", "by": ["_xfield"]}

, {"type": "formula", "field": "_yfield", "expr": "datum.value" }

    ]
  },

  ],
  "scales": [
    {
      "name": "x",
      "type": "time",
      "domain": {"data": "chart", "field": "_xfield"},
      "range": "width",



    },
    {
      "name": "y",
      "type": "linear",
      "range": "height",
      "domain": {"data": "chart", "field": "_yfield"},



    },
    {
      "name": "color",
      "type": "ordinal",
      "domain": {"data": "chart", "field": "key"},
      "range": "category10"
    },

  ],

  "axes": [
    {"scale": "x", "type": "x", "tickSizeEnd": 0
, "ticks": 7


},
    {"scale": "y", "type": "y", "tickSizeEnd": 0



}
  ],

  "marks": [
    // Group data by the group parameter or "key", and draw lines, one line per group
    {
      "type": "group",
      "from": {
        "data": "chart",
        "transform": [{"type": "facet", "groupby": ["key"]}]
      },
      "marks": [
        {
          "type": "line",
          "properties": {
            "enter": {
              "y": {"scale": "y", "field": "_yfield"},
              "x": {"scale": "x", "field": "_xfield"},
              "stroke": {"scale": "color", "field": "key"},
              "interpolate": {"value": "monotone"},
              "strokeWidth": {"value": 2.5}
            }
          }
        }
      ],
    }


  ]
}
</graph>