3 -- This script creates a graph of the known quests for the various locales from static.lua using gnuplot.
5 loadfile("../static.lua")()
9 for locale, data in pairs(QuestHelper_StaticData or {}) do
12 for faction in pairs({1, 2}) do
13 levels = data.quest and data.quest[faction] or {}
15 plotdata[locale][faction] = {}
18 local list = levels[level] or {}
21 for name, data in pairs(list) do
24 for hash in pairs(data.alt) do
30 plotdata[locale][faction][math.ceil(level/5)] = (plotdata[locale][faction][math.ceil(level/5)] or 0) + count
35 file = io.open("plot.dat", "w")
41 for locale, data in pairs(plotdata) do
42 if data[1][level] > 0 or data[2][level] > 0 then use_locale[locale] = true end
43 line = line .. data[1][level].." "..data[2][level].." "
45 file:write(line.."\n")
48 use_locale["zhCN"] = false
50 local title = {enUS="English", frFR="Français", esES="Español (España)", deDE="Deutsch", koKR="한국어", esMX="Español (Mexico)"}
54 local locale_count = 0
55 for locale in pairs(plotdata) do
56 if use_locale[locale] then
57 locale_count = locale_count + 1
61 local locale_colour_alliance = {enUS="#ff0000", frFR="#0000aa", deDE="#666666", esES="#ffaa00", koKR="#00aaff", zhCN="#ff00ff", esMX="#dddddd"}
62 local locale_colour_horde = {enUS="#dd0000", frFR="#000088", deDE="#44444444", esES="#dd8800", koKR="#0088dd", zhCN="#dd00dd", esMX="#bfbfbf"}
66 for locale in pairs(plotdata) do
67 if use_locale[locale] then
68 local a = (j-0.5)/(locale_count+1)+0.5
69 local b = a + 1/(locale_count+1)
71 command = (command and command..", " or "") .. "\"plot.dat\" using ($0+1):"..i..":($0+"..a.."):($0+"..b..") title \""..title[locale].."\" lc rgb '"..locale_colour_alliance[locale].."' with boxes"
72 command = (command and command..", " or "") .. "\"plot.dat\" using ($0+1):(-$"..(i+1).."):($0+"..a.."):($0+"..b..") notitle lc rgb '"..locale_colour_horde[locale].."' with boxes"
78 local stream = io.popen("gnuplot", "w")
81 stream:write("set terminal svg size 800,600\n")
82 stream:write("set output 'locale.svg'\n")
83 --stream:write("set terminal png notransparent size 1024,786\n")
84 --stream:write("set output 'locale.png'\n")
85 --stream:write("set terminal pdf colour\n")
86 --stream:write("set output 'locale.pdf'\n")
87 stream:write("set key title 'Quests'\n")
88 stream:write("set key top left Left reverse samplen 1\n")
89 stream:write("set style fill solid 1 border -1\n")
90 stream:write("set xlabel 'Level'\n")
91 local line = "set xtics ("
93 line = line .. "'" .. i*5+1 .. "-" .. i*5+5 .. "' "..i+1 .. (i==13 and ")\n" or ",")
96 stream:write("set ytics out scale 0 ('Alliance' 250, 'Horde' -250)\n")
97 if command then stream:write("plot [0:15]"..command..";\n") end
102 os.remove("plot.dat")