5 if ( typeof define ===
"function" && define.amd ) {
6 define( [
'JSRootPainter',
'd3'], factory );
7 }
else if (typeof exports ===
'object' && typeof module !==
'undefined') {
8 factory(require(
"./JSRootCore.js"), require(
"d3"));
10 if (typeof d3 !=
'object')
11 throw new Error(
'This extension requires d3.js',
'JSRootPainter.v7hist.js');
12 if (typeof JSROOT ==
'undefined')
13 throw new Error(
'JSROOT is not defined',
'JSRootPainter.v7hist.js');
14 if (typeof JSROOT.Painter !=
'object')
15 throw new Error(
'JSROOT.Painter not defined',
'JSRootPainter.v7hist.js');
18 } (
function(JSROOT, d3) {
22 JSROOT.sources.push(
"v7more");
27 var text = this.GetObject(),
28 pp = this.pad_painter(),
30 h = this.pad_height(),
32 p = pp.GetCoordinate(text.fPos),
33 text_size = this.v7EvalAttr(
"text_size", 12),
34 text_angle = -1 * this.v7EvalAttr(
"text_angle", 0),
35 text_align = this.v7EvalAttr(
"text_align", 22),
36 text_color = this.v7EvalColor(
"text_color",
"black"),
37 text_font = this.v7EvalAttr(
"text_font", 41);
39 this.CreateG(use_frame);
41 var arg = { align: text_align, x: p.x, y: p.y, text: text.fText, rotate: text_angle, color: text_color, latex: 1 };
47 this.StartTextDrawing(text_font, text_size);
51 this.FinishTextDrawing();
58 var line = this.GetObject(),
59 pp = this.pad_painter(),
60 p1 = pp.GetCoordinate(line.fP1),
61 p2 = pp.GetCoordinate(line.fP2),
62 line_width = this.v7EvalAttr(
"line_width", 1),
63 line_style = this.v7EvalAttr(
"line_style", 1),
64 line_color = this.v7EvalColor(
"line_color",
"black");
74 .style(
"stroke", line_color)
75 .attr(
"stroke-width", line_width)
77 .style(
"stroke-dasharray", JSROOT.Painter.root_line_styles[line_style]);
84 var box = this.GetObject(),
85 pp = this.pad_painter(),
86 p1 = pp.GetCoordinate(box.fP1),
87 p2 = pp.GetCoordinate(box.fP2),
88 line_width = this.v7EvalAttr(
"box_border_width", 1),
89 line_style = this.v7EvalAttr(
"box_border_style", 1),
90 line_color = this.v7EvalColor(
"box_border_color",
"black"),
91 fill_color = this.v7EvalColor(
"box_fill_color",
"white"),
92 fill_style = this.v7EvalAttr(
"box_fill_style", 1),
93 round_width = this.v7EvalAttr(
"box_round_width", 0),
94 round_height = this.v7EvalAttr(
"box_round_height", 0);
98 if (fill_style == 0) fill_color =
"none";
103 .attr(
"width", p2.x-p1.x)
105 .attr(
"height", p1.y-p2.y)
106 .attr(
"rx", round_width)
107 .attr(
"ry", round_height)
108 .style(
"stroke", line_color)
109 .attr(
"stroke-width", line_width)
110 .attr(
"fill", fill_color)
111 .style(
"stroke-dasharray", JSROOT.Painter.root_line_styles[line_style]);
116 function drawMarker() {
117 var marker = this.GetObject(),
118 pp = this.pad_painter(),
119 p = pp.GetCoordinate(marker.fP),
120 marker_size = this.v7EvalAttr(
"marker_size", 1),
121 marker_style = this.v7EvalAttr(
"marker_style", 1),
122 marker_color = this.v7EvalColor(
"marker_color",
"black"),
123 att =
new JSROOT.TAttMarkerHandler({ style: marker_style, color: marker_color, size: marker_size }),
124 path = att.create(p.x, p.y);
129 this.draw_g.append(
"svg:path")
136 function drawLegend(arg) {
138 var legend = this.GetObject(),
139 pp = this.pad_painter(),
140 p1 = pp.GetCoordinate(legend.fP1),
141 p2 = pp.GetCoordinate(legend.fP2),
142 line_width = this.v7EvalAttr(
"box_border_width", 1),
143 line_style = this.v7EvalAttr(
"box_border_style", 1),
144 line_color = this.v7EvalColor(
"box_border_color",
"black"),
145 fill_color = this.v7EvalColor(
"box_fill_color",
"white"),
146 fill_style = this.v7EvalAttr(
"box_fill_style", 1),
147 text_size = this.v7EvalAttr(
"title_size", 20),
148 text_angle = -1 * this.v7EvalAttr(
"title_angle", 0),
149 text_align = this.v7EvalAttr(
"title_align", 22),
150 text_color = this.v7EvalColor(
"title_color",
"black"),
151 text_font = this.v7EvalAttr(
"title_font", 41);
162 if (fill_style == 0) fill_color =
"none";
174 .attr(
"width", p2.x-p1.x)
176 .attr(
"height", p1.y-p2.y)
177 .style(
"stroke", line_color)
178 .attr(
"stroke-width", line_width)
179 .attr(
"fill", fill_color)
180 .style(
"stroke-dasharray", JSROOT.Painter.root_line_styles[line_style]);
182 var nlines = legend.fEntries.length;
184 if (legend.fTitle) nlines++;
186 var arg = { align: text_align, rotate: text_angle, color: text_color, latex: 1 };
188 this.StartTextDrawing(text_font, text_size);
192 this.DrawText(JSROOT.extend({ x: p1.x + (p2.x-p1.x)/2, y: p2.y - 0.5*(p2.y-p1.y)/(nlines+1), text: legend.fTitle }, arg));
196 for (var i=0; i<legend.fEntries.length; ++i) {
197 var entry = legend.fEntries[i],
198 ypos = p2.y - (cnt+0.5)*(p2.y-p1.y)/(nlines+1);
199 this.DrawText(JSROOT.extend({ x: p1.x + (p2.x-p1.x)/4, y: ypos, text: entry.fLabel }, arg));
201 var objp = this.FindPainterFor(entry.fDrawable.fIO);
203 if (objp && objp.lineatt)
206 .attr(
"x1", p1.x + (p2.x-p1.x)*0.5)
208 .attr(
"x2", p1.x + (p2.x-p1.x)*0.8)
210 .call(objp.lineatt.func);
215 this.FinishTextDrawing();
224 JSROOT.v7.drawText = drawText;
225 JSROOT.v7.drawLine = drawLine;
226 JSROOT.v7.drawBox = drawBox;
227 JSROOT.v7.drawMarker = drawMarker;
228 JSROOT.v7.drawLegend = drawLegend;