Module:Chart data/test chart

From RuneRealm Wiki

This is the current revision of this page, as edited by Alex (talk | contribs) at 00:00, 17 October 2024 (Created page with "local helper = require('Module:Chart data') local data = { type = 'scatter', data = { datasets = { { label = 'line 1', showLine = true, fill = false, backgroundColor = tostring(helper.colorPallets.qualitative[1]:fade(0.2)), borderColor = tostring(helper.colorPallets.qualitative[1]), data = helper.generateXYFromFunc(function(x) return x/10 end, 1, 100, 10) }, { label = 'line 2', showLine = true, fill = false, backgroun..."). The present address (URL) is a permanent link to this version.

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Chart data/test chart/doc

local helper = require('Module:Chart data')

local data = {
	type = 'scatter',
	data = {
		datasets = {
			{
				label = 'line 1',
				showLine = true,
				fill = false,
				backgroundColor = tostring(helper.colorPallets.qualitative[1]:fade(0.2)),
				borderColor = tostring(helper.colorPallets.qualitative[1]),
				data = helper.generateXYFromFunc(function(x) return x/10 end, 1, 100, 10)
			},
			{
				label = 'line 2',
				showLine = true,
				fill = false,
				backgroundColor = tostring(helper.colorPallets.qualitative[2]:fade(0.2)),
				borderColor = tostring(helper.colorPallets.qualitative[2]),
				data = helper.generateXYFromFunc(function(x) return x/5 end, 1, 100, 10)
			},
			{
				label = 'line 3',
				showLine = true,
				fill = false,
				backgroundColor = tostring(helper.colorPallets.qualitative[3]:fade(0.2)),
				borderColor = tostring(helper.colorPallets.qualitative[3]),
				data = helper.generateXYFromFunc(function(x) return x/2 end, 1, 100, 10)
			},
			{
				label = 'line 4',
				showLine = true,
				fill = false,
				backgroundColor = tostring(helper.colorPallets.qualitative[4]:fade(0.2)),
				borderColor = tostring(helper.colorPallets.qualitative[4]),
				data = helper.generateXYFromFunc(function(x) return x end, 1, 100, 10)
			},
			{
				label = 'line 5',
				showLine = true,
				fill = false,
				backgroundColor = tostring(helper.colorPallets.qualitative[5]:fade(0.2)),
				borderColor = tostring(helper.colorPallets.qualitative[5]),
				data = helper.generateXYFromFunc(function(x) return 1.5*x end, 1, 100, 10)
			},
			{
				label = 'line 6',
				showLine = true,
				fill = false,
				backgroundColor = tostring(helper.colorPallets.qualitative[1]:fade(0.2)),
				borderColor = tostring(helper.colorPallets.qualitative[1]),
				borderDash = { 5, 5 },
				pointStyle = 'triangle',
				pointRadius = 5,
				data = helper.generateXYFromFunc(function(x) return 2*x end, 1, 100, 10)
			},
			{
				label = 'line 7',
				showLine = true,
				fill = false,
				backgroundColor = tostring(helper.colorPallets.qualitative[2]:fade(0.2)),
				borderColor = tostring(helper.colorPallets.qualitative[2]),
				borderDash = { 5, 5 },
				pointStyle = 'triangle',
				pointRadius = 5,
				data = helper.generateXYFromFunc(function(x) return 3*x end, 1, 100, 10)
			},
			{
				label = 'line 8',
				showLine = true,
				fill = false,
				backgroundColor = tostring(helper.colorPallets.qualitative[3]:fade(0.2)),
				borderColor = tostring(helper.colorPallets.qualitative[3]),
				borderDash = { 5, 5 },
				pointStyle = 'triangle',
				pointRadius = 5,
				data = helper.generateXYFromFunc(function(x) return 4*x end, 1, 60, 10)
			},
			{
				label = 'line 9',
				showLine = true,
				fill = false,
				backgroundColor = tostring(helper.colorPallets.qualitative[4]:fade(0.2)),
				borderColor = tostring(helper.colorPallets.qualitative[4]),
				borderDash = { 5, 5 },
				pointStyle = 'triangle',
				pointRadius = 5,
				data = helper.generateXYFromFunc(function(x) return 5*x end, 1, 50, 10)
			},
			{
				label = 'line 10',
				showLine = true,
				fill = false,
				backgroundColor = tostring(helper.colorPallets.qualitative[5]:fade(0.2)),
				borderColor = tostring(helper.colorPallets.qualitative[5]),
				borderDash = { 5, 5 },
				pointStyle = 'triangle',
				pointRadius = 5,
				data = helper.generateXYFromFunc(function(x) return 100 end, 1, 100, 10)
			},
		}
	},
	options = {
		maintainAspectRatio = false,
		tooltips = {
			mode = 'x',
			position = 'nearest',
			intersect = false
		},
		scales = {
			xAxes = {
				{
					scaleLabel = {
						display = true,
						labelString = 'x'
					}
				}
			},
			yAxes = {
				{
					scaleLabel = {
						display = true,
						labelString = 'y'
					}
				}
			}
		}
	}
}

return data