Module:Graph: Difference between revisions

Content deleted Content added
m Change default showValues.fontcolor from black to persistentGrey, from sandbox
No edit summary
Line 3:
--
-- Version History (_PLEASE UPDATE when modifying anything_):
-- 2020-05-27 Map: allow specification which feature to display and changing the map center
-- 2020-04-08 Change default showValues.fontcolor from black to persistentGrey
-- 2020-04-06 Logarithmic scale outputs wrong axis labels when "nice"=true
-- 2020-03-11 Allow user-defined scale types, e.g. logarithmic scale
-- 2019-11-08 Apply color-inversion-friendliness to legend title, labels, and xGrid
Line 75 ⟶ 77:
local defaultValue = frame.args.defaultValue
local scaleType = frame.args.scaleType or "linear"
-- smallest value (only for numeric data)
-- minimaler Wertebereich (nur für numerische Daten)
local domainMin = tonumber(frame.args.domainMin)
-- largest value (only for numeric data)
-- maximaler Wertebereich (nur für numerische Daten)
local domainMax = tonumber(frame.args.domainMax)
-- color scale (only for numeric data)
-- Farbwerte der Farbskala (nur für numerische Daten)
local colorScale = frame.args.colorScale or "category10"
-- show legend
local legend = frame.args.legend
-- the map feature to display
local feature = frame.args.feature or "countries"
-- map center
local center = numericArray(frame.args.center)
-- format JSON output
local formatJson = frame.args.formatjson
Line 172 ⟶ 178:
{
-- data source for map paths data
name = "countries"feature,
url = basemapUrl,
format = { type = "topojson", feature = "countries"feature },
transform =
{
Line 182 ⟶ 188:
value = "data", -- data source
scale = scale,
translate = { 0, 0 },
center = center,
projection = projection
},
Line 202 ⟶ 209:
{
type = "path",
from = { data = "countries"feature },
properties =
{
Line 320 ⟶ 327:
local xscale =
{
name = "x",
type = xScaleType or "linear",
range = "width",
zero = false, -- do not include zero value
nice = truexScaleType ~= "log", -- force round numbers for yx scale, but log scale outputs a wrong "nice" scale
___domain = { data = "chart", field = "x" }
}
if xScaleType then xscale.type = xScaleType else xscale.type = "linear" end
if xMin then xscale.domainMin = xMin end
if xMax then xscale.domainMax = xMax end
Line 352 ⟶ 359:
local yscale =
{
name = "y",
type = yScaleType or "linear",
range = "height",
-- area charts have the lower boundary of their filling at y=0 (see marks.properties.enter.y2), therefore these need to start at zero
zero = chartType ~= "line",
nice = yScaleType ~= "log" -- force round numbers for y scale, but log scale outputs a wrong "nice" scale
nice = true
}
if yScaleType then yscale.type = yScaleType else yscale.type = "linear" end
if yMin then yscale.domainMin = yMin end
if yMax then yscale.domainMax = yMax end