Module:TestTimChart1
From MaRDI portal
Documentation for this module may be created at Module:TestTimChart1/doc
local p = {}
function p.renderChart(frame)
local height = frame.args.height or '500px' -- Default height is 500px if not specified
-- Enhanced and more visually interesting chart data
local chartData = {
type = 'bar',
data = {
labels = {'January', 'February', 'March', 'April', 'May', 'June'},
datasets = {
{
label = 'Dataset 1',
backgroundColor = '#ff6384',
borderColor = '#ff6384',
borderWidth = 1,
data = {65, 59, 80, 81, 56, 55}
},
{
label = 'Dataset 2',
backgroundColor = '#36a2eb',
borderColor = '#36a2eb',
borderWidth = 1,
data = {28, 48, 40, 19, 86, 27}
},
{
label = 'Dataset 3',
backgroundColor = '#cc65fe',
borderColor = '#cc65fe',
borderWidth = 1,
data = {12, 50, 75, 30, 70, 95}
}
}
},
options = {
responsive = true,
maintainAspectRatio = false, -- This will allow custom height
scales = {
yAxes = {{
ticks = {
beginAtZero = true
}
}}
}
}
}
local chartDataJson = mw.text.jsonEncode(chartData)
local chartContainer = mw.html.create('div')
:addClass('wikiChartContainer')
:css('height', height)
:attr('data-chartdata', chartDataJson)
return tostring(chartContainer)
end
return p