Content deleted Content added
Tom.Reding (talk | contribs) m Update version history |
allow x or y log axes: copied from Module:Graph/sandbox after testing on Template:Graph:Chart/testcases, source from de:Modul:Graph under CC-BY-SA |
||
Line 3:
--
-- Version History (_PLEASE UPDATE when modifying anything_):
-- 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
-- 2019-01-24 Allow comma-separated lists to contain values with commas
Line 65 ⟶ 66:
function p.map(frame)
-- map path data for geographic objects
local basemap = frame.args.basemap or "
-- scaling factor
local scale = tonumber(frame.args.scale) or 100
Line 313 ⟶ 314:
end
local function getXScale(chartType, stacked, xMin, xMax, xType, xScaleType)
if chartType == "pie" then return end
Line 319 ⟶ 320:
{
name = "x",
range = "width",
zero = false, -- do not include zero value
Line 325:
___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 345 ⟶ 346:
end
local function getYScale(chartType, stacked, yMin, yMax, yType, yScaleType)
if chartType == "pie" then return end
Line 351 ⟶ 352:
{
name = "y",
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
Line 357:
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
Line 842 ⟶ 843:
local yAxisFormat = frame.args.yAxisFormat
local xAxisAngle = tonumber(frame.args.xAxisAngle)
-- x and y scale types
local xScaleType = frame.args.xScaleType
local yScaleType = frame.args.yScaleType
-- show grid
local xGrid = frame.args.xGrid or "0"
Line 910 ⟶ 914:
local scales = {}
local xscale = getXScale(chartType, stacked, xMin, xMax, xType, xScaleType)
table.insert(scales, xscale)
local yscale = getYScale(chartType, stacked, yMin, yMax, yType, yScaleType)
table.insert(scales, yscale)
|