-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathplot.js
More file actions
44 lines (31 loc) · 1.14 KB
/
plot.js
File metadata and controls
44 lines (31 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
var scatterPlot = require('../scatter/plot');
module.exports = function plot(ternary, data) {
var plotContainer = ternary.plotContainer;
// remove all nodes inside the scatter layer
plotContainer.select('.scatterlayer').selectAll('*').remove();
// mimic cartesian plotinfo
var plotinfo = {
x: function() { return ternary.xaxis; },
y: function() { return ternary.yaxis; },
plot: plotContainer
};
var calcdata = new Array(data.length),
fullCalcdata = ternary.graphDiv.calcdata;
for(var i = 0; i < fullCalcdata.length; i++) {
var j = data.indexOf(fullCalcdata[i][0].trace);
if(j === -1) continue;
calcdata[j] = fullCalcdata[i];
// while we're here and have references to both the Ternary object
// and fullData, connect the two (for use by hover)
data[j]._ternary = ternary;
}
scatterPlot(ternary.graphDiv, plotinfo, calcdata);
};