Events by cryogenian · Pull Request #45 · slamdata/purescript-echarts · GitHub
Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions example/src/Bar.purs
11 changes: 11 additions & 0 deletions example/src/Pie.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Exception (EXCEPTION)
import Data.Maybe (Maybe(..))
import Data.Symbol (SProxy(..))
import Data.Variant as V
import Debug.Trace as DT
import DOM (DOM)
import DOM.Node.Types (ElementId(..))
Expand Down Expand Up @@ -46,6 +48,7 @@ options = do
E.name "three"
E.pie do
E.name "Outer"
E.selectedMode ET.Multiple
E.radius $ ET.Radius { start: ET.Percent 40.0, end: ET.Percent 55.0 }
E.buildItems do
E.addItem do
Expand Down Expand Up @@ -83,3 +86,11 @@ chart = do
ch ← EC.init el
EC.setOption options ch
EE.listenAll ch DT.traceAnyA
EE.dispatch
(V.inj (SProxy ∷ SProxy "pieselected")
$ { seriesIndex: 1
, seriesName: "Outer"
, name: "seven"
, dataIndex: 4
})
ch
6 changes: 0 additions & 6 deletions example/src/Scatter.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,20 @@ import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Exception (EXCEPTION)
import Control.Monad.Eff.Random (RANDOM)

import Data.Array (zipWith)
import Data.Maybe (Maybe(..), maybe)
import Data.NonEmpty as NE
import Data.Tuple (Tuple(..), uncurry)

import Debug.Trace as DT

import DOM (DOM)
import DOM.Node.Types (ElementId(..))

import ECharts.Chart as EC
import ECharts.Theme as ETheme
import ECharts.Types as ET
import ECharts.Types.Phantom as ETP
import ECharts.Commands as E
import ECharts.Monad (DSL)

import Math (cos, sin, (%))

import Utils as U

genSinData ∷ ∀ e. Eff (random ∷ RANDOM|e) (Array ET.Item)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "purescript-echarts",
"private": true,
"devDependencies": {
"echarts": "3.5.4",
"echarts": "cryogenian/echarts#item-value-unshift-prebuild",
"express": "^4.14.0"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/ECharts/Chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exports.registerTheme = function(name) {
return function() {
// if value is not `undefined` and is not of type `string` then it must be `Foreign` for which we only permit plain Objects.
if (theme !== undefined && typeof theme !== 'string' && !isObject(theme)) {
throw new TypeError('Theme must be an Object')
throw new TypeError('Theme must be an Object');
}
echarts.registerTheme(name, theme);
};
Expand Down
3 changes: 2 additions & 1 deletion src/ECharts/Chart.purs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ initWithTheme
⇒ Theme
→ HTMLElement
→ m Chart
initWithTheme theme el = liftEff $ initImpl (either (toForeign <<< builtInThemeName) toForeign theme) el
initWithTheme theme el =
liftEff $ initImpl (either (toForeign <<< builtInThemeName) toForeign theme) el

foreign import registerTheme
∷ ∀ e. String
Expand Down
42 changes: 42 additions & 0 deletions src/ECharts/Commands.purs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ xAxisIndex a = set "xAxisIndex" $ toForeign a
yAxisIndex ∷ ∀ i. Int → DSL (yAxisIndex ∷ I|i)
yAxisIndex a = set "yAxisIndex" $ toForeign a

xAxisAllIndices ∷ ∀ i. DSL (xAxisIndex ∷ I|i)
xAxisAllIndices = set "xAxisIndex" $ toForeign "all"

yAxisAllIndices ∷ ∀ i. DSL (yAxisIndex ∷ I|i)
yAxisAllIndices = set "yAxisIndex" $ toForeign "all"

polarIndex ∷ ∀ i. Int → DSL (polarIndex ∷ I|i)
polarIndex a = set "polarIndex" $ toForeign a

Expand Down Expand Up @@ -430,33 +436,69 @@ textMiddle = set "textBaseline" $ toForeign "middle"
brush ∷ ∀ i. DSL TP.BrushI → DSL (brush ∷ I|i)
brush = set "brush" <<< buildObj

brushType ∷ ∀ i. DSL TP.BrushToolboxI → DSL (brushType ∷ I|i)
brushType a = set "type" $ buildArr a

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't "type" be "brushType"? and same beloved for some other cases

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's by design, too much type fields in js. But they all are different: e.g. type for brush, type for series, type for events etc. So, in built options this is just "type": ["blahblah"] but that blahblah may be used only in brush context.


brushToolbox ∷ ∀ i. DSL TP.BrushToolboxI → DSL (brushToolbox ∷ I|i)
brushToolbox a = set "toolbox" $ buildArr a

brushModeSingle ∷ ∀ i. DSL (brushMode ∷ I|i)
brushModeSingle = set "brushMode" $ toForeign "single"

brushIcons ∷ ∀ i. DSL TP.BFFieldI → DSL (bfIcon ∷ I|i)
brushIcons a = set "icon" $ buildObj a

brushTitle ∷ ∀ i. DSL TP.BFFieldI → DSL (bfTitle ∷ I|i)
brushTitle a = set "title" $ buildObj a

brushModeMultiple ∷ ∀ i. DSL (brushMode ∷ I|i)
brushModeMultiple = set "brushMode" $ toForeign "multiple"

rect ∷ ∀ i. DSL (tool ∷ I|i)
rect = set "" $ toForeign "rect"

setRect ∷ ∀ i. String → DSL (rect ∷ I|i)
setRect a = set "rect" $ toForeign a

polygon ∷ ∀ i. DSL (tool ∷ I|i)
polygon = set "" $ toForeign "polygon"

setPolygon ∷ ∀ i. String → DSL (polygon ∷ I|i)
setPolygon a = set "polygon" $ toForeign a

lineX ∷ ∀ i. DSL (tool ∷ I|i)
lineX = set "" $ toForeign "lineX"

setLineX ∷ ∀ i. String → DSL (lineX ∷ I|i)
setLineX a = set "lineX" $ toForeign a

lineY ∷ ∀ i. DSL (tool ∷ I|i)
lineY = set "" $ toForeign "lineY"

setLineY ∷ ∀ i. String → DSL (lineY ∷ I|i)
setLineY a = set "lineY" $ toForeign a

keep ∷ ∀ i. DSL (tool ∷ I|i)
keep = set "" $ toForeign "keep"

setKeep ∷ ∀ i. String → DSL (keep ∷ I|i)
setKeep a = set "keep" $ toForeign a

clear ∷ ∀ i. DSL (tool ∷ I|i)
clear = set "" $ toForeign "clear"

setClear ∷ ∀ i. String → DSL (clear ∷ I|i)
setClear a = set "clear" $ toForeign a

toolbox ∷ ∀ i. DSL TP.ToolboxI → DSL (toolbox ∷ I|i)
toolbox a = set "toolbox" $ buildObj a

feature ∷ ∀ i. DSL TP.FeatureI → DSL (feature ∷ I|i)
feature a = set "feature" $ buildObj a

brushFeature ∷ ∀ i. DSL TP.BrushFeatureI → DSL (brush ∷ I|i)
brushFeature a = set "brush" $ buildObj a

magicType ∷ ∀ i. DSL TP.MagicTypeI → DSL (magicType ∷ I|i)
magicType a = set "magicType" $ buildObj a

Expand Down
93 changes: 92 additions & 1 deletion src/ECharts/Event.js
Loading