@@ -12,7 +12,7 @@ const version_id = 'dev',
1212
1313/** @summary version date
1414 * @desc Release date in format day/month/year like '14/04/2022' */
15- version_date = '26 /11/2024',
15+ version_date = '27 /11/2024',
1616
1717/** @summary version id and date
1818 * @desc Produced by concatenation of {@link version_id} and {@link version_date}
@@ -152479,12 +152479,13 @@ class TGraphPolargramPainter extends ObjectPainter {
152479152479 /** @summary Create painter
152480152480 * @param {object|string} dom - DOM element for drawing or element id
152481152481 * @param {object} polargram - object to draw */
152482- constructor(dom, polargram) {
152483- super(dom, polargram);
152482+ constructor(dom, polargram, opt ) {
152483+ super(dom, polargram, opt );
152484152484 this.$polargram = true; // indicate that this is polargram
152485152485 this.zoom_rmin = this.zoom_rmax = 0;
152486152486 this.t0 = 0;
152487152487 this.mult = 1;
152488+ this.decodeOptions(opt);
152488152489 }
152489152490
152490152491 /** @summary Returns true if fixed coordinates are configured */
@@ -152493,6 +152494,21 @@ class TGraphPolargramPainter extends ObjectPainter {
152493152494 return polar?.fRadian || polar?.fGrad || polar?.fDegree;
152494152495 }
152495152496
152497+ /** @summary Decode draw options */
152498+ decodeOptions(opt) {
152499+ const d = new DrawOptions(opt);
152500+
152501+ if (!this.options)
152502+ this.options = {};
152503+
152504+ Object.assign(this.options, {
152505+ NoLabels: d.check('N'),
152506+ OrthoLabels: d.check('O')
152507+ });
152508+
152509+ this.storeDrawOpt(opt);
152510+ }
152511+
152496152512 /** @summary Set angles range displayed by the polargram */
152497152513 setAnglesRange(tmin, tmax, set_obj) {
152498152514 if (tmin >= tmax)
@@ -152528,7 +152544,6 @@ class TGraphPolargramPainter extends ObjectPainter {
152528152544 format(radius) {
152529152545 if (radius === Math.round(radius)) return radius.toString();
152530152546 if (this.ndig > 10) return radius.toExponential(4);
152531-
152532152547 return radius.toFixed((this.ndig > 0) ? this.ndig : 0);
152533152548 }
152534152549
@@ -152562,10 +152577,10 @@ class TGraphPolargramPainter extends ObjectPainter {
152562152577 rect.szy = Math.round(0.5*h);
152563152578 }
152564152579
152565- rect.width = 2* rect.szx;
152566- rect.height = 2* rect.szy;
152567- rect.x = Math.round(w/ 2 - rect.szx);
152568- rect.y = Math.round(h/ 2 - rect.szy);
152580+ rect.width = 2 * rect.szx;
152581+ rect.height = 2 * rect.szy;
152582+ rect.x = Math.round(w / 2 - rect.szx);
152583+ rect.y = Math.round(h / 2 - rect.szy);
152569152584
152570152585 rect.hint_delta_x = rect.szx;
152571152586 rect.hint_delta_y = rect.szy;
@@ -152621,6 +152636,44 @@ class TGraphPolargramPainter extends ObjectPainter {
152621152636 }
152622152637 }
152623152638
152639+ /** @summary Draw polargram polar labels */
152640+ async drawPolarLabels(polar, nmajor) {
152641+ const fontsize = Math.round(polar.fPolarTextSize * this.szy * 2);
152642+
152643+ return this.startTextDrawingAsync(polar.fPolarLabelFont, fontsize)
152644+ .then(() => {
152645+ const lbls = (nmajor === 8) ? ['0', '#frac{#pi}{4}', '#frac{#pi}{2}', '#frac{3#pi}{4}', '#pi', '#frac{5#pi}{4}', '#frac{3#pi}{2}', '#frac{7#pi}{4}'] : ['0', '#frac{2#pi}{3}', '#frac{4#pi}{3}'],
152646+ aligns = [12, 11, 21, 31, 32, 33, 23, 13];
152647+
152648+ for (let n = 0; n < nmajor; ++n) {
152649+ const angle = -n*2*Math.PI/nmajor;
152650+ this.draw_g.append('svg:path')
152651+ .attr('d', `M0,0L${Math.round(this.szx*Math.cos(angle))},${Math.round(this.szy*Math.sin(angle))}`)
152652+ .call(this.lineatt.func);
152653+
152654+ let align = 12, rotate = 0;
152655+
152656+ if (this.options.OrthoLabels) {
152657+ rotate = -n/nmajor*360;
152658+ if ((rotate > -271) && (rotate < -91)) {
152659+ align = 32; rotate += 180;
152660+ }
152661+ } else {
152662+ const aindx = Math.round(16 - angle/Math.PI*4) % 8; // index in align table, here absolute angle is important
152663+ align = aligns[aindx];
152664+ }
152665+
152666+ this.drawText({ align, rotate,
152667+ x: Math.round((this.szx + fontsize)*Math.cos(angle)),
152668+ y: Math.round((this.szy + fontsize/this.szx*this.szy)*(Math.sin(angle))),
152669+ text: lbls[n],
152670+ color: this.getColor(polar.fPolarLabelColor), latex: 1 });
152671+ }
152672+
152673+ return this.finishTextDrawing();
152674+ });
152675+ }
152676+
152624152677 /** @summary Redraw polargram */
152625152678 async redraw() {
152626152679 if (!this.isMainPainter())
@@ -152654,8 +152707,7 @@ class TGraphPolargramPainter extends ObjectPainter {
152654152707
152655152708 this.setAnglesRange(polar.fRwtmin, polar.fRwtmax);
152656152709
152657- const ticks = this.r.ticks(5),
152658- fontsize = Math.round(polar.fPolarTextSize * this.szy * 2);
152710+ const ticks = this.r.ticks(5);
152659152711 let nminor = Math.floor((polar.fNdivRad % 10000) / 100),
152660152712 nmajor = polar.fNdivPol % 100;
152661152713 if (nmajor !== 3)
@@ -152683,7 +152735,7 @@ class TGraphPolargramPainter extends ObjectPainter {
152683152735 let exclude_last = false;
152684152736 const pointer_events = this.isBatchMode() ? null : 'visibleFill';
152685152737
152686- if ((ticks[ticks.length- 1] < polar.fRwrmax) && (this.zoom_rmin === this.zoom_rmax)) {
152738+ if ((ticks[ticks.length - 1] < polar.fRwrmax) && (this.zoom_rmin === this.zoom_rmax)) {
152687152739 ticks.push(polar.fRwrmax);
152688152740 exclude_last = true;
152689152741 }
@@ -152727,32 +152779,12 @@ class TGraphPolargramPainter extends ObjectPainter {
152727152779
152728152780 return this.finishTextDrawing();
152729152781 }).then(() => {
152730- return this.startTextDrawingAsync(polar.fPolarLabelFont, fontsize);
152731- }).then(() => {
152732- lbls = (nmajor === 8) ? ['0', '#frac{#pi}{4}', '#frac{#pi}{2}', '#frac{3#pi}{4}', '#pi', '#frac{5#pi}{4}', '#frac{3#pi}{2}', '#frac{7#pi}{4}'] : ['0', '#frac{2#pi}{3}', '#frac{4#pi}{3}'];
152733- const aligns = [12, 11, 21, 31, 32, 33, 23, 13];
152734-
152735- for (let n = 0; n < nmajor; ++n) {
152736- const angle = -n*2*Math.PI/nmajor;
152737- this.draw_g.append('svg:path')
152738- .attr('d', `M0,0L${Math.round(this.szx*Math.cos(angle))},${Math.round(this.szy*Math.sin(angle))}`)
152739- .call(this.lineatt.func);
152740-
152741- const aindx = Math.round(16 -angle/Math.PI*4) % 8; // index in align table, here absolute angle is important
152742-
152743- this.drawText({ align: aligns[aindx],
152744- x: Math.round((this.szx+fontsize)*Math.cos(angle)),
152745- y: Math.round((this.szy + fontsize/this.szx*this.szy)*(Math.sin(angle))),
152746- text: lbls[n],
152747- color: this.getColor(polar.fPolarLabelColor), latex: 1 });
152748- }
152749-
152750- return this.finishTextDrawing();
152782+ return this.options.NoLabels ? true : this.drawPolarLabels(polar, nmajor);
152751152783 }).then(() => {
152752152784 nminor = Math.floor((polar.fNdivPol % 10000) / 100);
152753152785
152754152786 if (nminor > 1) {
152755- for (let n = 0; n < nmajor* nminor; ++n) {
152787+ for (let n = 0; n < nmajor * nminor; ++n) {
152756152788 if (n % nminor === 0) continue;
152757152789 const angle = -n*2*Math.PI/nmajor/nminor;
152758152790 this.draw_g.append('svg:path')
@@ -152794,15 +152826,15 @@ class TGraphPolargramPainter extends ObjectPainter {
152794152826 }
152795152827
152796152828 /** @summary Draw TGraphPolargram */
152797- static async draw(dom, polargram /* , opt */ ) {
152829+ static async draw(dom, polargram, opt) {
152798152830 const main = getElementMainPainter(dom);
152799152831 if (main) {
152800152832 if (main.getObject() === polargram)
152801152833 return main;
152802152834 throw Error('Cannot superimpose TGraphPolargram with any other drawings');
152803152835 }
152804152836
152805- const painter = new TGraphPolargramPainter(dom, polargram);
152837+ const painter = new TGraphPolargramPainter(dom, polargram, opt );
152806152838 return ensureTCanvas(painter, false).then(() => {
152807152839 painter.setAsMainPainter();
152808152840 return painter.redraw();
@@ -152832,11 +152864,15 @@ class TGraphPolarPainter extends ObjectPainter {
152832152864 err: d.check('E'),
152833152865 fill: d.check('F'),
152834152866 line: d.check('L'),
152835- curve: d.check('C')
152867+ curve: d.check('C'),
152868+ radian: d.check('R'),
152869+ degree: d.check('D'),
152870+ grad: d.check('G'),
152871+ Axis: d.check('N') ? 'N' : ''
152836152872 });
152837152873
152838- if (d.check('A '))
152839- this._draw_axis = true ;
152874+ if (d.check('O '))
152875+ this.options.Axis += 'O' ;
152840152876
152841152877 this.storeDrawOpt(opt);
152842152878 }
@@ -152969,8 +153005,15 @@ class TGraphPolarPainter extends ObjectPainter {
152969153005
152970153006 /** @summary Create polargram object */
152971153007 createPolargram(gr) {
152972- if (!gr.fPolargram)
153008+ if (!gr.fPolargram) {
152973153009 gr.fPolargram = create$1('TGraphPolargram');
153010+ if (this.options.radian)
153011+ gr.fPolargram.fRadian = true;
153012+ else if (this.options.degree)
153013+ gr.fPolargram.fDegree = true;
153014+ else if (this.options.grad)
153015+ gr.fPolargram.fGrad = true;
153016+ }
152974153017
152975153018 let rmin = gr.fY[0] || 0, rmax = rmin;
152976153019 const has_err = gr.fEY?.length;
@@ -153124,7 +153167,7 @@ class TGraphPolarPainter extends ObjectPainter {
153124153167
153125153168 /** @summary Draw TGraphPolar */
153126153169 static async draw(dom, graph, opt) {
153127- const painter = new TGraphPolarPainter(dom, graph);
153170+ const painter = new TGraphPolarPainter(dom, graph, opt );
153128153171 painter.decodeOptions(opt);
153129153172
153130153173 const main = painter.getMainPainter();
@@ -153137,7 +153180,7 @@ class TGraphPolarPainter extends ObjectPainter {
153137153180 if (!main) {
153138153181 // indicate that axis defined by this graph
153139153182 painter._draw_axis = true;
153140- pr = TGraphPolargramPainter.draw(dom, painter.createPolargram(graph));
153183+ pr = TGraphPolargramPainter.draw(dom, painter.createPolargram(graph), painter.options.Axis );
153141153184 }
153142153185
153143153186 return pr.then(gram_painter => {
0 commit comments