Vorlage:Graph:Lines

Aus Regiowiki
Version vom 4. Juli 2020, 19:46 Uhr von Agruwie (Diskussion | Beiträge) (von w:Vorlage:Graph:Lines)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Zur Navigation springen Zur Suche springen

Documentation

i Info: Die Hauptversion dieser Vorlage befindet sich unter Template:Graph:Lines. Änderungswünsche sollten daher dort angefragt und durchgeführt und die Änderungen dann an die lokalen Kopien manuell verteilt werden.

Dieser Vorlage erlaubt die grafische Darstellung von tabellarischen Commons-Datensätzen oder aus Wikidata mittels des Wikidata-Abfragedienstes (https://query.wikidata.org/) in SPARQL-Syntax.

Beispiele

{{Graph:Lines
| table=bls.gov/US Women's weekly earnings as a percent of men's by age, annual averages.tab
| type=year | xField=year
| series="age_16_24", "age_25_34", "age_35_44", "age_45_54"
| title=Geschlechtsspezifisches Lohngefälle in den USA
| yZero=false | xAxis=Year | yAxis=Percentage | yMax=100 | yGrid=y | legend=Altersgruppe
}}

Lua-Fehler in Modul:TNT, Zeile 157: attempt to index field 'data' (a nil value).


{{Graph:Lines
| tabletype=query
| table=
SELECT ?decade (COUNT(?decade) AS ?count) 
WHERE {
  ?item wdt:P31 wd:Q3305213 .
  ?item wdt:P571 ?inception .
  BIND( year(?inception) as ?year ). 
  BIND( ROUND(?year/10)*10 as ?decade ) .
  FILTER( ?year > 1400)
} 
GROUP BY ?decade ORDER BY ?decade
| series="count" | type=year | xField=decade
| title=Gemälde nach Jahrzehnt
}}

Lua-Fehler in Modul:TNT, Zeile 157: attempt to index field 'data' (a nil value).


Wikidata query produces three columns - year, population size, and country name. This graph shows one line per country.
{{Graph:Lines
| tabletype=query
| table=
#Population of countries sharing a border with Germany
SELECT ?year ?population ?countryLabel 
WHERE {
  {
    SELECT ?country ?year (AVG(?population) AS ?population) WHERE {
      {
        SELECT ?country (YEAR(?date) AS ?year) ?population WHERE {
          ?country wdt:P47 wd:Q183.
          ?country p:P1082 ?populationStatement.
          ?populationStatement ps:P1082 ?population.
          ?populationStatement pq:P585 ?date.
          ?country wdt:P31 wd:Q3624078.
        }
      }
    }
    GROUP BY ?country ?year
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
| type=year | xField=year | group=countryLabel | value=population
| title=Bevölkerungszahl der Nachbarländer Deutschlands
| legend=- | xGrid=y | yGrid=y | yTicks=7 | width=600
}}

Lua-Fehler in Modul:TNT, Zeile 157: attempt to index field 'data' (a nil value).

Parameter

Lua-Fehler in Modul:TNT, Zeile 157: attempt to index field 'data' (a nil value)

Siehe auch

Werkzeuge

Bei technischen Fragen zu dieser Vorlage kannst du dich auch an die Vorlagenwerkstatt wenden. Inhaltliche Fragen und Vorschläge gehören zunächst auf die Diskussionsseite. Sie können ggf. auch an eine passende Redaktion, Portal usw. gerichtet werden.

<graph>
{
  //
  // 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"]},

    ]
  },

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



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



    },
    {
      "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": "value"},
              "x": {"scale": "x", "field": "_xfield"},
              "stroke": {"scale": "color", "field": "key"},
              "interpolate": {"value": "monotone"},
              "strokeWidth": {"value": 2.5}
            }
          }
        }
      ],
    }


  ]
}
</graph>