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

Function plot

src/traces/bar/plot.js:91–529  ·  view source on GitHub ↗
(gd, plotinfo, cdModule, traceLayer, opts, makeOnCompleteCallback)

Source from the content-addressed store, hash-verified

89}
90
91function plot(gd, plotinfo, cdModule, traceLayer, opts, makeOnCompleteCallback) {
92 var xa = plotinfo.xaxis;
93 var ya = plotinfo.yaxis;
94 var fullLayout = gd._fullLayout;
95 var isStatic = gd._context.staticPlot;
96
97 if (!opts) {
98 opts = {
99 mode: fullLayout.barmode,
100 norm: fullLayout.barmode,
101 gap: fullLayout.bargap,
102 groupgap: fullLayout.bargroupgap
103 };
104
105 // don't clear bar when this is called from waterfall or funnel
106 clearMinTextSize('bar', fullLayout);
107 }
108
109 var bartraces = Lib.makeTraceGroups(traceLayer, cdModule, 'trace bars').each(function (cd) {
110 var plotGroup = d3.select(this);
111 var trace = cd[0].trace;
112 var t = cd[0].t;
113 var isWaterfall = trace.type === 'waterfall';
114 var isFunnel = trace.type === 'funnel';
115 var isHistogram = trace.type === 'histogram';
116 var isBar = trace.type === 'bar';
117 var shouldDisplayZeros = isBar || isFunnel;
118 var adjustPixel = 0;
119 if (isWaterfall && trace.connector.visible && trace.connector.mode === 'between') {
120 adjustPixel = trace.connector.line.width / 2;
121 }
122
123 var isHorizontal = trace.orientation === 'h';
124 var withTransition = hasTransition(opts);
125
126 var pointGroup = Lib.ensureSingle(plotGroup, 'g', 'points');
127
128 var keyFunc = getKeyFunc(trace);
129 var bars = pointGroup.selectAll('g.point').data(Lib.identity, keyFunc);
130
131 bars.enter().append('g').classed('point', true);
132
133 bars.exit().remove();
134
135 bars.each(function (di, i) {
136 var bar = d3.select(this);
137
138 // now display the bar
139 // clipped xf/yf (2nd arg true): non-positive
140 // log values go off-screen by plotwidth
141 // so you see them continue if you drag the plot
142 var xy = getXY(di, xa, ya, isHorizontal);
143
144 var x0 = xy[0][0];
145 var x1 = xy[0][1];
146 var y0 = xy[1][0];
147 var y1 = xy[1][1];
148

Callers

nothing calls this directly

Calls 9

clearMinTextSizeFunction · 0.85
dirSignFunction · 0.85
calcCornerRadiusFunction · 0.85
appendBarTextFunction · 0.85
hasTransitionFunction · 0.70
getKeyFuncFunction · 0.70
getXYFunction · 0.70
signFunction · 0.70
transitionFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…