Skip to content

Commit 980cebd

Browse files
committed
Merge pull request #390 from plotly/ternary
Ternary phase diagrams
2 parents 0b5b003 + fce4d68 commit 980cebd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+5408
-1479
lines changed

.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"rules": {
1010
"no-trailing-spaces": [2],
11-
"no-multiple-empty-lines": [2, {"max": 2, "maxEOF": 1}],
11+
"no-multiple-empty-lines": [2, {"max": 2, "maxEOF": 0}],
1212
"eol-last": [2],
1313
"linebreak-style": [2, "unix"],
1414
"indent": [2, 4, {"SwitchCase": 1}],

lib/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ Core.register([
2929
require('./mesh3d'),
3030
require('./scattergeo'),
3131
require('./choropleth'),
32-
require('./scattergl')
32+
require('./scattergl'),
33+
require('./scatterternary')
3334
]);
3435

3536
module.exports = Core;

lib/scatterternary.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Copyright 2012-2016, 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+
module.exports = require('../src/traces/scatterternary');

src/components/annotations/index.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
var Plotly = require('../../plotly');
1313
var d3 = require('d3');
1414
var isNumeric = require('fast-isnumeric');
15+
var setCursor = require('../../lib/setcursor');
16+
var dragElement = require('../dragelement');
1517

1618
var annotations = module.exports = {};
1719

@@ -583,7 +585,7 @@ annotations.draw = function(gd, index, opt, value) {
583585
annx0,
584586
anny0;
585587

586-
Plotly.Fx.dragElement({
588+
dragElement.init({
587589
element: arrowdrag.node(),
588590
prepFn: function() {
589591
annx0 = Number(ann.attr('x'));
@@ -641,7 +643,7 @@ annotations.draw = function(gd, index, opt, value) {
641643
y0,
642644
update;
643645

644-
Plotly.Fx.dragElement({
646+
dragElement.init({
645647
element: ann.node(),
646648
prepFn: function() {
647649
x0 = Number(ann.attr('x'));
@@ -662,7 +664,7 @@ annotations.draw = function(gd, index, opt, value) {
662664
var widthFraction = options._xsize / gs.w,
663665
xLeft = options.x + options._xshift / gs.w - widthFraction / 2;
664666

665-
update[annbase + '.x'] = Plotly.Fx.dragAlign(xLeft + dx / gs.w,
667+
update[annbase + '.x'] = dragElement.align(xLeft + dx / gs.w,
666668
widthFraction, 0, 1, options.xanchor);
667669
}
668670

@@ -671,11 +673,11 @@ annotations.draw = function(gd, index, opt, value) {
671673
var heightFraction = options._ysize / gs.h,
672674
yBottom = options.y - options._yshift / gs.h - heightFraction / 2;
673675

674-
update[annbase + '.y'] = Plotly.Fx.dragAlign(yBottom - dy / gs.h,
676+
update[annbase + '.y'] = dragElement.align(yBottom - dy / gs.h,
675677
heightFraction, 0, 1, options.yanchor);
676678
}
677679
if(!xa || !ya) {
678-
csr = Plotly.Fx.dragCursors(
680+
csr = dragElement.cursor(
679681
xa ? 0.5 : update[annbase + '.x'],
680682
ya ? 0.5 : update[annbase + '.y'],
681683
options.xanchor, options.yanchor
@@ -694,10 +696,10 @@ annotations.draw = function(gd, index, opt, value) {
694696
x1 + ',' + y1 + ')'
695697
});
696698

697-
Plotly.Fx.setCursor(ann, csr);
699+
setCursor(ann, csr);
698700
},
699701
doneFn: function(dragged) {
700-
Plotly.Fx.setCursor(ann);
702+
setCursor(ann);
701703
if(dragged) {
702704
Plotly.relayout(gd, update);
703705
var notesBox = document.querySelector('.js-notes-box-panel');

src/components/color/attributes.js

+6
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,9 @@ exports.defaultLine = '#444';
2828
exports.lightLine = '#eee';
2929

3030
exports.background = '#fff';
31+
32+
// with axis.color and Color.interp we aren't using lightLine
33+
// itself anymore, instead interpolating between axis.color
34+
// and the background color using tinycolor.mix. lightFraction
35+
// gives back exactly lightLine if the other colors are defaults.
36+
exports.lightFraction = 100 * (0xe - 0x4) / (0xf - 0x4);

src/components/colorbar/defaults.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
var Lib = require('../../lib');
1313
var handleTickValueDefaults = require('../../plots/cartesian/tick_value_defaults');
14-
var handleTickDefaults = require('../../plots/cartesian/tick_defaults');
14+
var handleTickMarkDefaults = require('../../plots/cartesian/tick_mark_defaults');
15+
var handleTickLabelDefaults = require('../../plots/cartesian/tick_label_defaults');
1516

1617
var attributes = require('./attributes');
1718

@@ -52,7 +53,10 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) {
5253

5354
handleTickValueDefaults(colorbarIn, colorbarOut, coerce, 'linear');
5455

55-
handleTickDefaults(colorbarIn, colorbarOut, coerce, 'linear',
56+
handleTickLabelDefaults(colorbarIn, colorbarOut, coerce, 'linear',
57+
{outerTicks: false, font: layout.font, noHover: true});
58+
59+
handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear',
5660
{outerTicks: false, font: layout.font, noHover: true});
5761

5862
coerce('title');

0 commit comments

Comments
 (0)