// iplot.js // @version 0.6.3 // @copyright 2021,2022,2023,2024; Friedrich Wichmann // Javascript Code für Diagramme aus CSV-Daten 'use strict'; const sHeaderId = "ppi-head-"; const sSubDescId = "ppi-desc-"; const sCanvasId = "ppi-diag-"; var ppiDebug = 1; var myDiag = []; var maxDiag = 0; // Initialisierungsfunktion function iplotInit() { for (var dnr = 1; dnr <= 6; dnr++) { if (document.getElementById(sHeaderId + dnr)) { maxDiag = dnr; myDiag[dnr] = { "headerId" : sHeaderId + dnr, "subDescId" : sSubDescId + dnr, "canvasId" : sCanvasId + dnr, "DW" : 600, "DW0" : 600, "SW" : 500, "DH" : 360, "DH0" : 360, "DX" : 30, "DY" : 30, "ysymc" : 3, "iplotref" : null, "title" : null, "tmod" : null, "bg" : "lightyellow", "fillmod" : null, "axis" : null, "bars" : null, "barmax" : 0, "line" : null, "linemax" : 0, "xlist" : [], "vlist" : [], "plist" : [], "rmod" : null, "expl" : null, "small" : 0, "bis" : 0, "areaint" : 0, "crangeij" : null, "cats" : [], "xstep" : 1, "xmin" : 1990, "xmax" : 2050, }; myDiag[dnr].iplotref = A1todij(dnr, tab(dnr).iplot.ref); clog("iplotInit dnr=" + dnr + " ref=" + tab(dnr).iplot.ref + " iplotref=" + myDiag[dnr].iplotref); } } } // Liefert das iplot-Tabellen-Objekt function tab(dnr) { if (dnr==1) return fw4t1; if (dnr==2) return fw4t2; if (dnr==3) return fw4t3; if (dnr==4) return fw7t3n; if (dnr==5) return tabco2mlo; if (dnr==6) return tabglbts; return undefined; } // Liefert nullbasierte d,i,j-Koordinaten für einfache A1-Referenzen function A1todij(dnr, A1) { if (!A1 || A1.length < 2) return null; var a = A1.charCodeAt(0); var b = A1.charCodeAt(1); var i = (a >= 65 && a <= 90) ? a - 65 : NaN; if (b >= 48 && b < 58) { var j = parseInt(A1.substr(1)) - 1; } else if (b >= 65 && b <= 90 && A1.length >= 3) { i = 26 + (i * 26) + b - 65; var j = parseInt(A1.substr(2)) - 1; } else return null; return [dnr, i, j]; } // Liefert nullbasierte d,i,j,i',j'-Koordinaten für einfache A1-Bereiche function A1Rangetodij(dnr, A1R) { if (!A1R || A1R.length < 5) return null; var p = A1R.indexOf(":"); var f = A1R.substr(0, p); var t = A1R.substr(p+1); var fij = A1todij(dnr, f); var tij = A1todij(dnr, t); return [dnr, fij[1], fij[2], tij[1], tij[2]]; } // Liefert den Inhalt einer Zelle der iplot-Tabelle für die i+di,j+dj-Koordinaten function ref(dij, di, dj) { var i = dij[1] + ((di) ? di : 0); var j = dij[2] + ((dj) ? dj : 0); return tab(dij[0]).tab[j][i]; } // Logausgabe abhängig von ppiDebug. function clog(txt) { if (ppiDebug) console.log(txt); } // Liefert eine Textalternative: aus '{'A['|'B]'}' wird (alt) ? B : A im String. function altTxt(alt, txt) { if (typeof(txt) == "number") { txt = txt.toString(); } var i = txt.indexOf('{'); var j = -1, k = 0; var s = ""; while (i>=0) { s += txt.substring(j+1, i); j = txt.indexOf('}', i+1); if (j<0) j = txt.length; k = txt.indexOf('|', i+1); if (k>0 && k= 2) ? darr : (darr[0].indexOf(':') >= 0) ? undefined : darr[0]; } oBarLine.mods = (mod1 == "s") ? mod : undefined; } // Abspeichern von Änderungen für die Legende function setExplMod(dnr, myD, mod) { if (!myD.expl) { clog("setExplMod "+dnr+" mod="+mod+" not possible as myD.expl is null"); return; } myD.expl.on = (mod); } // Abspeichern von Änderungen für den Titel function setTMod(myD, anr, mod) { clog("setTMod "+mod+" anr="+anr+" modt="+myD.axis[anr].modt); if (mod && myD.axis[anr] && myD.axis[anr].modt) { myD.tmod = myD.title + " • " + myD.axis[anr].modt; } else { myD.tmod = null; } } // Abspeichern von Änderungen der Flächensummen (mod=[Wert, xi] oder 'u') function setAreaInt(dnr, myD, nr, mod) { if (nr == 0) { myD.areaint = (mod == 1); return; } if (!myD.line[nr] || !myD.line[nr].area) return; myD.line[nr].area.mod = (mod == "u") ? undefined : mod; } // Abspeichern von x-Wert-Änderungen (mod=0|1|-1 oder Liste mit Name/Wert abwechselnd) function setXListMod(dnr, myD, xval, mod) { var xlist = myD.xlist; for (var i=0; i iran[4]) break; var t = ref(rdij); clog("drawIplot check dij=" + rdij + " t=" + t + " " + typeof(t)); if (!t || typeof(t) != "string" || t.indexOf("iplot.") < 0) { break; } if (t.indexOf("iplot.a") >= 0) { /* ax/ay/aa Achsen iplot.a[xya]=c1,mi,ma,da,tx,c2,dg,c3,d3,f,ta */ var td = t.substr(7, 1); /* td=[xya]=x-Achse/y-Achse/2. y-Achse */ var h = (td == "x") ? 0 : (td == "y") ? 1 : 2; var c1 = ref(rdij, 1, 0); /* c1=col=Achsenforbe */ var mi = ref(rdij, 2, 0); /* mi=min=Minimaler Wert */ var ma = ref(rdij, 3, 0); /* ma=max=Maximaler Wert */ var da = ref(rdij, 4, 0); /* da=daxis=Abstand Achsenstriche */ var tx = ref(rdij, 5, 0); /* tx=txt=Achsenbezeichnung */ var c2 = ref(rdij, 6, 0); /* c2=gcol=Gitterfarbe */ var dg = ref(rdij, 7, 0); /* dg=dgrid=Abstand Gitterlinien */ var c3 = ref(rdij, 8, 0); /* c3=hcol=Hilfsgitterfarbe RFU */ var d3 = ref(rdij, 9, 0); /* d3=hgrid=Hilfgitterabstand RFU */ var f = ref(rdij, 10, 0); /* f=on=Achse eingeschaltet */ var ta = ref(rdij, 11, 0); /* ta=modt=extra Diagrammtitel */ if (f == undefined) f = 1; if (ta == undefined) ta = null; myD.axis[h] = { "dir" : td, "col" : c1, "min" : mi, "max" : ma, "daxis" : da, "on": f, "modc": null, "mods": null, "modt": ta, "txt" : tx, "gcol" : c2, "dgrid" : dg, "hcol" : c3, "hgrid" : d3}; } else if (t.indexOf("iplot.c") >= 0) { /* X-Kategorien iplot.c[]=td, xs, mi, ma */ var td = ref(rdij, 1, 0); /* td=A1:An X-Kategorien oder 0=mi/ma/xs verwenden */ var xs = ref(rdij, 2, 0); /* xs=xstep=Schrittweite X */ var mi = ref(rdij, 3, 0); /* mi=xmin=Minimaler X-Wert */ var ma = ref(rdij, 4, 0); /* ma=xmax=Maximaler X-Wert */ if (t.length >= 8) { /* Bereich[h] iplot.c=A1:An, xstep, xmin, xmax */ var h = parseInt(t.substr(7)); myD.cats[h] = { "rangeij": A1Rangetodij(dnr, td), "xmin": mi, "xmax": ma, "xstep": xs }; } else if (td != 0 && td.indexOf(":") >= 0) { /* Bereich A1:An der x-Werte==X-Kategorien */ myD.crangeij = A1Rangetodij(dnr, td); } else { /* Bereich xstep, xmin, xmax */ myD.xmin = mi; myD.xmax = ma; myD.xstep = xs; } } else if (t.indexOf("iplot.b") >= 0) { /* Balken iplot.b=c1,n,yd,f */ var h = parseInt(t.substr(7)); /* h=Balkennummer */ var c1 = ref(rdij, 1, 0); /* c1=col=Balkenfarbe */ var n = ref(rdij, 2, 0); /* n=name=Bezeichnung */ var yd = ref(rdij, 3, 0); /* yd=ydata=Bereich D1:Dn der y-Werte */ var f = ref(rdij, 4, 0); /* f=on=Balken eingeschaltet */ if (f == undefined) f = 1; myD.bars[h] = { "col" : c1, "name" : n, "ydata" : yd, "on" : f, "modc" : null, "mods": null }; if (h > myD.barmax) myD.barmax = h; } else if (t.indexOf("iplot.l") >= 0) { /* Linie iplot.l=c,n,yd,f,ty,w,ms,yo,yf */ var h = parseInt(t.substr(7)); /* h=Liniennummer */ var c = ref(rdij, 1, 0); /* c=col=Linienfarbe */ c = getColFrom(c, "red"); var n = ref(rdij, 2, 0); /* n=name=Bezeichnung */ var yd = ref(rdij, 3, 0); /* yd=ydata=Bereich D1:Dn der y-Werte */ var f = ref(rdij, 4, 0); /* f=on=Linie eingeschaltet */ var ty = ref(rdij, 5, 0); /* ty=type=Typ (s.u., Default 1) */ if (!ty) ty = 1; var w = ref(rdij, 6, 0); /* w=width=Breite (Default 4) */ if (!w) w = 4; var ms = ref(rdij, 7, 0); /* ms=msym=Symbol */ var yo = ref(rdij, 8, 0); /* ya=yoffs=y-Offset (Default 0) */ if (!yo) yo = 0; var yf = ref(rdij, 9, 0); /* yf=y-Faktor (Default 1) */ if (!yf) yf = 1; var c2 = ref(rdij, 10, 0); /* c2=Linienfarbe oben */ myD.line[h] = { "col" : c, "col2": c2, "name" : n, "ydata" : yd, "on" : f, "modc" : null, "mods": null, "area" : {}, "type" : ty, "width" : w, "msym" : ms, "yoffs": yo, "yf": yf }; if (h > myD.linemax) myD.linemax = h; } else if (t.indexOf("iplot.i") >= 0) { /* Flächengrößen iplot.i=c,n,v,s,x0,y0 */ var h = parseInt(t.substr(7)); /* h=Nummer der zugehörigen Linie */ var c = ref(rdij, 1, 0); /* c=col=Schriftfarbe (Default grey) */ if (!c) c = "grey"; var n = ref(rdij, 2, 0); /* n=name=Bezeichung */ var v = ref(rdij, 3, 0); /* v=val=Wert */ var s = ref(rdij, 4, 0); /* s=size=Schriftgröße */ var x0 = ref(rdij, 5, 0); /* x0=X-Position */ var y0 = ref(rdij, 6, 0); /* y0=Y-Position */ if (!myD.line[h]) { myD.line[h] = { "on" : 0, "type" : 1, "modc" : null, "mods": null, "area" : {} }; } myD.line[h].area = { "col" : c, "name" : n, "val" : v, "size" : s, "x0" : x0, "y0" : y0, "mod" : null, }; if (h > myD.linemax) myD.linemax = h; } else if (t == "iplot.expl") { /* Legende iplot.expl=c,r,w,h,bg,x0,y0,f */ var c = ref(rdij, 1, 0); /* c=col=Schriftfarbe */ var r = ref(rdij, 2, 0); /* r=refs=Liste von Referenzen D1;E2;F3.. */ var w = ref(rdij, 4, 0); /* w=width=Breite der Legende */ if (!w) w = 200; var h = ref(rdij, 5, 0); /* h=height=Höhe der Legende */ if (!h) h = 130; var bg = ref(rdij, 6, 0); /* bg=Hintergrundfarbe */ if (!bg) bg = "white"; var x0 = ref(rdij, 7, 0); /* x0=x-Position */ if (!x0) x0 = 0; var y0 = ref(rdij, 8, 0); /* y0=y-Position */ if (!y0) y0 = 0; var f = ref(rdij, 9, 0); /* f=on=Legende sichtbar */ if (f == undefined) f = 1; myD.expl = { "col" : c, "refs" : r , "bg" : bg, "width" : w, "height" : h, "x0" : x0, "y0" : y0, "on": f}; } } } // Zeichne die angegebene Achse (h=0, 1, 2: x-, y-, alt-y-Achse) function drawAxis(context, dnr, myD, h, xs) { if (!myD.axis[h]) return undefined; var mi = (h==0 && myD.rmod) ? myD.rmod[0].xmin : myD.axis[h].min; var ma = (h==0 && myD.rmod) ? myD.rmod[0].xmax : myD.axis[h].max; if (mi==undefined || ma==undefined) return undefined; var d = ma - mi; var ys = (d) ? myD.DH / d : 0; if (!ys) return undefined; if (!myD.axis[h].on || xs==null) return {"ys": ys, "y0": mi}; var da = (h==0 && myD.rmod) ? myD.rmod[0].daxis : myD.axis[h].daxis; var dg = (h==0 && myD.rmod) ? myD.rmod[0].dgrid : myD.axis[h].dgrid; context.strokeStyle = (myD.axis[h].gcol) ? myD.axis[h].gcol : "lightgray"; context.lineWidth = 0.5; context.setLineDash([]); context.fillStyle = (myD.axis[h].col) ? myD.axis[h].col : "black"; context.textAlign = "left"; var x, y, x1, y1; if (myD.axis[h].dir == "x") { x = 0; y = myD.DY; x1 = 0; y1 = myD.DH+myD.DY+2; } else if (myD.axis[h].dir == "y") { x = myD.DX-2; y = 0; x1 = myD.DW+myD.DX-1; y1 = 0; if (myD.axis[h].txt && myD.axis[h].mods != 's') { context.fillText(altTxt(myD.small, myD.axis[h].txt), 3, myD.DY-15); } } else if (myD.axis[h].dir == "a") { x = myD.DW+myD.DX-2; y = 0; x1 = myD.DW+myD.DX+2; y1 = 0; if (myD.axis[h].txt && myD.axis[h].mods != 's') { context.textAlign = "right"; context.fillText(altTxt(myD.small, myD.axis[h].txt), myD.DW+2*myD.DX-4, myD.DY-15); } } // Zeichne Linien quer zur Achse im Gitterabstand (ggf. mehr wenn dicht bei Zahl) var uadd = (myD.axis[h].dir == "x") ? dg*0.6 : dg*0.1; //if (uadd <= 1.0) uadd = 1.1; // TODO for (var u=mi; (dg) && u<=ma+uadd; u+=dg) { if (myD.axis[h].dir == "x") { x = Math.round((u-mi)*xs) + myD.DX; x1 = x; } else /* "y" or "a" */ { y = myD.DH-Math.round((u-mi)*ys) + myD.DY; y1 = y; } context.beginPath(); context.moveTo(x, y); context.lineTo(x1, y1); context.stroke(); } // Zeichne Achsenbeschriftung im Abstand da if (myD.axis[h].mods == 's') { context.textAlign = "left"; return {"ys": ys, "y0": mi}; } context.fillStyle = (myD.axis[h].col) ? myD.axis[h].col : "black"; context.strokeStyle = (myD.axis[h].col) ? myD.axis[h].col : "black"; var uadd = (myD.axis[h].dir == "x") ? da*0.1 : da*0.1; for (var u=mi; (da) && u<=ma+uadd; u+=da) { var sVal = u.toString(); if (myD.axis[h].dir == "x") { x = Math.round((u-mi)*xs) + myD.DX; // schräg stellen / um 45° (justiert für 4stellige Jahreszahl) context.setTransform(0.7071, -0.7071, 0.7071, 0.7071, x-7, myD.DH+myD.DY+25); context.fillText(sVal, 0, 0); context.setTransform(1, 0, 0, 1, 0, 0); } else if (myD.axis[h].dir == "y") { y = myD.DH-Math.round((u-mi)*ys) + myD.DY; context.textAlign = "right"; context.fillText(sVal, myD.DX-4, y+3, myD.DX-5); } else /* "a" */ { x = myD.DW+myD.DX; y = myD.DH-Math.round((u-mi)*ys) + myD.DY; if (!dg) { context.beginPath(); context.moveTo(x-4, y); context.lineTo(x+2, y); context.stroke(); } context.textAlign = "left"; context.fillText(sVal, x+4, y+3, myD.DX-5); } } context.textAlign = "left"; return {"ys": ys, "y0": mi}; } function getColFrom(col, defcol) { if (!col) { return defcol; } if (typeof col == "object" && !Array.isArray(col)) { var arr = []; for (var k in col) { const kv = parseInt(k, 10); if (isNaN(kv)) continue; arr.push(k + ":" + col[k]); } clog("getColFrom arr="+arr.toString()); col = arr; } return col; } // Gibt Farbe oder Gradient zurück; wenn modc nicht gesetzt als Default c. function getModcCol(ctx, modc, c, bMid) { if (!modc) { if (typeof c == "object" && !Array.isArray(c)) { clog("getModcCol c="+c); c = Array.from(c); } if (!c || !Array.isArray(c)) { ctx.strokeStyle = undefined; return c; } modc = c; } if (typeof modc == "object" && !Array.isArray(modc)) { clog("getModcCol modc="+modc); modc = Array.from(modc); } if (Array.isArray(modc)) { const can = ctx.canvas; const lc = modc.length; var s = modc[0]; for (var i=1; i 1) { var na = myD.bars[bn].name.substr(0,3).toLowerCase(); for (var i=0; i= 4 && ty <= 6); const sym = setupLine(context, ty, myD.line[ln], modc); if (!sym) context.beginPath(); const sst = (typeof(context.strokeStyle) == "object") ? "grad" : context.strokeStyle; clog("line "+ln+" k=0.."+(kmax-1)+" x0="+x0+" dx="+dx+" xs="+xs.toFixed(4)+" ys="+ys.toFixed(4)+" sst="+sst); var xa, xe, xt, xx, yt, ya, ye; for (var k=0; k xmax) continue; //clog("k="+k+" kmax="+kmax+" x="+x+" linedij="+linedij); var y = ref(linedij, 0, k); if (pmod) { if (x == pmod[pi]) { clog("pi="+pi+" x="+x+" pmod="+pmod[pi+1]); xt = Math.round((x-x0)*xs + dx*xs*0.5) + myD.DX; yt = Math.round((pmod[pi+1]+yoffs)*yf*ys); if (!pi) { context.moveTo(xt, myD.DH-yt + myD.DY); } else { context.lineTo(xt, myD.DH-yt + myD.DY); } pi += 2; } } else if (y) { xt = Math.round((x-x0)*xs + dx*xs*0.5) + myD.DX; xx = (px && fgaps) ? xt - px : Math.round(dx*xs); yt = Math.round((y-y0+yoffs)*yf*ys); if (sym) { yt -= myD.ysymc; context.fillText(sym, xt, myD.DH-yt + myD.DY, xx); } else if (py) { /* y && py */ context.moveTo(xt-xx, myD.DH-py + myD.DY); context.lineDashOffset = xt-xx; context.lineTo(xt, myD.DH-yt + myD.DY); } else { /* y && !py */ xa = xt; ya = yt; } px = xt; py = yt; } else if (fgaps) { /* !y && fgaps */ // px,py behalten } else { /* !y */ if (py) { /* !y && py */ xe = Math.round((x-x0)*xs - dx*xs*0.5) + myD.DX; ye = py; if (xa && (ty == 9)) { var msym = myD.line[ln].msym; if (msym) { xt = Math.round((xa+xe)*0.5); yt = Math.round((ya+ye)*0.5); context.textAlign = "center"; context.fillText(msym, xt, myD.DH-yt + myD.DY + 2); } } } xa = py = undefined; } } // for k=0..numcat-1 if (!sym) context.stroke(); } // Typ 1=Linie, 2=gestrichelt, 3=Punkte, 4,5,6=waagrecht ergänzt, 9=mit Mittelmarkierung, String=Symbole function setupLine(context, ty, oLine, col) { var sym = (typeof(ty) == "string") ? ty : null; if (sym || ty == 9) { context.fillStyle = getModcCol(context, col, oLine.col); context.textAlign = "center"; } if (ty == 2 || ty == 5) context.setLineDash([5, 5]); else if (ty == 3 || ty == 6) context.setLineDash([2, 2]); else context.setLineDash([]); context.strokeStyle = getModcCol(context, col, oLine.col); context.lineWidth = oLine.width; return sym; } // Zeichne die Flächenbeschriftungen function drawAreaInt(context, dnr, myD, ln, xs, ys, x0, dx) { var on = myD.line[ln].on; var sk = Math.max(myD.DH / myD.DH0 * 1.2, 0.6); var sz = Math.round(myD.line[ln].area.size * sk); if (!on || !sz || !myD.areaint) return; var c1 = getModcCol(context, myD.line[ln].modc, myD.line[ln].area.col); var val = myD.line[ln].area.val; var mo = myD.line[ln].area.mod; if (mo == 0) { return; } if (mo && mo[0]) { val = mo[0]; } var txt = val.toString(); var xi = myD.line[ln].area.x0; var yi = myD.line[ln].area.y0; if (mo && mo[1]) { xi = mo[1]; } var x = Math.round((xi-x0)*xs + dx*xs*0.5) + myD.DX; var y = myD.DH - Math.round(yi*ys) + myD.DY; var prfont = context.font; context.font = sz.toString() + 'pt Arial'; var w = Math.round(context.measureText(txt).width); var h = Math.round(sz * 1); clog("iplot.i" + ln + " c1="+c1.toString() + " val="+txt + " dim="+w+","+h+" x="+x+" sk="+sk.toFixed(2)); context.textAlign = "left"; context.fillStyle = "white"; context.fillRect(x-2, y-h-1, w+2, h+2); context.setLineDash([]); context.strokeStyle = c1; context.lineWidth = 1; context.strokeText(txt, x, y); context.font = prfont; } // Zeichne vertikale Pfeile function drawVArrow(context, dnr, myD, h, xs, ys, x0, y0, dx) { var modv = myD.vlist[h]; if (!modv) return; var c = (modv.col) ? modv.col : "black"; var ty = (modv.ty) ? parseInt(modv.ty) : 1; var ar = (modv.ty) ? modv.ty.substr(1) : 'a'; var w = (modv.wid) ? modv.wid : 1; var x = modv.xval; var y1 = modv.y1; var y2 = modv.y2; var xt = Math.round((x-x0)*xs + dx*xs*0.5) + myD.DX; var lx1 = Math.round(dx*xs*((ar=='b') ? 1 : 0.3)); var lx2 = Math.round(dx*xs*((ar=='b') ? 3 : 0.3)); var ly2 = Math.round(dx*ys*((ar=='b') ? 0 : 40)); var yt1 = Math.round((y1-y0)*ys); var yt2 = Math.round((y2-y0)*ys); var yd = (modv.yd) ? modv.yd : ((ar=='b') ? 25 : 5); var yy = (ar=='b' && yd > 5) ? yd-3 : 0; clog("iplot.v" + h + " c="+c.toString() +" x="+x+" y1,y2="+y1+","+y2+" xt="+xt+" yt1,yt2="+yt1+","+yt2); var oLine = { "col": c, "width": w }; setupLine(context, ty, oLine); context.beginPath(); context.moveTo(xt, myD.DH-yt1-yy + myD.DY); context.lineDashOffset = xt; context.lineTo(xt, myD.DH-yt2 + myD.DY); context.setLineDash([]); context.moveTo(xt-lx1, myD.DH-yt1 + myD.DY); context.lineTo(xt+lx2, myD.DH-yt1 + myD.DY); context.moveTo(xt-lx1, myD.DH-yt2-ly2 + myD.DY); context.lineTo(xt, myD.DH-yt2 + myD.DY); context.lineTo(xt+lx2, myD.DH-yt2-ly2 + myD.DY); context.stroke(); if (modv.col2 && modv.txt) { var yt = myD.DH-yt1-yd + myD.DY; var p = modv.txt.indexOf('\n'); var txt = (p < 0) ? modv.txt : modv.txt.substr(0, p); var ht = (p < 0) ? 10 : 20; var wt = Math.round(context.measureText(txt).width); if (p >= 0) { var wt2 = Math.round(context.measureText(modv.txt.substr(p+1).width)); if (wt2 > wt) wt = wt2; } context.fillStyle = "white"; context.fillRect(xt-wt/2-1, yt-ht-1, wt+2, ht+2); context.fillStyle = modv.col2; context.lineWidth = 1; context.textAlign = "left"; context.fillText(txt, xt-wt/2, yt-ht+9); if (p >= 0) { context.fillText(modv.txt.substr(p+1), xt-wt/2, yt-1); } } } // Zeichne gefüllte Bereiche function drawFillings(context, dnr, myD, h, xs, ys, x0, y0, dx) { var modf = (myD.fillmod) ? myD.fillmod[h] : null; if (!modf) return; var c1 = modf.c1; var c2 = modf.c2; var x1 = modf.x1; var x2 = modf.x2; var y1 = modf.y1; var y2 = modf.y2; var xt1 = Math.round((x1-x0)*xs + dx*xs*0.5); var xt2 = Math.round((x2-x0)*xs + dx*xs*0.5); var yoffs = myD.line[1].yoffs; var yf = myD.line[1].yf; var yt1 = Math.round((y1-y0+yoffs)*yf*ys); var yt2 = Math.round((y2-y0+yoffs)*yf*ys); var wd = xt2 - xt1; var hi = yt2 - yt1; clog("iplot.f" + h + " c1,c2="+c1.toString()+","+c2.toString()+" x1,y1="+x1+","+y1+" x2,y2="+x2+","+y2+" xt1,yt1="+xt1+","+yt1+" xt2,yt2="+xt2+","+yt2); var grd = context.createLinearGradient(0, 1.2 * hi, 0, 0); grd.addColorStop(0, c1); grd.addColorStop(1, c2); context.fillStyle = grd; context.fillRect(xt1 + myD.DX, myD.DH - yt1 + myD.DY, wd, -hi); context.fillStyle = "black"; } // Zeichne die Legende function drawExpl(context, dnr, myD, ex, ey, wd, hi) { if (!myD.expl.on) return; var ra = myD.expl.refs.split(';'); var x = ex + 40; var y = ey + 8; var dy = 11; for (var i=0; i=0) { var bn = parseInt(ip.substr(7)); if (!myD.bars[bn].on) hi -= dy; } if (ip.indexOf("iplot.l")>=0) { var ln = parseInt(ip.substr(7)); if (!myD.line[ln].on) hi -= dy; } if (ip.indexOf("iplot.i")>=0) { var ln = parseInt(ip.substr(7)); if (!myD.areaint || !myD.line[ln].on || !myD.line[ln].area) hi -= dy; } } context.fillStyle = myD.expl.bg; context.fillRect(ex, ey, wd, hi); for (var i=0; i=0) { var bn = parseInt(ip.substr(7)); if (!myD.bars[bn].on) continue; var c = myD.bars[bn].col; context.fillStyle = c; context.fillRect(x-35, y-5, 25, 5); } if (ip == "iplot.xx") continue; var s = altTxt(myD.small, ref(dij)); var p = s.indexOf('\n'); var txt = (p < 0) ? s : s.substr(0, p); if (ip && ip.indexOf("iplot.l")>=0) { var ln = parseInt(ip.substr(7)); if (!myD.line[ln].on) continue; var c = getModcCol(context, myD.line[ln].modc, myD.line[ln].col, 1); var ty = myD.line[ln].type; var wi = myD.line[ln].width; var sym = setupLine(context, ty, myD.line[ln], c); if (sym) { context.fillText(sym + sym + sym, x-22, y+1); } else { if (ty==9) { context.fillText(ref(dij, 5, 0), x-22, y+1); } else if (ty>1) { context.setLineDashOffset = 0; } context.beginPath(); context.moveTo(x-35, y-3); context.lineTo(x-10, y-3); context.stroke(); } } if (ip && ip.indexOf("iplot.i")>=0) { var ln = parseInt(ip.substr(7)); if (!myD.areaint || !myD.line[ln].on || !myD.line[ln].area) continue; var c = getModcCol(context, myD.line[ln].modc, myD.line[ln].area.col); var ty = myD.line[ln].type; var t1 = myD.line[ln].area.val.toString(); var prfont = context.font; context.font = '10pt Arial'; context.textAlign = "left"; context.setLineDash([]); context.strokeStyle = c; context.lineWidth = 0.5; context.strokeText(t1, x-30, y+1); context.font = prfont; } if (c=="white" || c=="#000000") c = "black"; context.textAlign = "left"; context.fillStyle = c; context.fillText(txt, x, y); y += dy; if (p >= 0) { // zweite Textzeile context.fillText(s.substr(p+1), x, y); y += dy; } } } // Gibt das Jahr bis zu dem Daten vorliegen zurück function getYearBis(dnr) { var myD = myDiag[dnr]; if (!myD || !myD.iplotref || !myD.bis) return ""; return myD.bis; } // Setzt alle Checkbox-Zustände auf "val". function setAllCheckboxStates(elems, name, val) { for (var i=0; i