Skip to content

Commit 949b311

Browse files
committed
add ScatterTernary.eventData method
- 🔪 is select method, reuse Scatter.select instead - using same event-data pipeline for hover and select revealed an inconsistency: hover data includes the raw input coords whereas selection data includes the scaled coords (as in calcdata).
1 parent b30fab4 commit 949b311

File tree

3 files changed

+39
-34
lines changed

3 files changed

+39
-34
lines changed
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Copyright 2012-2017, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
'use strict';
10+
11+
module.exports = function eventData(out, pt, trace, cd, pointNumber) {
12+
if(pt.xa) out.xaxis = pt.xa;
13+
if(pt.ya) out.yaxis = pt.ya;
14+
15+
if(cd[pointNumber]) {
16+
var cdi = cd[pointNumber];
17+
18+
// N.B. These are the scale coordinates !!!
19+
//
20+
// On master, hover events get the non-scaled coordinates
21+
// whereas selection events get the scaled version.
22+
// Note also that the hover labels show the scaled version.
23+
//
24+
// What about the 'raw' input coordinates?
25+
// Should we include them in parallel here or replace a/b/c with them?
26+
out.a = cdi.a;
27+
out.b = cdi.b;
28+
out.c = cdi.c;
29+
} else {
30+
// for fill-hover only
31+
out.a = pt.a;
32+
out.b = pt.b;
33+
out.c = pt.c;
34+
}
35+
36+
return out;
37+
};

src/traces/scatterternary/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ ScatterTernary.calc = require('./calc');
1717
ScatterTernary.plot = require('./plot');
1818
ScatterTernary.style = require('./style');
1919
ScatterTernary.hoverPoints = require('./hover');
20-
ScatterTernary.selectPoints = require('./select');
20+
ScatterTernary.selectPoints = require('../scatter/select');
21+
ScatterTernary.eventData = require('./event_data');
2122

2223
ScatterTernary.moduleType = 'trace';
2324
ScatterTernary.name = 'scatterternary';

src/traces/scatterternary/select.js

-33
This file was deleted.

0 commit comments

Comments
 (0)