MCPcopy Index your code
hub / github.com/plotly/plotly.js / styleLines

Function styleLines

src/components/legend/style.js:86–166  ·  view source on GitHub ↗
(d)

Source from the content-addressed store, hash-verified

84 .each(styleOHLC);
85
86 function styleLines(d) {
87 var styleGuide = getStyleGuide(d);
88 var showFill = styleGuide.showFill;
89 var showLine = styleGuide.showLine;
90 var showGradientLine = styleGuide.showGradientLine;
91 var showGradientFill = styleGuide.showGradientFill;
92 var anyFill = styleGuide.anyFill;
93 var anyLine = styleGuide.anyLine;
94
95 var d0 = d[0];
96 var trace = d0.trace;
97 var dMod, tMod;
98
99 var cOpts = extractOpts(trace);
100 var colorscale = cOpts.colorscale;
101 var reversescale = cOpts.reversescale;
102
103 var fillStyle = function (s) {
104 if (s.size()) {
105 if (showFill) {
106 Drawing.fillGroupStyle(s, gd, true);
107 } else {
108 var gradientID = 'legendfill-' + trace.uid;
109 Drawing.gradient(s, gd, gradientID, getGradientDirection(reversescale), colorscale, 'fill');
110 }
111 }
112 };
113
114 var lineGradient = function (s) {
115 if (s.size()) {
116 var gradientID = 'legendline-' + trace.uid;
117 Drawing.lineGroupStyle(s);
118 Drawing.gradient(s, gd, gradientID, getGradientDirection(reversescale), colorscale, 'stroke');
119 }
120 };
121
122 // with fill and no markers or text, move the line and fill up a bit
123 // so it's more centered
124
125 var pathStart =
126 subTypes.hasMarkers(trace) || !anyFill
127 ? 'M5,0'
128 : // with a line leave it slightly below center, to leave room for the
129 // line thickness and because the line is usually more prominent
130 anyLine
131 ? 'M5,-2'
132 : 'M5,-3';
133
134 var this3 = d3.select(this);
135
136 var fill = this3
137 .select('.legendfill')
138 .selectAll('path')
139 .data(showFill || showGradientFill ? [d] : []);
140 fill.enter().append('path').classed('js-fill', true);
141 fill.exit().remove();
142 fill.attr('d', pathStart + 'h' + itemWidth + 'v6h-' + itemWidth + 'z').call(fillStyle);
143

Callers

nothing calls this directly

Calls 3

getStyleGuideFunction · 0.85
extractOptsFunction · 0.85
boundLineWidthFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…