Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit d1dfdaf

Browse files
committed
pr comments addressed
1 parent 2d70094 commit d1dfdaf

File tree

6 files changed

+12
-59
lines changed

6 files changed

+12
-59
lines changed

example/src/Bar.purs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,8 @@ import Control.Monad.Eff.Random (RANDOM, random)
1010
import DOM (DOM)
1111
import DOM.Node.Types (ElementId(..))
1212
import Data.Array as Arr
13-
import Data.Foreign (toForeign)
1413
import Data.Maybe (Maybe(..))
15-
import Data.Newtype (wrap)
16-
import Data.Symbol (SProxy(..))
1714
import Data.Traversable as F
18-
import Data.Tuple (Tuple(..))
19-
import Data.Variant as V
2015
import Debug.Trace as DT
2116
import ECharts.Chart as EC
2217
import ECharts.Commands as E

example/src/Pie.purs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import Prelude
44

55
import Control.Monad.Eff (Eff)
66
import Control.Monad.Eff.Exception (EXCEPTION)
7-
import Data.Foreign (toForeign)
87
import Data.Maybe (Maybe(..))
98
import Data.Symbol (SProxy(..))
10-
import Data.StrMap as SM
119
import Data.Variant as V
1210
import Debug.Trace as DT
1311
import DOM (DOM)

example/src/Scatter.purs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@ import Prelude
55
import Control.Monad.Eff (Eff)
66
import Control.Monad.Eff.Exception (EXCEPTION)
77
import Control.Monad.Eff.Random (RANDOM)
8-
98
import Data.Array (zipWith)
109
import Data.Maybe (Maybe(..), maybe)
1110
import Data.NonEmpty as NE
1211
import Data.Tuple (Tuple(..), uncurry)
13-
1412
import Debug.Trace as DT
15-
1613
import DOM (DOM)
1714
import DOM.Node.Types (ElementId(..))
18-
1915
import ECharts.Chart as EC
2016
import ECharts.Theme as ETheme
2117
import ECharts.Types as ET
@@ -24,7 +20,6 @@ import ECharts.Commands as E
2420
import ECharts.Monad (DSL)
2521
import Math (cos, sin, (%))
2622
import Utils as U
27-
import Unsafe.Coerce (unsafeCoerce)
2823

2924
genSinData e. Eff (random RANDOM|e) (Array ET.Item)
3025
genSinData = do

src/ECharts/Chart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var echarts = require("echarts");
33
exports.initImpl = function(theme) {
44
return function(el) {
55
return function() {
6-
return echarts.init(el,theme);
6+
return echarts.init(el, theme);
77
};
88
};
99
};

src/ECharts/Event.js

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -83,41 +83,20 @@ exports.on_ = function(chart) {
8383
return function(callback) {
8484
return function() {
8585
return chart.on(eName, function(e) {
86-
var modifiedE = eName === "brush" ? addAll(this.getOption(), e) : e;
87-
callback(modifiedE)();
86+
if (eName === "brush") {
87+
addAll(this.getOption(), e);
88+
}
89+
callback(e)();
8890
});
8991
};
9092
};
9193
};
9294
};
9395

94-
exports.dispatchAction_ = function(maybeKeys) {
95-
return function(maybe) {
96-
return function(rawAction) {
97-
return function(chart) {
98-
return function() {
99-
var keys = Object.keys(rawAction),
100-
i, key, value, keysArr,
101-
action = {};
102-
for (i = 0; i < keys.length; i++) {
103-
key = keys[i];
104-
if (typeof maybeKeys[rawAction.type] === "undefined") {
105-
keysArr = [];
106-
} else {
107-
keysArr = maybeKeys[rawAction.type];
108-
}
109-
if (keysArr.indexOf(key) == -1) {
110-
value = rawAction[key];
111-
} else {
112-
value = maybe(undefined)(function(x) {return x;})(rawAction[key]);
113-
}
114-
if (typeof value !== "undefined") {
115-
action[key] = value;
116-
}
117-
}
118-
chart.dispatchAction(action);
119-
};
120-
};
96+
exports.dispatchAction_ = function(action) {
97+
return function(chart) {
98+
return function() {
99+
return chart.dispatchAction(action);
121100
};
122101
};
123102
}

src/ECharts/Event.purs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ import Control.Monad.Except (runExcept)
88
import Data.Foldable (for_)
99
import Data.Foreign (Foreign, readString)
1010
import Data.Foreign.Index (readProp)
11-
import Data.Maybe as M
1211
import Data.List as L
1312
import Data.Record.Unsafe as R
14-
import Data.StrMap as SM
1513
import Data.Tuple (Tuple(..), fst, snd)
1614
import Data.Variant.Internal (RLProxy(..), variantTags, class VariantTags)
1715
import ECharts.Types (EChartsEvent, EChartsEventR, Chart, ECHARTS)
@@ -43,10 +41,8 @@ listenAll chart cb = liftEff $
4341
toEChartsEvent = unsafeCoerce
4442

4543
foreign import dispatchAction_
46-
e a b action
47-
. SM.StrMap (Array String) -- mapping from action type to keys that are maybe's
48-
( b (a b) M.Maybe a b ) -- maybe
49-
action
44+
e action
45+
. action
5046
Chart
5147
Eff ( echarts ECHARTS |e ) Unit
5248

@@ -57,18 +53,8 @@ dispatch
5753
Chart
5854
m Unit
5955
dispatch vaction chart =
60-
liftEff $ dispatchAction_ strmapConfig M.maybe action chart
56+
liftEff $ dispatchAction_ action chart
6157
where
62-
strmapConfig = SM.fromFoldable
63-
[ Tuple "highlight" ["name", "dataIndex"]
64-
, Tuple "downplay" ["name", "dataIndex"]
65-
, Tuple "mapSelect" ["name", "dataIndex"]
66-
, Tuple "mapUnSelect" ["name", "dataIndex"]
67-
, Tuple "mapToggleSelect" ["name", "dataIndex"]
68-
, Tuple "focusNodeAdjacency" ["seriesId", "seriesIndex", "seriesName"]
69-
, Tuple "unfocusNodeAdjacency" ["seriesId", "seriesIndex", "seriesName"]
70-
]
71-
7258
variantPair Tuple String {}
7359
variantPair = unsafeCoerce vaction
7460

0 commit comments

Comments
 (0)