Skip to content

Commit 6f21697

Browse files
committed
adding multitrace latex mock; fixing multitrace drag bug
1 parent 5336725 commit 6f21697

File tree

2 files changed

+63
-27
lines changed

2 files changed

+63
-27
lines changed

src/traces/table/plot.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ module.exports = function plot(gd, calcdata) {
107107
var movedColumn = d3.select(this);
108108
var getter = function(dd) {return (d === dd ? d3.event.x : dd.x) + dd.columnWidth / 2;};
109109
d.x = Math.max(-c.overdrag, Math.min(d.calcdata.width + c.overdrag - d.columnWidth, d3.event.x));
110-
var newOrder = yColumn.data().sort(function(a, b) {return getter(a) - getter(b);});
110+
111+
var sortableColumns = [].concat.apply([], yColumn.map(function(g) {return g;}))
112+
.map(function(g) {return g.__data__})
113+
.filter(function(dd) {return dd.calcdata.key === d.calcdata.key});
114+
var newOrder = sortableColumns.sort(function(a, b) {return getter(a) - getter(b);});
111115
newOrder.forEach(function(dd, i) {
112116
dd.xIndex = i;
113117
dd.x = d === dd ? dd.x : dd.xScale(dd);
Lines changed: 58 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,71 @@
11
{
22
"layout": {
33
"width": 620,
4-
"height": 550,
5-
"title": "Half-Angle Formulas"
4+
"height": 560,
5+
"title": "Half and Double Angles"
66
},
77

8-
"data": [{
8+
"data": [
9+
{
910

10-
"type": "table",
11+
"type": "table",
1112

12-
"domain": {
13-
"x": [0, 1],
14-
"y": [0, 1]
15-
},
13+
"domain": {
14+
"x": [0, 1],
15+
"y": [0.5, 1]
16+
},
17+
18+
"columnwidth": [30, 200, 200],
19+
"columnorder": [0, 1, 2],
1620

17-
"columnwidth": [30, 200, 200],
18-
"columnorder": [0, 1, 2],
21+
"header": {
22+
"values": [["<b>#</b>"], ["Half-angle form"], ["Equivalent"]],
23+
"align": ["right", "center", "center"],
24+
"line": {"width": 0.0},
25+
"fill": {"color": ["dimgray", "grey"]},
26+
"font": {"family": "Arial", "size": 14, "color": "white"}
27+
},
1928

20-
"header": {
21-
"values": [["<b>#</b>"], ["Form"], ["Equivalent"]],
22-
"align": ["right", "center", "center"],
23-
"line": {"width": 0.0},
24-
"fill": {"color": ["dimgray", "grey"]},
25-
"font": {"family": "Arial", "size": 14, "color": "white"}
29+
"cells": {
30+
"values": [
31+
["1.", "2."],
32+
["$$\\cos^2\\theta=\\displaystyle\\frac{1+\\cos\\theta}{2}$$", "$$\\sin^2\\theta=\\displaystyle\\frac{1-\\cos\\theta}{2}$$"],
33+
["$$\\cos\\theta=\\pm\\sqrt{\\displaystyle\\frac{1+\\cos\\theta}{2}}$$", "$$\\sin\\theta=\\pm\\sqrt{\\displaystyle\\frac{1-\\cos\\theta}{2}}$$"]
34+
],
35+
"align": ["right", "center", "center"],
36+
"line": {"color": "grey", "width": 1},
37+
"font": {"family": "Arial", "size": 12, "color": ["black"]}
38+
}
2639
},
40+
{
41+
42+
"type": "table",
43+
44+
"domain": {
45+
"x": [0.1, 0.9],
46+
"y": [0, 0.5]
47+
},
48+
49+
"columnwidth": [200, 300],
50+
"columnorder": [0, 1],
51+
52+
"header": {
53+
"values": [["Trig function"], ["Double-angle form"]],
54+
"align": ["right", "left"],
55+
"line": {"width": 0.0},
56+
"fill": {"color": ["dimgray", "grey"]},
57+
"font": {"family": "Arial", "size": 14, "color": "white"}
58+
},
2759

28-
"cells": {
29-
"values": [
30-
["1.", "2."],
31-
["$$\\cos^2\\theta=\\displaystyle\\frac{1+\\cos\\theta}{2}$$", "$$\\sin^2\\theta=\\displaystyle\\frac{1-\\cos\\theta}{2}$$"],
32-
["$$\\cos\\theta=\\pm\\sqrt{\\displaystyle\\frac{1+\\cos\\theta}{2}}$$", "$$\\sin\\theta=\\pm\\sqrt{\\displaystyle\\frac{1-\\cos\\theta}{2}}$$"]
33-
],
34-
"align": ["right", "center", "center"],
35-
"line": {"color": "grey", "width": 1},
36-
"font": {"family": "Arial", "size": 12, "color": ["black"]}
60+
"cells": {
61+
"values": [
62+
["<i>Sine</i>", "<i>Cosine</i>"],
63+
["$$\\sin2\\theta=2\\sin\\theta\\cos\\theta$$", "$$\\begin{eqnarray*}\\cos2\\theta&=&\\cos^2\\theta-\\sin^2\\theta\\\\&=&2\\cos^2\\theta-1\\\\&=&1-2\\sin^2\\theta\\end{eqnarray*}$$"]
64+
],
65+
"align": ["right", "left"],
66+
"line": {"color": "grey", "width": 1},
67+
"font": {"family": "Arial", "size": [12, 10], "color": ["black"]}
68+
}
3769
}
38-
}]
70+
]
3971
}

0 commit comments

Comments
 (0)