├── .gitignore
├── .swift-version
├── .travis.yml
├── DemoOptions
├── AreaRainfallDatas.plist
├── BarOptions.swift
├── BeijingAQIDatas.plist
├── BoxplotOptions.swift
├── CandlestickOptions.swift
├── CandlestickSh2015.json
├── ConfidenceBandData.plist
├── FunnelOptions.swift
├── GaugeOptions.swift
├── GraphOptions.swift
├── HK.json
├── HeatmapOptions.swift
├── LineAirline.json
├── LineOptions.swift
├── LinesBus.json
├── MapOptions.swift
├── MixZoomOnValue.json
├── ParalledOptions.swift
├── PictorialBarOptions.swift
├── PieOptions.swift
├── RadarOptions.swift
├── SankeyOptions.swift
├── ScatterOptions.swift
├── ThemeRiverBasicData.plist
├── ThemeRiverOptions.swift
├── TreemapOptions.swift
├── USA.json
├── npmdepgraph.min10.json
├── province
│ ├── anhui.json
│ ├── aomen.json
│ ├── beijing.json
│ ├── chongqing.json
│ ├── fujian.json
│ ├── gansu.json
│ ├── guangdong.json
│ ├── guangxi.json
│ ├── guizhou.json
│ ├── hainan.json
│ ├── hebei.json
│ ├── heilongjiang.json
│ ├── henan.json
│ ├── hubei.json
│ ├── hunan.json
│ ├── jiangsu.json
│ ├── jiangxi.json
│ ├── jilin.json
│ ├── liaoning.json
│ ├── neimenggu.json
│ ├── ningxia.json
│ ├── qinghai.json
│ ├── shandong.json
│ ├── shanghai.json
│ ├── shanxi.json
│ ├── shanxi1.json
│ ├── sichuan.json
│ ├── tianjin.json
│ ├── xianggang.json
│ ├── xinjiang.json
│ ├── xizang.json
│ ├── yunnan.json
│ └── zhejiang.json
├── stock-DJI.json
└── webkit-dep.json
├── LICENSE
├── OSX_Example
├── AppDelegate.swift
├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Base.lproj
│ └── Main.storyboard
├── Info.plist
└── ViewController.swift
├── Podfile
├── README.md
├── SwiftyEcharts.podspec
├── SwiftyEcharts.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── xcshareddata
│ └── xcschemes
│ ├── SwiftyEcharts.xcscheme
│ ├── SwiftyEchartsTest_iOS.xcscheme
│ └── iOS_Example.xcscheme
├── SwiftyEcharts.xcworkspace
├── contents.xcworkspacedata
└── xcshareddata
│ └── SwiftyEcharts.xcscmblueprint
├── SwiftyEcharts
├── Info.plist
├── Models
│ ├── Axis
│ │ ├── AngleAxis.swift
│ │ ├── Axis.swift
│ │ ├── AxisLabel.swift
│ │ ├── AxisLine.swift
│ │ ├── AxisPointer.swift
│ │ ├── AxisTick.swift
│ │ ├── AxisType.swift
│ │ ├── ParallelAxis.swift
│ │ ├── RadiusAxis.swift
│ │ ├── SingleAxis.swift
│ │ ├── SplitArea.swift
│ │ └── SplitLine.swift
│ ├── Brush.swift
│ ├── Calendar.swift
│ ├── DataZoom
│ │ ├── DataZoom.swift
│ │ ├── InsideDataZoom.swift
│ │ └── SliderDataZoom.swift
│ ├── Geo.swift
│ ├── Graphic
│ │ ├── ArcGraphic.swift
│ │ ├── BezierCurveGraphic.swift
│ │ ├── CircleGraphic.swift
│ │ ├── Graphic.swift
│ │ ├── GraphicStyle.swift
│ │ ├── GraphicType.swift
│ │ ├── GroupGraphic.swift
│ │ ├── ImageGraphic.swift
│ │ ├── LineGraphic.swift
│ │ ├── PolygonGraphic.swift
│ │ ├── PolylineGraphic.swift
│ │ ├── RectGraphic.swift
│ │ ├── RingGraphic.swift
│ │ ├── SectorGraphic.swift
│ │ └── TextGraphic.swift
│ ├── Grid.swift
│ ├── Legend.swift
│ ├── Mark
│ │ ├── MarkArea.swift
│ │ ├── MarkData.swift
│ │ ├── MarkDataType.swift
│ │ ├── MarkLine.swift
│ │ └── MarkPoint.swift
│ ├── Option.swift
│ ├── Parallel.swift
│ ├── Polar.swift
│ ├── Protocol
│ │ ├── Borderable.swift
│ │ ├── Displayable.swift
│ │ ├── Emphasisable.swift
│ │ ├── Enumable.swift
│ │ ├── Formatted.swift
│ │ ├── Line.swift
│ │ ├── Opacitable.swift
│ │ ├── Shadowable.swift
│ │ └── Zable.swift
│ ├── Radar.swift
│ ├── Series
│ │ ├── BarSerie.swift
│ │ ├── BoxplotSerie.swift
│ │ ├── CandlestickSerie.swift
│ │ ├── CoordinateSystem.swift
│ │ ├── CustomSerie.swift
│ │ ├── EffectScatterSerie.swift
│ │ ├── FunnelSerie.swift
│ │ ├── GaugeSerie.swift
│ │ ├── GraphSerie.swift
│ │ ├── HeatmapSerie.swift
│ │ ├── LineSerie.swift
│ │ ├── LinesSerie.swift
│ │ ├── MapSerie.swift
│ │ ├── ParallelSerie.swift
│ │ ├── PictorialBarSerie.swift
│ │ ├── PieSerie.swift
│ │ ├── RadarSerie.swift
│ │ ├── SankeySerie.swift
│ │ ├── ScatterSerie.swift
│ │ ├── Serie.swift
│ │ ├── ThemeRiverSerie.swift
│ │ └── TreemapSerie.swift
│ ├── Timeline.swift
│ ├── Title.swift
│ ├── Toolbox.swift
│ ├── Tooltip.swift
│ ├── Type
│ │ ├── Animatable.swift
│ │ ├── AreaStyle.swift
│ │ ├── BoundaryGap.swift
│ │ ├── Font.swift
│ │ ├── ItemStyle.swift
│ │ ├── Label.swift
│ │ ├── LineStyle.swift
│ │ ├── Orient.swift
│ │ ├── Padding.swift
│ │ ├── Position.swift
│ │ ├── Roam.swift
│ │ ├── SelectedMode.swift
│ │ ├── Symbol.swift
│ │ ├── Target.swift
│ │ └── Text.swift
│ └── VisualMap
│ │ ├── ContinuousVisualMap.swift
│ │ ├── PiecewiseVisualMap.swift
│ │ └── VisualMap.swift
├── Resources
│ ├── echarts.html
│ └── js
│ │ ├── china.js
│ │ ├── dataTool.js
│ │ ├── echarts.min.js
│ │ └── world.js
├── SwiftyEcharts.h
├── Tools
│ ├── Echarts.swift
│ ├── Json
│ │ ├── JsCache.swift
│ │ ├── Jsonable.swift
│ │ ├── Mappable.swift
│ │ └── Mapper.swift
│ ├── Type
│ │ ├── Color.swift
│ │ ├── Function.swift
│ │ ├── FunctionOrOthers.swift
│ │ ├── LengthValue.swift
│ │ ├── OneOrMore.swift
│ │ ├── Pair.swift
│ │ └── Percent.swift
│ └── Utilities.swift
└── Views
│ ├── EchartsAction.swift
│ ├── EchartsEvent.swift
│ └── EchartsView.swift
├── SwiftyEchartsTest_iOS
├── AngleAxisSpec.swift
├── AnimatableSpec.swift
├── ArcGraphicSpec.swift
├── AreaStyleSpec.swift
├── AxisLabelSpec.swift
├── AxisLineSpec.swift
├── AxisPointerSpec.swift
├── AxisSpec.swift
├── AxisTickSpec.swift
├── AxisTypeSpec.swift
├── BarSerieSpec.swift
├── BezierCurveGraphicSpec.swift
├── BoundaryGapSpec.swift
├── BoxplotSerieSpec.swift
├── BrushSpec.swift
├── CalendarSpec.swift
├── CandlestickSerieSpec.swift
├── CircleGraphicSpec.swift
├── ColorSpec.swift
├── ContinuousVisualMapSpec.swift
├── CoordinateSystemSpec.swift
├── CustomSerieSpec.swift
├── DataZoomSpec.swift
├── DownplayActionSpec.swift
├── EchartsActionTypeSpec.swift
├── EchartsSpec.swift
├── EffectScatterSerieSpec.swift
├── EnumableSpec.swift
├── FontSpec.swift
├── FormatterSpec.swift
├── FunctionOrOthersSpec.swift
├── FunctionSpec.swift
├── FunnelSerieSpec.swift
├── GaugeSerieSpec.swift
├── GeoSepc.swift
├── GeoSpec.swift
├── GraphSerieSpec.swift
├── GraphicSpec.swift
├── GraphicStyleSpec.swift
├── GraphicTypeSpec.swift
├── GridSpec.swift
├── GroupGraphicSpec.swift
├── HeatmapSerieSpec.swift
├── HighlightActionSpec.swift
├── ImageGraphicSpec.swift
├── Info.plist
├── InsideDataZoomSpec.swift
├── ItemStyleSpec.swift
├── JsCacheSpec.swift
├── JsonableSpec.swift
├── LabelSpec.swift
├── LegendSpec.swift
├── LengthValueSpec.swift
├── LineGraphicSpec.swift
├── LineSerieSpec.swift
├── LineSpec.swift
├── LineStyleSpec.swift
├── LinesSerieSpec.swift
├── MapSerieSpec.swift
├── MappableSpec.swift
├── MapperSpec.swift
├── MarkAreaSpec.swift
├── MarkDataSpec.swift
├── MarkDataTypeSpec.swift
├── MarkLineSpec.swift
├── MarkPointSpec.swift
├── OneOrMoreSepc.swift
├── OpacitableSpec.swift
├── OrientSpec.swift
├── PaddingSpec.swift
├── PairSpec.swift
├── ParallelAxisSpec.swift
├── ParallelSerieSpec.swift
├── ParrallelSpec.swift
├── PercentSpec.swift
├── PictorialBarSerieSpec.swift
├── PieSerieSpec.swift
├── PiecewiseVisualMapSpec.swift
├── PolarSpec.swift
├── PolygonGraphicSpec.swift
├── PolylineGraphicSpec.swift
├── PositionSpec.swift
├── RadarSerieSpec.swift
├── RadarSpec.swift
├── RadiusAxisSpec.swift
├── RectGraphicSpec.swift
├── RingGraphicSpec.swift
├── RoamSpec.swift
├── SankeySerieSpec.swift
├── ScatterSerieSpec.swift
├── SectorGraphicSpec.swift
├── SelectedModeSpec.swift
├── SerieSpec.swift
├── ShadowStyleSpec.swift
├── SingleAxisSpec.swift
├── SliderDataZoomSpec.swift
├── SplitAreaSpec.swift
├── SplitLineSpec.swift
├── SymbolSpec.swift
├── TargetSpec.swift
├── TextGraphicSpec.swift
├── TextSpec.swift
├── ThemeRiverSerieSpec.swift
├── TimelineSpec.swift
├── TitleSpec.swift
├── ToolboxSpec.swift
├── TooltipSpec.swift
├── TreemapSerieSpec.swift
└── VisualMapSpec.swift
├── iOS_Example
├── AppDelegate.swift
├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
├── DemoControllers
│ ├── BarsController.swift
│ ├── BaseDemoController.swift
│ ├── BoxplotsControllers.swift
│ ├── CandlesticksController.swift
│ ├── FunnelController.swift
│ ├── GaugesController.swift
│ ├── GraphsController.swift
│ ├── HeatmapsController.swift
│ ├── LinesController.swift
│ ├── MapsController.swift
│ ├── PictorialBarsController.swift
│ ├── PiesController.swift
│ ├── RadarsController.swift
│ ├── SankeysController.swift
│ ├── ScattersController.swift
│ └── ThemeRiversController.swift
├── Info.plist
└── MenuController.swift
└── script.vim
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/macos,swift
3 |
4 | ### macOS ###
5 | *.DS_Store
6 | .AppleDouble
7 | .LSOverride
8 |
9 | # Icon must end with two \r
10 | Icon
11 |
12 |
13 | # Thumbnails
14 | ._*
15 |
16 | # Files that might appear in the root of a volume
17 | .DocumentRevisions-V100
18 | .fseventsd
19 | .Spotlight-V100
20 | .TemporaryItems
21 | .Trashes
22 | .VolumeIcon.icns
23 | .com.apple.timemachine.donotpresent
24 |
25 | # Directories potentially created on remote AFP share
26 | .AppleDB
27 | .AppleDesktop
28 | Network Trash Folder
29 | Temporary Items
30 | .apdisk
31 |
32 | ### Swift ###
33 | # Xcode
34 | #
35 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
36 |
37 | ## Build generated
38 | build/
39 | DerivedData/
40 |
41 | ## Various settings
42 | *.pbxuser
43 | !default.pbxuser
44 | *.mode1v3
45 | !default.mode1v3
46 | *.mode2v3
47 | !default.mode2v3
48 | *.perspectivev3
49 | !default.perspectivev3
50 | xcuserdata/
51 |
52 | ## Other
53 | *.moved-aside
54 | *.xccheckout
55 | *.xcscmblueprint
56 |
57 | ## Obj-C/Swift specific
58 | *.hmap
59 | *.ipa
60 | *.dSYM.zip
61 | *.dSYM
62 |
63 | ## Playgrounds
64 | timeline.xctimeline
65 | playground.xcworkspace
66 |
67 | # Swift Package Manager
68 | #
69 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
70 | # Packages/
71 | # Package.pins
72 | .build/
73 |
74 | # CocoaPods
75 | #
76 | # We recommend against adding the Pods directory to your .gitignore. However
77 | # you should judge for yourself, the pros and cons are mentioned at:
78 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
79 | #
80 | Pods/
81 | Podfile.lock
82 |
83 | # Carthage
84 | #
85 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
86 | # Carthage/Checkouts
87 |
88 | Carthage/Build
89 |
90 | # fastlane
91 | #
92 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
93 | # screenshots whenever they are needed.
94 | # For more information about the recommended setup visit:
95 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
96 |
97 | fastlane/report.xml
98 | fastlane/Preview.html
99 | fastlane/screenshots
100 | fastlane/test_output
101 |
102 | # End of https://www.gitignore.io/api/macos,swift
103 |
--------------------------------------------------------------------------------
/.swift-version:
--------------------------------------------------------------------------------
1 | 3.0
2 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: objective-c
2 | xcode_workspace: SwiftyEcharts.xcworkspace
3 | xcode_scheme: SwiftyEchartsTest_iOS
4 | osx_image: xcode8.2
5 | xcode_sdk: iphonesimulator10.1
6 |
7 | script: xcodebuild clean test -workspace SwiftyEcharts.xcworkspace -scheme SwiftyEchartsTest_iOS -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1'
8 |
9 | after_success: bash <(curl -s https://codecov.io/bash)
10 |
--------------------------------------------------------------------------------
/DemoOptions/ParalledOptions.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ParalledOptions.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto-Y on 16/01/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import SwiftyEcharts
10 |
11 | public final class ParalledOptions {
12 |
13 | // MARK: Parallel Aqi
14 | /// 地址: http://echarts.baidu.com/demo.html#parallel-aqi
15 | static func parallelAqiOption() -> Option {
16 | // TODO: 添加实现
17 | return Option(
18 | )
19 | }
20 |
21 | // MARK: Parallel Nutrients
22 | /// 地址: http://echarts.baidu.com/demo.html#parallel-nutrients
23 | static func parallelNutrientsOption() -> Option {
24 | // TODO: 添加实现
25 | return Option(
26 | )
27 | }
28 |
29 | // MARK: Scatter Matrix
30 | /// 地址: http://echarts.baidu.com/demo.html#scatter-matrix
31 | static func scatterMatrixOption() -> Option {
32 | // TODO: 添加实现
33 | return Option(
34 | )
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/DemoOptions/TreemapOptions.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TreemapOptions.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto-Y on 16/01/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import SwiftyEcharts
10 |
11 | public final class TreemapOptions {
12 |
13 | // MARK: Disk Usage
14 | /// 地址: http://echarts.baidu.com/demo.html#treemap-disk
15 | static func treemapDiskOption() -> Option {
16 | // TODO: 添加实现
17 | return Option(
18 | )
19 | }
20 |
21 | // MARK: ECharts 配置项查询分布
22 | /// 地址: http://echarts.baidu.com/demo.html#treemap-drill-down
23 | static func reemapDrillDownOption() -> Option {
24 | // TODO: 添加实现
25 | return Option(
26 | )
27 | }
28 |
29 | // MARK: How $3.7 Trillion is Spent
30 | /// 地址: http://echarts.baidu.com/demo.html#treemap-obama
31 | static func treemapObamaOption() -> Option {
32 | // TODO: 添加实现
33 | return Option(
34 | )
35 | }
36 |
37 | // MARK: Parallel Aqi
38 | /// 地址: http://echarts.baidu.com/demo.html#treemap-visual
39 | static func treemapVisualOption() -> Option {
40 | // TODO: 添加实现
41 | return Option(
42 | )
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/DemoOptions/province/aomen.json:
--------------------------------------------------------------------------------
1 | {"type":"FeatureCollection","features":[{"id":"820001","geometry":{"type":"Polygon","coordinates":["@@LADC^umZ@DONWEBDCLHBH@DFBBNA"],"encodeOffsets":[[116285,22746]]},"properties":{"cp":[113.5528956,22.20787],"name":"花地瑪堂區","childNum":1}},{"id":"820002","geometry":{"type":"Polygon","coordinates":["@@MK@CA@AAGDEB@NVFHE"],"encodeOffsets":[[116281,22734]]},"properties":{"cp":[113.5489608,22.1992075],"name":"花王堂區","childNum":1}},{"id":"820003","geometry":{"type":"Polygon","coordinates":["@@EGOB@DNLHE@C"],"encodeOffsets":[[116285,22729]]},"properties":{"cp":[113.5501828,22.19372083],"name":"望德堂區","childNum":1}},{"id":"820004","geometry":{"type":"Polygon","coordinates":["@@YIPEL@JFCBBFADHDBBFDHIJJEFDPCHHlY"],"encodeOffsets":[[116313,22707]]},"properties":{"cp":[113.5536475,22.18853944],"name":"大堂區","childNum":1}},{"id":"820005","geometry":{"type":"Polygon","coordinates":["@@JICGAECACGEBAAEDP^"],"encodeOffsets":[[116266,22728]]},"properties":{"cp":[113.5419278,22.18736806],"name":"風順堂區","childNum":1}},{"id":"820006","geometry":{"type":"Polygon","coordinates":["@@ ZNWRquZCBCC@AEA@@ADCDCAACEAGBQ@IN"],"encodeOffsets":[[116265,22694]]},"properties":{"cp":[113.5587044,22.15375944],"name":"嘉模堂區","childNum":1}},{"id":"820007","geometry":{"type":"Polygon","coordinates":["@@MOIAIEI@@GE@AAUCBdCFIFR@HAFBBDDBDCBCDB@BFDDC"],"encodeOffsets":[[116316,22676]]},"properties":{"cp":[113.5695992,22.13663],"name":"路氹填海區","childNum":1}},{"id":"820008","geometry":{"type":"Polygon","coordinates":["@@DKMMa_GC_COD@dVDBBF@@HJ@JFJBNP"],"encodeOffsets":[[116329,22670]]},"properties":{"cp":[113.5599542,22.12348639],"name":"聖方濟各堂區","childNum":1}}],"UTF8Encoding":true}
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Pluto Y
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/OSX_Example/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // OSX_Example
4 | //
5 | // Created by Pluto Y on 02/11/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Cocoa
10 |
11 | @NSApplicationMain
12 | class AppDelegate: NSObject, NSApplicationDelegate {
13 |
14 |
15 |
16 | func applicationDidFinishLaunching(_ aNotification: Notification) {
17 | // Insert code here to initialize your application
18 | }
19 |
20 | func applicationWillTerminate(_ aNotification: Notification) {
21 | // Insert code here to tear down your application
22 | }
23 |
24 |
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/OSX_Example/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/OSX_Example/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSAppTransportSecurity
6 |
7 | NSAllowsArbitraryLoads
8 |
9 |
10 | CFBundleDevelopmentRegion
11 | en
12 | CFBundleExecutable
13 | $(EXECUTABLE_NAME)
14 | CFBundleIconFile
15 |
16 | CFBundleIdentifier
17 | $(PRODUCT_BUNDLE_IDENTIFIER)
18 | CFBundleInfoDictionaryVersion
19 | 6.0
20 | CFBundleName
21 | $(PRODUCT_NAME)
22 | CFBundlePackageType
23 | APPL
24 | CFBundleShortVersionString
25 | 1.0
26 | CFBundleVersion
27 | 1
28 | LSMinimumSystemVersion
29 | $(MACOSX_DEPLOYMENT_TARGET)
30 | NSHumanReadableCopyright
31 | Copyright © 2017 com.pluto-y. All rights reserved.
32 | NSMainStoryboardFile
33 | Main
34 | NSPrincipalClass
35 | NSApplication
36 |
37 |
38 |
--------------------------------------------------------------------------------
/OSX_Example/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // OSX_Example
4 | //
5 | // Created by Pluto Y on 02/11/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Cocoa
10 | import SwiftyEcharts
11 |
12 | class EchartsViewController: NSViewController {
13 |
14 | private var echartsView: EchartsView?
15 | override func viewDidLoad() {
16 | print("viewDidLoad")
17 | super.viewDidLoad()
18 |
19 | echartsView = EchartsView(frame: CGRect(x: 0, y: 30, width: 300, height: 300))
20 | self.view.addSubview(echartsView!)
21 | let leadingConstraint = NSLayoutConstraint(item: echartsView!,
22 | attribute: .leading,
23 | relatedBy: .equal,
24 | toItem: self.view,
25 | attribute: .leading,
26 | multiplier: 1.0,
27 | constant: 0)
28 | let trailingConstraint = NSLayoutConstraint(item: echartsView!,
29 | attribute: .trailing,
30 | relatedBy: .equal,
31 | toItem: self.view,
32 | attribute: .trailing,
33 | multiplier: 1.0,
34 | constant: 0)
35 | let bottomConstraint = NSLayoutConstraint(item: echartsView!,
36 | attribute: .bottom,
37 | relatedBy: .equal,
38 | toItem: self.view,
39 | attribute: .bottom,
40 | multiplier: 1.0,
41 | constant: 0)
42 | let topConstraint = NSLayoutConstraint(item: echartsView!,
43 | attribute: .top,
44 | relatedBy: .equal,
45 | toItem: self.view,
46 | attribute: .top,
47 | multiplier: 1.0,
48 | constant: 30)
49 | // self.view.addConstraints([leadingConstraint, trailingConstraint, topConstraint, bottomConstraint])
50 | print("loadEcharts")
51 | let option = LineOptions.areaStackOption()
52 | echartsView?.option = option
53 | echartsView?.loadEcharts()
54 | print("loadEcharts finished")
55 | }
56 |
57 | override var representedObject: Any? {
58 | didSet {
59 | // Update the view, if already loaded.
60 | }
61 | }
62 |
63 |
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/Podfile:
--------------------------------------------------------------------------------
1 | use_frameworks!
2 |
3 | target 'SwiftyEchartsTest_iOS' do
4 |
5 | pod 'Quick', '~> 1.0.0'
6 | pod 'Nimble', '~> 5.0.0'
7 |
8 |
9 | end
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SwiftyEcharts
2 | [](https://travis-ci.org/Pluto-Y/SwiftyEcharts)
3 | [](https://codecov.io/gh/Pluto-Y/SwiftyEcharts)
4 | 
5 | [](https://github.com/Carthage/Carthage)
6 |
7 | ____
8 | ## 简介
9 | SwiftyEchart 是针对 [ECharts 3](http://echarts.baidu.com/) 进行封装的一个开源库。 主要方便针对不熟悉 `Javascript` 的小伙伴快速使用 `ECharts 3` 的特性,能做出细致的配置。 该项目将适用于 `iOS`, `MacOS`, `tvOS` 以及 `Server`, 并且有可能方便服务器的小伙伴能产生出正确的 `JSON` 交于前端( `ECharts` )处理。
10 |
11 | 目前该项目还在紧急开发中,由于项目有点大,也只有一个人开发,所以可能进度有点慢,希望小伙伴见谅~
12 |
13 | 同时如果遇到任何问题欢迎小伙伴提 [Issue](https://github.com/Pluto-Y/SwiftyEcharts/issues/new) 以及如果有兴趣的小伙伴也可以提 [Pull Request](https://github.com/Pluto-Y/SwiftyEcharts/compare) 给我, 加快项目的进度。
14 |
15 | ## TODO (开发计划)
16 | ___
17 |
18 | 接下来一段时间会针对以下这些开发计划逐步完整,也会根据大家反馈进行添加计划以及调整计划的优先级,目前即将要处理的主要有以下几块:
19 |
20 | - [ ] 支持多种图形类型
21 | - [x] 散点图(已支持)
22 | - [x] 折线图(已支持)
23 | - [x] 柱状图(已支持)
24 | - [x] 地图(已支持)
25 | - [x] 饼图(已支持)
26 | - [x] 雷达图(已支持)
27 | - [x] k线图(已支持)
28 | - [x] 箱线图(已支持)
29 | - [x] 热力图(已支持)
30 | - [ ] 关系图
31 | - [ ] 矩形树图
32 | - [ ] 平行坐标
33 | - [x] 桑基图(已支持)
34 | - [x] 漏斗图(已支持)
35 | - [x] 仪表盘(已支持)
36 | - [x] 象形柱图(已支持)
37 | - [x] 主题河流图(已支持)
38 | - [ ] 日历图
39 | - [x] 支持 `Swift` 语言各版本
40 | > ( branch - Swift 2.3, master - Swift 3.x)
41 | - [ ] 支持 `iOS`, `MacOS`, `tvOS`, `Server`
42 | - [x] 支持事件处理
43 | - [ ] 支持 `Echarts` 更多方法
44 | - [ ] 支持模块化
45 |
46 | ## 安装
47 |
48 | * 手动导入:
49 | * 将项目下的`SwiftyEcharts`目录拷贝到项目中
50 | * `Remove References`移除js目录,然后通过`create floder references`的方式添加js目录
51 | * 通过 `Cocoapods` 进行导入:pod 'SwiftyEcharts'
52 | * 通过 `Carthage` 进行导入: github "Pluto-Y/SwiftyEcharts"
53 |
54 | ⚠️ *** 请确保js目录是蓝色的 *** ⚠️
55 |
56 |
57 | ## 教程
58 |
59 | ## 系统要求
60 | * iOS 8.0 +
61 | * Swift 3(master), Swift2.3(branch)
62 |
63 | ## 联系我
64 |
65 | 由于这个项目需要封装的内容有点多,希望有小伙伴一起来封装,有兴趣的小伙伴可以通过[@叫什么都都不如叫Pluto-Y](http://weibo.com/5690716723/info)来联系我。
66 |
67 | ## 许可证
68 |
69 | SwiftyEcharts 使用 `MIT` 许可证,详情见 [LICENSE](https://github.com/Pluto-Y/SwiftyEcharts/blob/master/LICENSE) 文件。
70 |
--------------------------------------------------------------------------------
/SwiftyEcharts.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 | s.name = "SwiftyEcharts"
3 | s.version = "0.0.2"
4 | s.summary = "A custom component for the ecomfe's echarts 3."
5 | s.homepage = "https://github.com/Pluto-Y/SwiftyEcharts"
6 | s.license = { :type => "MIT", :file => 'LICENSE' }
7 | s.author = { "PlutoY" => "kuaileainits@163.com" }
8 | #s.platform = :ios, "8.0"
9 | s.source = { :git => "https://github.com/Pluto-Y/SwiftyEcharts.git", :tag => s.version}
10 | s.source_files = "SwiftyEcharts/**/*.{h,swift}"
11 | s.resource_bundles = { 'SwiftyEcharts' => 'SwiftyEcharts/Resources/**' }
12 | s.requires_arc = true
13 | s.ios.frameworks = 'UIKit'
14 | s.ios.deployment_target = '8.0'
15 | end
16 |
--------------------------------------------------------------------------------
/SwiftyEcharts.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/SwiftyEcharts.xcodeproj/xcshareddata/xcschemes/SwiftyEcharts.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
55 |
61 |
62 |
63 |
64 |
65 |
66 |
72 |
73 |
79 |
80 |
81 |
82 |
84 |
85 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/SwiftyEcharts.xcodeproj/xcshareddata/xcschemes/SwiftyEchartsTest_iOS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
31 |
32 |
34 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
56 |
57 |
63 |
64 |
65 |
66 |
67 |
68 |
74 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/SwiftyEcharts.xcodeproj/xcshareddata/xcschemes/iOS_Example.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
53 |
54 |
64 |
66 |
72 |
73 |
74 |
75 |
76 |
77 |
83 |
85 |
91 |
92 |
93 |
94 |
96 |
97 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/SwiftyEcharts.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/SwiftyEcharts.xcworkspace/xcshareddata/SwiftyEcharts.xcscmblueprint:
--------------------------------------------------------------------------------
1 | {
2 | "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "12942D37B1059E33B4DAFF1D5E8285BC92E5B14B",
3 | "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
4 | "12942D37B1059E33B4DAFF1D5E8285BC92E5B14B" : {
5 |
6 | },
7 | "f1a3fdbb-014d-4a08-901a-2106448ef8ba++1485" : {
8 |
9 | }
10 | },
11 | "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
12 | "12942D37B1059E33B4DAFF1D5E8285BC92E5B14B" : 9223372036854775807,
13 | "f1a3fdbb-014d-4a08-901a-2106448ef8ba++1485" : 9223372036854775807
14 | },
15 | "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "B3BAC4B7-4C57-4BFF-8276-65C363D0C6D4",
16 | "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
17 | "12942D37B1059E33B4DAFF1D5E8285BC92E5B14B" : "SwiftyEcharts\/",
18 | "f1a3fdbb-014d-4a08-901a-2106448ef8ba++1485" : "SwiftyEcharts\/"
19 | },
20 | "DVTSourceControlWorkspaceBlueprintNameKey" : "SwiftyEcharts",
21 | "DVTSourceControlWorkspaceBlueprintVersion" : 204,
22 | "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "SwiftyEcharts.xcworkspace",
23 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
24 | {
25 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/Pluto-Y\/SwiftyEcharts.git",
26 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
27 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "12942D37B1059E33B4DAFF1D5E8285BC92E5B14B"
28 | },
29 | {
30 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "http:\/\/106.185.33.23:8080\/project\/github",
31 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Subversion",
32 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "f1a3fdbb-014d-4a08-901a-2106448ef8ba++1485"
33 | }
34 | ]
35 | }
--------------------------------------------------------------------------------
/SwiftyEcharts/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Axis/AxisLine.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AxisLine.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 06/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 坐标轴轴线相关设置。
10 | public final class AxisLine: Displayable, Line {
11 | public var show: Bool?
12 | /// X 轴或者 Y 轴的轴线是否在另一个轴的 0 刻度上,只有在另一个轴为数值轴且包含 0 刻度时有效。
13 | public var onZero: Bool?
14 | public var lineStyle: LineStyle?
15 |
16 | public init() { }
17 |
18 | }
19 |
20 | extension AxisLine: Enumable {
21 | public enum Enums {
22 | case show(Bool), onZero(Bool), lineStyle(LineStyle)
23 | }
24 |
25 | public typealias ContentEnum = Enums
26 |
27 | public convenience init(_ elements: Enums...) {
28 | self.init()
29 | for ele in elements {
30 | switch ele {
31 | case let .show(show):
32 | self.show = show
33 | case let .onZero(onZero):
34 | self.onZero = onZero
35 | case let .lineStyle(lineStyle):
36 | self.lineStyle = lineStyle
37 | }
38 | }
39 | }
40 | }
41 |
42 | extension AxisLine: Mappable {
43 | public func mapping(_ map: Mapper) {
44 | map["show"] = show
45 | map["onZero"] = onZero
46 | map["lineStyle"] = lineStyle
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Axis/AxisTick.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AxisTick.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 06/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 坐标轴刻度相关设置。
10 | public final class AxisTick: Line, Displayable {
11 | /// 是否显示坐标轴刻度。
12 | public var show: Bool?
13 | /// 类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
14 | public var alignWithLabel: Bool?
15 | /// 坐标轴刻度的显示间隔,在类目轴中有效。默认同 axisLabel.interval 一样。
16 | /// 默认会采用标签不重叠的策略间隔显示标签。
17 | /// 可以设置成 0 强制显示所有标签。
18 | /// 如果设置为 1,表示『隔一个标签显示一个标签』,如果值为 2,表示隔两个标签显示一个标签,以此类推。
19 | ///
20 | /// 可以用数值表示间隔的数据,也可以通过回调函数控制。回调函数格式如下:
21 | ///
22 | /// (index:number, value: string) => boolean
23 | /// 第一个参数是类目的 index,第二个值是类目名称,如果跳过则返回 false。
24 | public var interval: Int?
25 | /// 坐标轴刻度是否朝内,默认朝外。
26 | public var inside: Bool?
27 | /// 坐标轴刻度的长度。
28 | public var length: LengthValue?
29 | /// 刻度横线的样式
30 | public var lineStyle: LineStyle?
31 |
32 | /// 分隔线之间分割的刻度数。
33 | /// ## 目前只用于仪表盘图中
34 | public var splitNumber: UInt8?
35 |
36 | public init() { }
37 |
38 | }
39 |
40 | extension AxisTick: Enumable {
41 | public enum Enums {
42 | case show(Bool), alignWithLabel(Bool), interval(Int), inside(Bool), length(LengthValue), lineStyle(LineStyle), splitNumber(UInt8)
43 | }
44 |
45 | public typealias ContentEnum = Enums
46 |
47 | public convenience init(_ elements: Enums...) {
48 | self.init()
49 | for ele in elements {
50 | switch ele {
51 | case let .show(show):
52 | self.show = show
53 | case let .alignWithLabel(alignWithLabel):
54 | self.alignWithLabel = alignWithLabel
55 | case let .interval(interval):
56 | self.interval = interval
57 | case let .inside(inside):
58 | self.inside = inside
59 | case let .length(length):
60 | self.length = length
61 | case let .lineStyle(lineStyle):
62 | self.lineStyle = lineStyle
63 | case let .splitNumber(splitNumber):
64 | self.splitNumber = splitNumber
65 | }
66 | }
67 | }
68 | }
69 |
70 | extension AxisTick: Mappable {
71 | public func mapping(_ map: Mapper) {
72 | map["show"] = show
73 | map["alignWithLabel"] = alignWithLabel
74 | map["interval"] = interval
75 | map["inside"] = inside
76 | map["length"] = length
77 | map["lineStyle"] = lineStyle
78 | map["splitNumber"] = splitNumber
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Axis/AxisType.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AxisType.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 06/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 坐标轴类型。
10 | ///
11 | /// - value: 数值轴,适用于连续数据。
12 | /// - category: 类目轴,适用于离散的类目数据,为该类型时必须通过 data 设置类目数据。
13 | /// - time: 时间轴,适用于连续的时序数据,与数值轴相比时间轴带有时间的格式化,在刻度计算上也有所不同,例如会根据跨度的范围来决定使用月,星期,日还是小时范围的刻度。
14 | /// - log: 对数轴。适用于对数数据。
15 | public enum AxisType: String, Jsonable {
16 | case value = "value"
17 | case category = "category"
18 | case time = "time"
19 | case log = "log"
20 |
21 | public var jsonString: String {
22 | return self.rawValue.jsonString
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Axis/SplitArea.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SplitArea.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 06/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 分割区域
10 | public final class SplitArea: Displayable {
11 |
12 | public var show: Bool?
13 | public var interval: UInt?
14 | public var areaStyle: AreaStyle?
15 |
16 | public init() { }
17 | }
18 |
19 | extension SplitArea: Enumable {
20 | public enum Enums {
21 | case show(Bool), interval(UInt), areaStyle(AreaStyle)
22 | }
23 |
24 | public typealias ContentEnum = Enums
25 |
26 | public convenience init(_ elements: Enums...) {
27 | self.init()
28 | for ele in elements {
29 | switch ele {
30 | case let .show(show):
31 | self.show = show
32 | case let .interval(interval):
33 | self.interval = interval
34 | case let .areaStyle(areaStyle):
35 | self.areaStyle = areaStyle
36 | }
37 | }
38 | }
39 | }
40 |
41 | extension SplitArea: Mappable {
42 | public func mapping(_ map: Mapper) {
43 | map["show"] = show
44 | map["interval"] = interval
45 | map["areaStyle"] = areaStyle
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Axis/SplitLine.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SplitLine.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 06/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 分割线
10 | public final class SplitLine: Displayable, Line {
11 | /// 是否显示分隔线。
12 | public var show: Bool?
13 | /// 分隔线的显示间隔
14 | public var interval: LengthValue?
15 | /// 分隔线的长度
16 | public var length: LengthValue?
17 | /// 分割线的样式
18 | public var lineStyle: LineStyle?
19 |
20 | public init() { }
21 | }
22 |
23 | extension SplitLine: Enumable {
24 | public enum Enums {
25 | case show(Bool), interval(LengthValue), length(LengthValue), lineStyle(LineStyle)
26 | }
27 |
28 | public typealias ContentEnum = Enums
29 |
30 | public convenience init(_ elements: Enums...) {
31 | self.init()
32 | for ele in elements {
33 | switch ele {
34 | case let .show(show):
35 | self.show = show
36 | case let .interval(interval):
37 | self.interval = interval
38 | case let .length(length):
39 | self.length = length
40 | case let .lineStyle(lineStyle):
41 | self.lineStyle = lineStyle
42 | }
43 | }
44 | }
45 | }
46 |
47 | extension SplitLine: Mappable {
48 | public func mapping(_ map: Mapper) {
49 | map["show"] = show
50 | map["interval"] = interval
51 | map["length"] = length
52 | map["lineStyle"] = lineStyle
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Graphic/GraphicStyle.swift:
--------------------------------------------------------------------------------
1 | //
2 | // GraphicStyle.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 11/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 通用 `Graphic` 的样式接口
10 | public protocol GraphicStyle: Shadowable {
11 | /// 填充色。
12 | var fill: Color? { get set }
13 | /// 笔画颜色。
14 | var stroke: Color? { get set }
15 | /// 笔画宽度。
16 | var lineWidth: Float? { get set }
17 | }
18 |
19 | /// 通用的 `Graphic` 的样式实现
20 | public final class CommonGraphicStyle: GraphicStyle {
21 | /// MARK: GraphicStyle
22 | public var fill: Color?
23 | public var stroke: Color?
24 | public var lineWidth: Float?
25 | public var shadowBlur: Float?
26 | public var shadowOffsetX: Float?
27 | public var shadowOffsetY: Float?
28 | public var shadowColor: Color?
29 |
30 | public init() {}
31 | }
32 |
33 | extension CommonGraphicStyle: Enumable {
34 | public enum Enums {
35 | case fill(Color), stroke(Color), lineWidth(Float), shadowBlur(Float), shadowOffsetX(Float), shadowOffsetY(Float), shadowColor(Color)
36 | }
37 |
38 | public typealias ContentEnum = Enums
39 |
40 | public convenience init(_ elements: Enums...) {
41 | self.init()
42 | for ele in elements {
43 | switch ele {
44 | case let .fill(fill):
45 | self.fill = fill
46 | case let .stroke(stroke):
47 | self.stroke = stroke
48 | case let .lineWidth(lineWidth):
49 | self.lineWidth = lineWidth
50 | case let .shadowBlur(shadowBlur):
51 | self.shadowBlur = shadowBlur
52 | case let .shadowOffsetX(shadowOffsetX):
53 | self.shadowOffsetX = shadowOffsetX
54 | case let .shadowOffsetY(shadowOffsetY):
55 | self.shadowOffsetY = shadowOffsetY
56 | case let .shadowColor(shadowColor):
57 | self.shadowColor = shadowColor
58 | }
59 | }
60 | }
61 | }
62 |
63 | extension CommonGraphicStyle: Mappable {
64 | public func mapping(_ map: Mapper) {
65 | map["fill"] = fill
66 | map["stroke"] = stroke
67 | map["lineWidth"] = lineWidth
68 | map["shadowBlur"] = shadowBlur
69 | map["shadowOffsetX"] = shadowOffsetX
70 | map["shadowOffsetY"] = shadowOffsetY
71 | map["shadowColor"] = shadowColor
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Graphic/GraphicType.swift:
--------------------------------------------------------------------------------
1 | //
2 | // GraphicType.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 10/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 原生图形元素组件的类型
10 | ///
11 | /// - group: group 是唯一的可以有子节点的容器。group 可以用来整体定位一组图形元素。
12 | /// - image: 图片
13 | /// - text: 文本块
14 | /// - rect: 矩形
15 | /// - circle: 圆
16 | /// - ring: 圆环
17 | /// - sector: 扇形
18 | /// - arc: 圆弧
19 | /// - polygon: 多边形
20 | /// - polyline: 折线
21 | /// - line: 直线
22 | /// - bezierCurve: 二次或三次贝塞尔曲线
23 | public enum GraphicType: String, Jsonable {
24 | case group = "group"
25 | case image = "image"
26 | case text = "text"
27 | case rect = "rect"
28 | case circle = "circle"
29 | case ring = "ring"
30 | case sector = "sector"
31 | case arc = "arc"
32 | case polygon = "polygon"
33 | case polyline = "polyline"
34 | case line = "line"
35 | case bezierCurve = "bezierCurve"
36 |
37 | public var jsonString: String {
38 | return self.rawValue.jsonString
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Graphic/GroupGraphic.swift:
--------------------------------------------------------------------------------
1 | //
2 | // GroupGraphic.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 10/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// group 是唯一的可以有子节点的容器。group 可以用来整体定位一组图形元素。
10 | public final class GroupGraphic: Graphic {
11 |
12 | /// MARK: Graphic
13 | public var type: GraphicType {
14 | return .group
15 | }
16 |
17 | public var id: String?
18 | public var action: GraphicAction?
19 | public var left: Position?
20 | public var right: Position?
21 | public var top: Position?
22 | public var bottom: Position?
23 | public var bounding: GraphicBounding?
24 | public var z: Float?
25 | public var zlevel: Float?
26 | public var silent: Bool?
27 | public var invisible: Bool?
28 | public var cursor: String?
29 | public var draggable: Bool?
30 | public var progressive: Bool?
31 |
32 | /// 用于描述此 group 的宽。
33 | ///
34 | /// 这个宽只用于给子节点定位。
35 | ///
36 | /// 即便当宽度为零的时候,子节点也可以使用 left: 'center' 相对于父节点水平居中。
37 | public var width: Float?
38 | /// 用于描述此 group 的高。
39 | ///
40 | /// 这个高只用于给子节点定位。
41 | ///
42 | /// 即便当高度为零的时候,子节点也可以使用 top: 'middle' 相对于父节点垂直居中。
43 | public var height: Float?
44 | /// 子节点列表,其中项都是一个图形元素定义。
45 | public var children: [Graphic]?
46 |
47 | }
48 |
49 | extension GroupGraphic: Enumable {
50 | public enum Enums {
51 | case id(String), action(GraphicAction), left(Position), right(Position), top(Position), bottom(Position), bounding(GraphicBounding), z(Float), zlevel(Float), silent(Bool), invisible(Bool), cursor(String), draggable(Bool), progressive(Bool), width(Float), height(Float), children([Graphic])
52 | }
53 |
54 | public typealias ContentEnum = Enums
55 |
56 | public convenience init(_ elements: Enums...) {
57 | self.init()
58 | for ele in elements {
59 | switch ele {
60 | case let .id(id):
61 | self.id = id
62 | case let .action(action):
63 | self.action = action
64 | case let .left(left):
65 | self.left = left
66 | case let .right(right):
67 | self.right = right
68 | case let .top(top):
69 | self.top = top
70 | case let .bottom(bottom):
71 | self.bottom = bottom
72 | case let .bounding(bounding):
73 | self.bounding = bounding
74 | case let .z(z):
75 | self.z = z
76 | case let .zlevel(zlevel):
77 | self.zlevel = zlevel
78 | case let .silent(silent):
79 | self.silent = silent
80 | case let .invisible(invisible):
81 | self.invisible = invisible
82 | case let .cursor(cursor):
83 | self.cursor = cursor
84 | case let .draggable(draggable):
85 | self.draggable = draggable
86 | case let .progressive(progressive):
87 | self.progressive = progressive
88 | case let .width(width):
89 | self.width = width
90 | case let .height(height):
91 | self.height = height
92 | case let .children(children):
93 | self.children = children
94 | }
95 | }
96 | }
97 | }
98 |
99 | extension GroupGraphic: Mappable {
100 | public func mapping(_ map: Mapper) {
101 | map["type"] = type
102 | map["id"] = id
103 | map["$action"] = action
104 | map["left"] = left
105 | map["right"] = right
106 | map["top"] = top
107 | map["bottom"] = bottom
108 | map["bounding"] = bounding
109 | map["z"] = z
110 | map["zlevel"] = zlevel
111 | map["silent"] = silent
112 | map["invisible"] = invisible
113 | map["cursor"] = cursor
114 | map["draggable"] = draggable
115 | map["progressive"] = progressive
116 | map["width"] = width
117 | map["height"] = height
118 | map["children"] = children
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Mark/MarkDataType.swift:
--------------------------------------------------------------------------------
1 | //
2 | // MarkDataType.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 16/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 特殊的标注类型,用于标注最大值最小值等。
10 | ///
11 | /// - min: 最小值
12 | /// - max: 最大值
13 | /// - average: 平均值
14 | public enum MarkDataType: String, Jsonable {
15 | case min = "min"
16 | case max = "max"
17 | case average = "average"
18 |
19 | public var jsonString: String {
20 | return self.rawValue.jsonString
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Polar.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Polar.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 25/01/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 极坐标系,可以用于散点图和折线图。每个极坐标系拥有一个角度轴和一个半径轴。
10 | public final class Polar: Zable {
11 | /// 所有图形的 zlevel 值。
12 | ///
13 | /// zlevel用于 Canvas 分层,不同zlevel值的图形会放置在不同的 Canvas 中,Canvas 分层是一种常见的优化手段。我们可以把一些图形变化频繁(例如有动画)的组件设置成一个单独的zlevel。需要注意的是过多的 Canvas 会引起内存开销的增大,在手机端上需要谨慎使用以防崩溃。
14 | ///
15 | /// zlevel 大的 Canvas 会放在 zlevel 小的 Canvas 的上面。
16 | public var zlevel: Float?
17 | /// 组件的所有图形的z值。控制图形的前后顺序。z值小的图形会被z值大的图形覆盖。
18 | ///
19 | /// z相比zlevel优先级更低,而且不会创建新的 Canvas。
20 | public var z: Float?
21 | /// 极坐标系的中心(圆心)坐标,数组的第一项是横坐标,第二项是纵坐标。
22 | ///
23 | /// 支持设置成百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度。
24 | ///
25 | /// 使用示例:
26 | ///
27 | /// // 设置成绝对的像素值
28 | /// center: [400, 300]
29 | /// // 设置成相对的百分比
30 | /// center: [50%, 50%]
31 | public var center: Point?
32 | /// 极坐标系的半径,数组的第一项是内半径,第二项是外半径。
33 | ///
34 | /// 支持设置成百分比,相对于容器高宽中较小的一项的一半。
35 | public var radius: Range?
36 | }
37 |
38 | extension Polar: Enumable {
39 | public enum Enums {
40 | case zlevel(Float), z(Float), center(Point), radius(Range)
41 | }
42 |
43 | public typealias ContentEnum = Enums
44 |
45 | public convenience init(_ elements: Enums...) {
46 | self.init()
47 | for ele in elements {
48 | switch ele {
49 | case let .zlevel(zlevel):
50 | self.zlevel = zlevel
51 | case let .z(z):
52 | self.z = z
53 | case let .center(center):
54 | self.center = center
55 | case let .radius(radius):
56 | self.radius = radius
57 | }
58 | }
59 | }
60 | }
61 |
62 | extension Polar: Mappable {
63 | public func mapping(_ map: Mapper) {
64 | map["zlevel"] = zlevel
65 | map["z"] = z
66 | map["center"] = center
67 | map["radius"] = radius
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Protocol/Borderable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Borderable.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 03/01/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public protocol Borderable {
12 | var borderColor: Color? { get set }
13 | var borderWidth: Float? { get set }
14 | }
15 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Protocol/Displayable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Displayable.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 01/12/2016.
6 | // Copyright © 2016 com.pluto-y. All rights reserved.
7 | //
8 |
9 | public protocol Displayable {
10 | var show: Bool? { get set }
11 | }
12 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Protocol/Emphasisable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // LabelType.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 03/01/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 针对那些有 '正常' 和 '高亮' 两种样式的组件的接口, 例如 `ItemStyle`, `AreaStyle` `Label` 等
10 | public protocol Emphasisable {
11 |
12 | /// 样式,针对不同的组件有不同的样式
13 | associatedtype Style
14 |
15 | /// 默认样式,即非触发 '高亮' 情况下的样式
16 | var normal: Style? { get set }
17 | /// 高亮样式
18 | var emphasis: Style? { get set }
19 | }
20 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Protocol/Enumable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Enumable.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 15/01/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 针对那种只有只读属性或者没有属性的类型
10 | public enum EmptyEnum { }
11 |
12 | public protocol Enumable {
13 | associatedtype ContentEnum
14 | init(_ elements: Self.ContentEnum...)
15 | }
16 |
17 | extension Enumable {
18 | public init(_ element: Self.ContentEnum) {
19 | /// 兼容只有一个参数的情况
20 | self.init(element, element)
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Protocol/Formatted.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Formatted.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 01/12/2016.
6 | // Copyright © 2016 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 内容格式化器:支持字符串模板和回调函数两种形式
10 | ///
11 | /// ## string: 字符串模板。
12 | /// - 模板变量有 {a}, {b},{c},{d},{e},分别表示系列名,数据名,数据值等。 在 trigger 为 'axis' 的时候,会有多个系列的数据,此时可以通过 {a0}, {a1}, {a2} 这种后面加索引的方式表示系列的索引。 不同图表类型下的 {a},{b},{c},{d} 含义不一样。 其中变量{a}, {b}, {c}, {d}在不同图表类型下代表数据含义
13 | /// - 折线(区域)图、柱状(条形)图、K线图 : {a}(系列名称),{b}(类目值),{c}(数值), {d}(无)
14 | /// - 散点图(气泡)图 : {a}(系列名称),{b}(数据名称),{c}(数值数组), {d}(无)
15 | /// - 地图 : {a}(系列名称),{b}(区域名称),{c}(合并数值), {d}(无)
16 | /// - 饼图、仪表盘、漏斗图: {a}(系列名称),{b}(数据项名称),{c}(数值), {d}(百分比)
17 | ///
18 | /// 更多其它图表模板变量的含义可以见相应的图表的 label.normal.formatter 配置项。
19 | ///
20 | /// '{b0}: {c0}
{b1}: {c1}'
21 | /// ## function:回调函数 支持js函数,只需通过字符串来指定声明函数即可
22 | public typealias Formatter = FunctionOrString
23 |
24 | public protocol Formatted {
25 | var formatter: Formatter? { get set }
26 | }
27 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Protocol/Line.swift:
--------------------------------------------------------------------------------
1 | //
2 | // LineStyleContainer.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 01/12/2016.
6 | // Copyright © 2016 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 线的类型
10 | ///
11 | /// - solid: 实线
12 | /// - dashed: 虚线
13 | /// - dotted: 点线
14 | public enum LineType: String, Jsonable {
15 | case solid = "solid", dashed = "dashed", dotted = "dotted"
16 |
17 | public var jsonString: String {
18 | return self.rawValue.jsonString
19 | }
20 | }
21 |
22 |
23 | public protocol Line {
24 | var lineStyle: LineStyle? { get set }
25 | }
26 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Protocol/Opacitable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Opacitable.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 03/01/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 当一个控件支持透明是,则实现此协议即可
10 | public protocol Opacitable: class {
11 | /// 图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
12 | var opacity: Float? { get set }
13 | }
14 |
15 | extension Opacitable {
16 | @discardableResult
17 | public func validateOpacity() -> Bool {
18 | guard let opacity = opacity else {
19 | return false
20 | }
21 | if opacity < Float(0.0) {
22 | self.opacity = 0.0
23 | return false
24 | } else if opacity > Float(1.0) {
25 | self.opacity = 1.0
26 | return false
27 | }
28 | return true
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Protocol/Zable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Zable.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto-Y on 07/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | public protocol Zable {
10 | /// 所有图形的 zlevel 值。
11 | ///
12 | /// zlevel用于 Canvas 分层,不同zlevel值的图形会放置在不同的 Canvas 中,Canvas 分层是一种常见的优化手段。我们可以把一些图形变化频繁(例如有动画)的组件设置成一个单独的zlevel。需要注意的是过多的 Canvas 会引起内存开销的增大,在手机端上需要谨慎使用以防崩溃。
13 | ///
14 | /// zlevel 大的 Canvas 会放在 zlevel 小的 Canvas 的上面。0000000
15 | var zlevel: Float? { get set }
16 | /// 组件的所有图形的z值。控制图形的前后顺序。z值小的图形会被z值大的图形覆盖。
17 | ///
18 | /// z相比zlevel优先级更低,而且不会创建新的 Canvas。
19 | var z: Float? { get set }
20 | }
21 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Series/CoordinateSystem.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CoordinateSystem.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 18/01/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 坐标系枚举
10 | ///
11 | /// - cartesian2d: 二维的直角坐标系(也称笛卡尔坐标系),通过 xAxisIndex, yAxisIndex指定相应的坐标轴组件
12 | /// - polar: 极坐标系,通过 polarIndex 指定相应的极坐标组件
13 | /// - geo: 使用地理坐标系,通过 geoIndex 指定相应的地理坐标系组件
14 | public enum CoordinateSystem: String, Jsonable {
15 | case cartesian2d = "cartesian2d"
16 | case polar = "polar"
17 | case geo = "geo"
18 | case parallel = "parallel"
19 | case calendar = "calendar"
20 | case none = "none"
21 |
22 | public var jsonString: String {
23 | return self.rawValue.jsonString
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Series/Serie.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Serie.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto-Y on 03/01/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 图表类型
10 | ///
11 | /// - line: 折线/面积图
12 | /// - bar: 柱状/条形图
13 | /// - pie: 饼图
14 | /// - scatter: 散点(气泡)图
15 | /// - effectScatter: 带有涟漪特效动画的散点(气泡)图
16 | /// - radar: 雷达图
17 | /// - treemap: 常见的表达『层级数据』『树状数据』的可视化形式
18 | /// - boxplot: 『箱形图』、『盒须图』、『盒式图』、『盒状图』、『箱线图』
19 | /// - candlestick: K线图
20 | /// - heatmap: 热力图
21 | /// - map: 地图
22 | /// - parallel: 平行坐标系
23 | /// - lines: 线图
24 | /// - graph: 关系图
25 | /// - sankey: 桑基图
26 | /// - funnel: 漏斗图
27 | /// - gauge: 仪表盘
28 | /// - pictorialBar: 象形柱图
29 | /// - themeRiver: 主题河流
30 | public enum SerieType: String, Jsonable {
31 | case line = "line"
32 | case bar = "bar"
33 | case pie = "pie"
34 | case scatter = "scatter"
35 | case effectScatter = "effectScatter"
36 | case radar = "radar"
37 | case treemap = "treemap"
38 | case boxplot = "boxplot"
39 | case candlestick = "candlestick"
40 | case heatmap = "heatmap"
41 | case map = "map"
42 | case parallel = "parallel"
43 | case lines = "lines"
44 | case graph = "graph"
45 | case sankey = "sankey"
46 | case funnel = "funnel"
47 | case gauge = "gauge"
48 | case pictorialBar = "pictorialBar"
49 | case themeRiver = "themeRiver"
50 | case custom = "custom"
51 |
52 | public var jsonString: String {
53 | return self.rawValue.jsonString
54 | }
55 | }
56 |
57 | public protocol Serie {
58 |
59 | /// 系列列表。每个系列通过 type 决定自己的图表类型
60 | var type: SerieType { get }
61 | }
62 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Type/AreaStyle.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AreaStyle.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 04/01/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | public protocol AreaStyleContent: Colorful, Shadowable, Opacitable {
10 |
11 | }
12 |
13 | /// 分隔区域的样式设置。
14 | public final class AreaStyle: AreaStyleContent {
15 | /// 分隔区域颜色。分隔区域会按数组中颜色的顺序依次循环设置颜色。默认是一个深浅的间隔色。
16 | public var color: Color?
17 | /// 阴影设置
18 | public var shadowBlur: Float?
19 | public var shadowColor: Color?
20 | public var shadowOffsetX: Float?
21 | public var shadowOffsetY: Float?
22 | /// 图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
23 | public var opacity: Float? {
24 | didSet {
25 | validateOpacity()
26 | }
27 | }
28 | }
29 |
30 | public typealias CommonAreaStyleContent = AreaStyle
31 |
32 | extension AreaStyle: Enumable {
33 | public enum Enums {
34 | case color(Color), shadowBlur(Float), shadowColor(Color), shadowOffsetX(Float), shadowOffsetY(Float), opacity(Float)
35 | }
36 |
37 | public typealias ContentEnum = Enums
38 |
39 | public convenience init(_ elements: Enums...) {
40 | self.init()
41 | for ele in elements {
42 | switch ele {
43 | case let .color(color):
44 | self.color = color
45 | case let .shadowBlur(blur):
46 | self.shadowBlur = blur
47 | case let .shadowColor(color):
48 | self.shadowColor = color
49 | case let .shadowOffsetX(x):
50 | self.shadowOffsetX = x
51 | case let .shadowOffsetY(y):
52 | self.shadowOffsetY = y
53 | case let .opacity(opacity):
54 | self.opacity = opacity
55 | }
56 | }
57 | }
58 | }
59 |
60 | extension AreaStyle: Mappable {
61 | public func mapping(_ map: Mapper) {
62 | map["color"] = color
63 | map["shadowBlur"] = shadowBlur
64 | map["shadowColor"] = shadowColor
65 | map["shadowOffsetX"] = shadowOffsetX
66 | map["shadowOffsetY"] = shadowOffsetY
67 | map["opacity"] = opacity
68 | }
69 | }
70 |
71 | public final class EmphasisAreaStyle: Emphasisable {
72 | public typealias Style = CommonAreaStyleContent
73 |
74 | public var normal: Style?
75 | public var emphasis: Style?
76 | }
77 |
78 | extension EmphasisAreaStyle: Enumable {
79 | public enum Enums {
80 | case normal(Style), emphasis(Style)
81 | }
82 |
83 | public typealias ContentEnum = Enums
84 |
85 | public convenience init(_ elements: Enums...) {
86 | self.init()
87 | for ele in elements {
88 | switch ele {
89 | case let .normal(normal):
90 | self.normal = normal
91 | case let .emphasis(emphasis):
92 | self.emphasis = emphasis
93 | }
94 | }
95 | }
96 | }
97 |
98 | extension EmphasisAreaStyle: Mappable {
99 | public func mapping(_ map: Mapper) {
100 | map["normal"] = normal
101 | map["emphasis"] = emphasis
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Type/BoundaryGap.swift:
--------------------------------------------------------------------------------
1 | //
2 | // BoundaryGap.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto-Y on 15/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 坐标轴两边留白策略,类目轴和非类目轴的设置和表现不一样。
10 | ///
11 | /// - category: 类目轴中 boundaryGap 可以配置为 true 和 false。默认为 true,这时候刻度只是作为分隔线,标签和数据点都会在两个刻度之间的带(band)中间。
12 | /// - notCategory: 非类目轴,包括时间,数值,对数轴,boundaryGap是一个两个值的数组,分别表示数据最小值和最大值的延伸范围,可以直接设置数值或者相对的百分比,在设置 min 和 max 后无效。
13 | ///
14 | /// 示例:
15 | ///
16 | /// boundaryGap: ['20%', '20%']
17 | public enum BoundaryGap: Jsonable {
18 | case category(Bool)
19 | case notCategory(Range)
20 |
21 | public var jsonString: String {
22 | switch self {
23 | case let .category(enable):
24 | return "\(enable)"
25 | case let .notCategory(range):
26 | return "\(range.jsonString)"
27 | }
28 | }
29 | }
30 |
31 | /// 保证该类可以通过 Bool 的类型进行创建
32 | extension BoundaryGap: ExpressibleByBooleanLiteral {
33 | public typealias BooleanLiteralType = Bool
34 | public init(booleanLiteral value: Bool) {
35 | self = BoundaryGap.category(value)
36 | }
37 | }
38 |
39 | /// 保证该类可以通过常量数组进行创建
40 | extension BoundaryGap: ExpressibleByArrayLiteral {
41 | public init(arrayLiteral elements: LengthValue...) {
42 | let range: Range = Range(elements)
43 | self = BoundaryGap.notCategory(range)
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Type/Font.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Font.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 30/11/2016.
6 | // Copyright © 2016 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | /// 文字字体的风格
12 | public enum FontStyle: String, Jsonable, CustomStringConvertible{
13 | case normal = "normal"
14 | case italic = "italic"
15 | case oblique = "oblique"
16 |
17 | public var description: String {
18 | return "\(self.rawValue)"
19 | }
20 | }
21 |
22 |
23 | /// 文字字体的粗细
24 | public enum FontWeight: Jsonable, CustomStringConvertible {
25 | case normal
26 | case bold
27 | case bolder
28 | case lighter
29 | case weight(Int)
30 |
31 | public var description: String {
32 | switch self {
33 | case .normal:
34 | return "normal"
35 | case .bold:
36 | return "bold"
37 | case .bolder:
38 | return "bolder"
39 | case .lighter:
40 | return "lighter"
41 | case let .weight(weight):
42 | return "\(weight)"
43 | }
44 | }
45 | }
46 |
47 | // 通过整数创建 `FontWeight`
48 | extension FontWeight: ExpressibleByIntegerLiteral {
49 | public init(integerLiteral value: Int) {
50 | self = .weight(value)
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Type/LineStyle.swift:
--------------------------------------------------------------------------------
1 | //
2 | // LineStyle.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 03/01/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | public protocol LineStyleContent: Colorful, Shadowable, Opacitable {
10 | var width: Float? { get set }
11 | var type: LineType? { get set }
12 | }
13 |
14 |
15 | /// 线条样式
16 | public final class LineStyle: Displayable, Shadowable, Colorful, Opacitable, Jsonable {
17 |
18 | /// 是否显示
19 | public var show: Bool?
20 | /// 线的颜色。
21 | public var color: Color?
22 | /// 线宽。
23 | public var width: Float?
24 | /// 线的类型。
25 | public var type: LineType?
26 | /// 图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
27 | public var opacity: Float? {
28 | didSet {
29 | validateOpacity()
30 | }
31 | }
32 |
33 | // MARK: - Shadowable
34 | public var shadowBlur: Float?
35 | public var shadowColor: Color?
36 | public var shadowOffsetX: Float?
37 | public var shadowOffsetY: Float?
38 |
39 | public var curveness: Float?
40 |
41 | public init() { }
42 |
43 | }
44 |
45 |
46 | extension LineStyle: Enumable {
47 | public enum Enums {
48 | case show(Bool), color(Color), width(Float), type(LineType), shadowBlur(Float), shadowColor(Color), shadowOffsetX(Float), shadowOffsetY(Float), opacity(Float), curveness(Float)
49 | }
50 |
51 | public typealias ContentEnum = Enums
52 |
53 | public convenience init(_ elements: Enums...) {
54 | self.init()
55 | for ele in elements {
56 | switch ele {
57 | case let .show(show):
58 | self.show = show
59 | case let .color(color):
60 | self.color = color
61 | case let .width(width):
62 | self.width = width
63 | case let .type(type):
64 | self.type = type
65 | case let .shadowBlur(blur):
66 | self.shadowBlur = blur
67 | case let .shadowColor(color):
68 | self.shadowColor = color
69 | case let .shadowOffsetX(x):
70 | self.shadowOffsetX = x
71 | case let .shadowOffsetY(y):
72 | self.shadowOffsetY = y
73 | case let .opacity(opacity):
74 | self.opacity = opacity
75 | case let .curveness(curveness):
76 | self.curveness = curveness
77 | }
78 | }
79 | }
80 | }
81 |
82 | extension LineStyle: Mappable {
83 | public func mapping(_ map: Mapper) {
84 | map["show"] = show
85 | map["color"] = color
86 | map["width"] = width
87 | map["type"] = type
88 | map["shadowBlur"] = shadowBlur
89 | map["shadowColor"] = shadowColor
90 | map["shadowOffsetX"] = shadowOffsetX
91 | map["shadowOffsetY"] = shadowOffsetY
92 | map["opacity"] = opacity
93 | map["curveness"] = curveness
94 | }
95 | }
96 |
97 | public final class EmphasisLineStyle: Emphasisable {
98 | public typealias Style = LineStyle
99 |
100 | public var normal: Style?
101 | public var emphasis: Style?
102 |
103 | public init() { }
104 | }
105 |
106 | extension EmphasisLineStyle: Enumable {
107 | public enum Enums {
108 | case normal(Style), emphasis(Style)
109 | }
110 |
111 | public typealias ContentEnum = Enums
112 |
113 | public convenience init(_ elements: Enums...) {
114 | self.init()
115 | for ele in elements {
116 | switch ele {
117 | case let .normal(normal):
118 | self.normal = normal
119 | case let .emphasis(emphasis):
120 | self.emphasis = emphasis
121 | }
122 | }
123 | }
124 | }
125 |
126 | extension EmphasisLineStyle: Mappable {
127 | public func mapping(_ map: Mapper) {
128 | map["normal"] = normal
129 | map["emphasis"] = emphasis
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Type/Orient.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Orient.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 12/04/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 布局朝向
10 | ///
11 | /// - horizontal: 水平
12 | /// - vertical: 垂直
13 | public enum Orient: String, Jsonable {
14 | case horizontal = "horizontal", vertical = "vertical"
15 |
16 | public var jsonString: String {
17 | return self.rawValue.jsonString
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Type/Padding.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Padding.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 12/04/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 内边距
10 | ///
11 | /// - all: 所有
12 | /// - verticalAndHorizontal: 垂直和水平方向
13 | /// - trbl: 上右下左
14 | /// - null: 为空的情况
15 | public enum Padding: Jsonable {
16 | case all(Float)
17 | case verticalAndHorizontal(Float, Float)
18 | case trbl(Float, Float, Float, Float)
19 | case null
20 | public var jsonString: String {
21 | switch self {
22 | case let .all(val):
23 | return "\(val)"
24 | case let .verticalAndHorizontal(vVal, hVal):
25 | return "[\(vVal), \(hVal)]"
26 | case let .trbl(tVal, rVal, bVal, lVal):
27 | return "[\(tVal), \(rVal), \(bVal), \(lVal)]"
28 | case .null:
29 | return "null"
30 | }
31 | }
32 | }
33 |
34 |
35 | // MARK: - 使其能通过浮点数,整数来创建创建
36 | extension Padding: ExpressibleByFloatLiteral {
37 | public init(floatLiteral value: Float) {
38 | self = .all(value)
39 | }
40 | }
41 |
42 | extension Padding: ExpressibleByIntegerLiteral {
43 | public init(integerLiteral value: Int) {
44 | self = .all(Float(value))
45 | }
46 | }
47 |
48 | // MARK: - 使其能通过数组来创建
49 | extension Padding: ExpressibleByArrayLiteral {
50 | public init(arrayLiteral elements: Float...) {
51 | if elements.count == 1 {
52 | self = .all(elements.first!)
53 | } else if elements.count == 2 {
54 | self = .verticalAndHorizontal(elements.first!, elements.last!)
55 | } else if elements.count == 4 {
56 | self = .trbl(elements[0], elements[1], elements[2], elements[3])
57 | } else {
58 | self = .null
59 | }
60 | }
61 | }
62 |
63 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Type/Position.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Position.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto-Y on 15/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 位置
10 | public enum Position: FunctionOrOthers {
11 | case auto, left, center, right, top, middle, bottom, start, end, inside, inner, outside, insideLeft, insideTop, insideRight, insideBottom, insideTopLeft, insideBottomLeft, insideTopRight, insideBottomRight
12 | case value(LengthValue)
13 | case point(Point)
14 | case function(Function)
15 |
16 | public var jsonString: String {
17 | switch self {
18 | case .auto:
19 | return "auto".jsonString
20 | case .left:
21 | return "left".jsonString
22 | case .right:
23 | return "right".jsonString
24 | case .center:
25 | return "center".jsonString
26 | case .top:
27 | return "top".jsonString
28 | case .bottom:
29 | return "bottom".jsonString
30 | case .middle:
31 | return "middle".jsonString
32 | case .start:
33 | return "start".jsonString
34 | case .end:
35 | return "end".jsonString
36 | case .inside:
37 | return "inside".jsonString
38 | case .inner:
39 | return "inner".jsonString
40 | case .outside:
41 | return "outside".jsonString
42 | case .insideLeft:
43 | return "insideLeft".jsonString
44 | case .insideRight:
45 | return "insideRight".jsonString
46 | case .insideTop:
47 | return "insideTop".jsonString
48 | case .insideBottom:
49 | return "insideBottom".jsonString
50 | case .insideTopLeft:
51 | return "insideTopLeft".jsonString
52 | case .insideBottomLeft:
53 | return "insideBottomLeft".jsonString
54 | case .insideTopRight:
55 | return "insideTopRight".jsonString
56 | case .insideBottomRight:
57 | return "insideBottomRight".jsonString
58 | case let .point(point):
59 | return point.jsonString
60 | case let .value(val):
61 | return val.jsonString
62 | case let .function(f):
63 | return f.jsonString
64 | }
65 | }
66 | }
67 |
68 | extension Position: ExpressibleByFloatLiteral, ExpressibleByIntegerLiteral {
69 | public init(floatLiteral value: Float) {
70 | self = .value(value)
71 | }
72 |
73 | public init(integerLiteral value: Int) {
74 | self = .value(value)
75 | }
76 | }
77 |
78 | public enum Location: String, Jsonable {
79 | case start = "start"
80 | case middle = "middle"
81 | case end = "end"
82 |
83 | public var jsonString: String {
84 | return self.rawValue.jsonString
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Type/Roam.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Roam.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 03/03/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 是否开启拖拽漫游(移动和缩放)。可取值有:
10 | ///
11 | /// - enable: 缩放和平移均可。
12 | /// - disable: 关闭。
13 | /// - scale: 只能够缩放。
14 | /// - zoom: 只能够缩放。
15 | /// - move: 只能够平移。
16 | /// - pan: 只能够平移。
17 | /// - null: 采用默认值,看具体使用的地方。
18 | public enum Roam: String, Jsonable {
19 | case enable = "true"
20 | case disable = "false"
21 | case scale = "scale"
22 | case zoom = "zoom"
23 | case move = "move"
24 | case pan = "pan"
25 | case null = "null"
26 |
27 | public var jsonString: String {
28 | switch self {
29 | case .enable, .disable, .null:
30 | return "\(self.rawValue)"
31 | default:
32 | return self.rawValue.jsonString
33 | }
34 | }
35 | }
36 |
37 | // 通过 Bool 值能控制是否开启拖拽漫游
38 | extension Roam: ExpressibleByBooleanLiteral {
39 |
40 | public init(booleanLiteral value: Bool) {
41 | if value {
42 | self = .enable
43 | } else {
44 | self = .disable
45 | }
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Type/SelectedMode.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SelectedMode.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 10/03/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 图例选择的模式,控制是否可以通过点击图例改变系列的显示状态。默认开启图例选择,可以设成 false 关闭。
10 | ///
11 | /// 除此之外也可以设成 'single' 或者 'multiple' 使用单选或者多选模式。
12 | public enum SelectedMode: String, Jsonable {
13 | case enable = "true"
14 | case disable = "false"
15 | case single = "single"
16 | case multiple = "multiple"
17 |
18 | public var jsonString: String {
19 | switch self {
20 | case .enable, .disable:
21 | return "\(self.rawValue)"
22 | case .single, .multiple:
23 | return self.rawValue.jsonString
24 | }
25 | }
26 |
27 | }
28 |
29 | extension SelectedMode: ExpressibleByBooleanLiteral {
30 | public init(booleanLiteral value: Bool) {
31 | if value {
32 | self = .enable
33 | } else {
34 | self = .disable
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Type/Symbol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Symbol.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 06/12/2016.
6 | // Copyright © 2016 com.pluto-y. All rights reserved.
7 | //
8 |
9 |
10 | /// ECharts 提供的标记类型包括 'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow'
11 | ///
12 | /// 也可以通过 image(url) 设置为图片,其中 url 为图片的链接。
13 | ///
14 | /// 在 ECharts 3 里可以通过 'path://' 将图标设置为任意的矢量路径。这种方式相比于使用图片的方式,不用担心因为缩放而产生锯齿或模糊,而且可以设置为任意颜色。路径图形会自适应调整为合适(如果是 symbol 的话就是 symbolSize)的大小。路径的格式参见 SVG PathData。可以从 Adobe Illustrator 等工具编辑导出。
15 | public enum Symbol: CustomStringConvertible, Jsonable {
16 | case emptyCircle
17 | case circle
18 | case rect
19 | case roundRect
20 | case triangle
21 | case diamond
22 | case pin
23 | case arrow
24 | case none
25 | case image(String)
26 | case path(String)
27 |
28 | public var description: String {
29 | switch self {
30 | case .emptyCircle:
31 | return "emptyCircle"
32 | case .circle:
33 | return "circle"
34 | case .rect:
35 | return "rect"
36 | case .roundRect:
37 | return "roundRect"
38 | case .triangle:
39 | return "triangle"
40 | case .diamond:
41 | return "diamond"
42 | case .pin:
43 | return "pin"
44 | case .arrow:
45 | return "arrow"
46 | case .none:
47 | return "none"
48 | case let .image(url):
49 | return url
50 | case let .path(path):
51 | return path
52 | }
53 | }
54 | }
55 |
56 | public protocol Symbolized {
57 | var symbol: OneOrMore? { get set }
58 | var symbolSize: FunctionOrFloatOrPair? { get set }
59 | var symbolRotate: Float? { get set }
60 | var symbolOffset: Point? { get set }
61 | }
62 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Type/Target.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Target.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 12/04/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 指定窗口打开主标题超链接。
10 | public enum Target: Jsonable, CustomStringConvertible {
11 |
12 | /// 当前窗口打开
13 | case `self`
14 | /// 新窗口打开
15 | case blank
16 |
17 | public var description: String {
18 | switch self {
19 | case .`self`:
20 | return "self"
21 | case .blank:
22 | return "blank"
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Models/Type/Text.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TextStyle.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 30/11/2016.
6 | // Copyright © 2016 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 水平对齐
10 | ///
11 | /// - left: 左边
12 | /// - right: 右边
13 | /// - center: 中间
14 | public enum Align: String, Jsonable {
15 | case left = "left"
16 | case right = "right"
17 | case center = "center"
18 | case auto = "auto"
19 | case none = ""
20 |
21 | public var jsonString: String {
22 | return self.rawValue.jsonString
23 | }
24 | }
25 |
26 | /// 文本垂直对齐
27 | ///
28 | /// - top: 顶部
29 | /// - middle: 中间
30 | /// - bottom: 底部
31 | public enum VerticalAlign: String, Jsonable {
32 | case top = "top"
33 | case middle = "middle"
34 | case bottom = "bottom"
35 |
36 | public var jsonString: String {
37 | return self.rawValue.jsonString
38 | }
39 | }
40 |
41 | /// 文字样式
42 | public final class TextStyle: Colorful {
43 | /// 颜色
44 | public var color: Color?
45 | /// 文字字体的风格
46 | public var fontStyle: FontStyle?
47 | /// 文字字体的粗细
48 | public var fontWeight: FontWeight?
49 | /// 文字的字体系列
50 | public var fontFamily: String?
51 | /// 文字的字体大小
52 | public var fontSize: UInt?
53 | /// 父控件的相对位置的对齐
54 | public var align: Position?
55 |
56 | public init() { }
57 | }
58 |
59 | extension TextStyle: Enumable {
60 |
61 | public enum Enums {
62 | case color(Color), fontStyle(FontStyle), fontWeight(FontWeight), fontFamily(String), fontSize(UInt), align(Position)
63 | }
64 |
65 | public typealias ContentEnum = Enums
66 |
67 | public convenience init(_ elements: Enums...) {
68 | self.init()
69 | for ele in elements {
70 | switch ele {
71 | case let .color(color):
72 | self.color = color;
73 | case let .fontStyle(fontStyle):
74 | self.fontStyle = fontStyle
75 | case let .fontWeight(fontWeight):
76 | self.fontWeight = fontWeight
77 | case let .fontFamily(fontFamily):
78 | self.fontFamily = fontFamily
79 | case let .fontSize(fontSize):
80 | self.fontSize = fontSize
81 | case let .align(align):
82 | self.align = align
83 | }
84 | }
85 | }
86 | }
87 |
88 | extension TextStyle: Mappable {
89 | public func mapping(_ map: Mapper) {
90 | map["color"] = color
91 | map["fontStyle"] = fontStyle
92 | map["fontWeight"] = fontWeight
93 | map["fontFamily"] = fontFamily
94 | map["fontSize"] = fontSize
95 | map["align"] = align
96 | }
97 | }
98 |
99 | public protocol Textful {
100 | var textStyle: TextStyle? { get set }
101 | }
102 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Resources/js/dataTool.js:
--------------------------------------------------------------------------------
1 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("echarts")):"function"==typeof define&&define.amd?define(["echarts"],t):"object"==typeof exports?exports.dataTool=t(require("echarts")):(e.echarts=e.echarts||{},e.echarts.dataTool=t(e.echarts))}(this,function(e){return function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return e[o].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){var o;o=function(e){var t=r(1);return t.dataTool={version:"1.0.0",gexf:r(5),prepareBoxplotData:r(6)},t.dataTool}.call(t,r,t,e),!(void 0!==o&&(e.exports=o))},function(t,r){t.exports=e},,,,function(e,t,r){var o;o=function(e){"use strict";function t(e){var t;if("string"==typeof e){var r=new DOMParser;t=r.parseFromString(e,"text/xml")}else t=e;if(!t||t.getElementsByTagName("parsererror").length)return null;var i=l(t,"gexf");if(!i)return null;for(var u=l(i,"graph"),s=o(l(u,"attributes")),c={},f=0;fg){var x=[u,b];"vertical"===r.layout&&x.reverse(),a.push(x)}}}return{boxData:n,outliers:a,axisData:i}}}.call(t,r,t,e),!(void 0!==o&&(e.exports=o))},function(e,t,r){var o;o=function(e){return function(e,t){var r=(e.length-1)*t+1,o=Math.floor(r),n=+e[o-1],a=r-o;return a?n+a*(e[o]-n):n}}.call(t,r,t,e),!(void 0!==o&&(e.exports=o))}])});
2 |
--------------------------------------------------------------------------------
/SwiftyEcharts/SwiftyEcharts.h:
--------------------------------------------------------------------------------
1 | //
2 | // SwiftyEcharts.h
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 22/09/2016.
6 | // Copyright © 2016 com.pluto-y. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for SwiftyEcharts.
12 | FOUNDATION_EXPORT double SwiftyEchartsVersionNumber;
13 |
14 | //! Project version string for SwiftyEcharts.
15 | FOUNDATION_EXPORT const unsigned char SwiftyEchartsVersionString[];
16 |
17 | // In this header, you should import all the public headers of your framework using statements like #import
18 |
19 |
20 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Tools/Json/JsCache.swift:
--------------------------------------------------------------------------------
1 | //
2 | // JsCache.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 12/01/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 用来缓存Js需要执行的代码段,会在显示 Echarts 执行
10 | /// 例如需要在 Serie 中动态执行的 data , 或者是 formatter 需要在执行是才知道数据的情况下都可以缓存在该处
11 | public final class JsCache {
12 | fileprivate static var jsCache: [String] = [String]()
13 | fileprivate static let lock = NSLock()
14 |
15 | public static func add(_ jsStr: String) {
16 | lock.lock()
17 | jsCache.append(jsStr)
18 | lock.unlock()
19 | }
20 |
21 | public static func removeAll() {
22 | lock.lock()
23 | jsCache.removeAll()
24 | lock.unlock()
25 | }
26 |
27 | public static func allJsStrings() -> [String] {
28 | lock.lock()
29 | let result = jsCache
30 | lock.unlock()
31 | return result
32 | }
33 |
34 | public static func contain(_ jsStr: String) -> Bool {
35 | lock.lock()
36 | let result = jsCache.contains(jsStr)
37 | lock.unlock()
38 | return result
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Tools/Json/Mappable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Mappable.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto-Y on 04/01/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | public protocol Mappable: Jsonable {
10 | func mapping(_ map: Mapper)
11 | }
12 |
13 | extension Mappable {
14 |
15 | public var jsonString: String {
16 | let map = Mapper()
17 | mapping(map)
18 | return map.jsonString
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Tools/Json/Mapper.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Mapper.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 09/01/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 |
10 | public final class Mapper {
11 | public static var ignoreNil: Bool = true
12 | public var mapDic: [String: Jsonable?] = {
13 | let dic = [String: Jsonable?]()
14 | return dic
15 | }()
16 |
17 | public subscript(key: String) -> Jsonable? {
18 | get {
19 | if let value = mapDic[key] {
20 | return value
21 | }
22 | return nil
23 | }
24 | set {
25 | mapDic[key] = newValue
26 | }
27 | }
28 | }
29 |
30 | extension Mapper: Jsonable {
31 | public var jsonString: String {
32 | if Mapper.ignoreNil {
33 | let tmpDic = mapDic
34 | for (key, val) in tmpDic {
35 | if val == nil {
36 | mapDic.removeValue(forKey: key)
37 | }
38 | }
39 | }
40 | return mapDic.jsonString
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Tools/Type/Function.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Function.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 18/09/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 用来封装在model或者一些枚举中会用到的js的function的情况
10 | /// 保证其的统一性以及将来的拓展性
11 | public final class Function {
12 | internal var jsFuncStr: String
13 |
14 | public init(_ jsFuncStr: String) {
15 | self.jsFuncStr = jsFuncStr
16 | }
17 | }
18 |
19 | internal let EchartsFunctionPrefix = "_echartsFunc"
20 |
21 | // MARK: - 用来封装对Jsonable的拓展
22 | extension Function: Jsonable {
23 | public var jsonString: String {
24 | guard jsFuncStr != "null" else {
25 | return "null"
26 | }
27 | // 避免重复添加相同的js
28 | for jsFunc in JsCache.allJsStrings() {
29 | if let endRange = jsFunc.range(of: " = \(jsFuncStr);") {
30 | let j = jsFunc.substring(to: endRange.lowerBound).substring(from: jsFunc.index(jsFunc.startIndex, offsetBy: 4))
31 | return j.jsonString
32 | }
33 | }
34 | let jsonStr = "\(EchartsFunctionPrefix)\(JsCache.allJsStrings().count)"
35 | JsCache.add("var \(jsonStr) = \(jsFuncStr);")
36 | return jsonStr.jsonString
37 | }
38 | }
39 |
40 | // MARK: - 用来封装其可以通过字符串常量来进行赋值
41 | extension Function: ExpressibleByStringLiteral {
42 | public convenience init(stringLiteral value: String) {
43 | self.init(value)
44 | }
45 |
46 | public convenience init(extendedGraphemeClusterLiteral value: String) {
47 | self.init(value)
48 | }
49 |
50 | public convenience init(unicodeScalarLiteral value: String) {
51 | self.init(value)
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Tools/Type/FunctionOrOthers.swift:
--------------------------------------------------------------------------------
1 | //
2 | // FunctionOrOthers.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 18/06/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | public protocol FunctionOrOthers: Jsonable {
10 | }
11 |
12 | public enum FunctionOrFloat: FunctionOrOthers {
13 | case value(Float)
14 | case function(Function)
15 |
16 | public var jsonString: String {
17 | switch self {
18 | case let .value(value):
19 | return value.jsonString
20 | case let .function(f):
21 | return f.jsonString
22 | }
23 | }
24 | }
25 |
26 | extension FunctionOrFloat: ExpressibleByFloatLiteral, ExpressibleByIntegerLiteral {
27 |
28 | public init(floatLiteral value: Float) {
29 | self = .value(value)
30 | }
31 |
32 | public init(integerLiteral value: Int) {
33 | self = .value(Float(value))
34 | }
35 |
36 | }
37 |
38 | public enum FunctionOrFloatOrPair: FunctionOrOthers {
39 | case value(Float)
40 | case point(Point)
41 | case function(Function)
42 |
43 | public var jsonString: String {
44 | switch self {
45 | case let .value(value):
46 | return value.jsonString
47 | case let .function(f):
48 | return f.jsonString
49 | case let .point(point):
50 | return point.jsonString
51 | }
52 | }
53 | }
54 |
55 | extension FunctionOrFloatOrPair: ExpressibleByFloatLiteral, ExpressibleByIntegerLiteral {
56 |
57 | public init(floatLiteral value: Float) {
58 | self = .value(value)
59 | }
60 |
61 | public init(integerLiteral value: Int) {
62 | self = .value(Float(value))
63 | }
64 |
65 | }
66 |
67 | extension FunctionOrFloatOrPair: ExpressibleByArrayLiteral {
68 | public typealias Element = LengthValue
69 | public init(arrayLiteral elements: FunctionOrFloatOrPair.Element...) {
70 | if elements.count != 2 {
71 | printError("The count of the array should only be two.")
72 | self = .function("null")
73 | } else {
74 | let point = Pair(elements)
75 | self = .point(point)
76 | }
77 | }
78 | }
79 |
80 | public enum FunctionOrString: FunctionOrOthers {
81 | case string(String)
82 | case function(Function)
83 |
84 | public var jsonString: String {
85 | switch self {
86 | case let .string(string):
87 | return string.jsonString
88 | case let .function(function):
89 | return function.jsonString
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Tools/Type/LengthValue.swift:
--------------------------------------------------------------------------------
1 | //
2 | // LengthValue.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto-Y on 15/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 用来同意表示长度的值, 之后可以通过数值或者通过数值加%(见 Percent.swift )
10 | ///
11 | /// 例如通过标示宽度可以通过下面例子来表示:
12 | ///
13 | /// .width(30.0)
14 | ///
15 | /// 或者
16 | ///
17 | /// .width(32.0%)
18 | public protocol LengthValue: Jsonable { }
19 |
20 | /// 保证Float, Double, Int 都支持 LengthValue 协议
21 | extension Float: LengthValue { }
22 | extension Double: LengthValue { }
23 | extension Int: LengthValue { }
24 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Tools/Type/OneOrMore.swift:
--------------------------------------------------------------------------------
1 | //
2 | // OneOrMore.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 19/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 针对那些可以是一个组件也可以是多个组件组成的属性的抽象
10 | ///
11 | /// 例如在 Option 中存在许多即可以传递一个也可以传递多个的组件
12 | ///
13 | /// 并且保证其可以通过数组常量来进行创建
14 | public final class OneOrMore: ExpressibleByArrayLiteral {
15 | fileprivate var one: T? = nil
16 | fileprivate var more: [T]? = nil
17 |
18 | public init(one: T) {
19 | self.one = one
20 | }
21 |
22 | public init(more: [T]) {
23 | if more.count == 1 {
24 | self.one = more[0]
25 | } else {
26 | self.more = more
27 | }
28 | }
29 |
30 | public init(arrayLiteral elements: T...) {
31 | if elements.count == 1 {
32 | self.one = elements[0]
33 | } else {
34 | self.more = elements
35 | }
36 | }
37 | }
38 |
39 | extension OneOrMore: Jsonable {
40 | public var jsonString: String {
41 | if let datas = self.more {
42 | return datas.jsonString
43 | } else if let data = self.one {
44 | return obtainJsonString(from: data)
45 | }
46 | return "null".jsonString
47 | }
48 | }
49 |
50 | // MARK: - 实现下标的拓展
51 | extension OneOrMore {
52 | public subscript(index: Int) -> T? {
53 | if one != nil {
54 | return index == 0 ? one : nil
55 | }
56 | return more![index]
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Tools/Type/Pair.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Pair.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 15/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 用来保存只有两个元素的类型,
10 | ///
11 | /// 例如一个点, [x, y]
12 | ///
13 | /// 例如一个访问, [min, max]
14 | public final class Pair: ExpressibleByArrayLiteral {
15 |
16 | fileprivate var first: T?
17 | fileprivate var second: T?
18 |
19 | public init(arrayLiteral elements: T...) {
20 | if elements.count != 2 {
21 | printError("The count of the array should only be two.")
22 | } else {
23 | self.first = elements[0]
24 | self.second = elements[1]
25 | }
26 | }
27 |
28 | public init (_ elements: [T]) {
29 | if elements.count != 2 {
30 | printError("The count of the array should only be two.")
31 | } else {
32 | self.first = elements[0]
33 | self.second = elements[1]
34 | }
35 | }
36 | }
37 |
38 | extension Pair: Jsonable {
39 | public var jsonString: String {
40 | if let first = self.first as? Jsonable, let second = self.second as? Jsonable {
41 | return [first, second].jsonString
42 | }
43 | return "null"
44 | }
45 | }
46 |
47 | /// 用于指定坐标点, eg: [x, y]
48 | public typealias Point = Pair
49 | /// 用于指定范围, eg: [min, max]
50 | public typealias Range = Pair
51 | /// 用来指定两端的文本 , eg: ContinuousVisualMap.text
52 | public typealias PiecewiseText = Pair
53 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Tools/Type/Percent.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Percent.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 15/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | /// 用来标示百分比的情况, 通常可以通过用 数值 + % 形式来初始化
10 | /// 并且可以通过 Percent.precision 来进行全局定义
11 | public final class Percent {
12 | public static var precision: Int = 2
13 | fileprivate let value: Double
14 |
15 | public init(_ value: Double) {
16 | self.value = value
17 | }
18 | }
19 |
20 | extension Percent: Jsonable {
21 | public var jsonString: String {
22 | let formatStr = String(format: "%%.%df", Percent.precision)
23 | return "\"\(String(format: formatStr, value))%\""
24 | }
25 | }
26 |
27 | extension Percent: LengthValue {
28 |
29 | }
30 |
31 | // 用自定义操作符 % 将 Int, Float 以及 Double 转换成 Percent 类型
32 | postfix operator %
33 |
34 | public postfix func %(value: Double) -> Percent {
35 | let percent: Percent = Percent(value)
36 | return percent
37 | }
38 |
39 | public postfix func %(value: Float) -> Percent {
40 | let percent: Percent = Percent(Double(value))
41 | return percent
42 | }
43 |
44 | public postfix func %(value: Int) -> Percent {
45 | let percent: Percent = Percent(Double(value))
46 | return percent
47 | }
48 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Tools/Utilities.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Utilities.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto-Y on 10/01/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | // 自定义输出的方法,保证在打包Release版本的时候不会有输出信息
12 | func printInfo(_ object: Any) {
13 | #if DEBUG
14 | Swift.print(object)
15 | #endif
16 | }
17 |
18 | // 自定义错误输出的方法,保证不管是Debug还是Release版本都会输出信息
19 | func printError(_ object: Any) {
20 | Swift.print("Error: \(object)")
21 | }
22 |
23 | // 自定义警告输出的方法,保证不管是Debug还是Release版本都会输出信息
24 | func printWarning(_ object: Any) {
25 | Swift.print("Warning: \(object)")
26 | }
27 |
--------------------------------------------------------------------------------
/SwiftyEcharts/Views/EchartsEvent.swift:
--------------------------------------------------------------------------------
1 | //
2 | // EchartsEvent.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 28/09/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | public enum EchartsEvent: String {
10 | // 鼠标事件
11 | case click = "click"
12 | case dbClick = "dbclick"
13 | case mouseDown = "mousedown"
14 | case mouseUp = "mouseup"
15 | case mouseOver = "mouseover"
16 | case mouseOut = "mouseout"
17 | case globalOut = "globalout"
18 | case contextMenu = "contextmenu"
19 | // legend
20 | case legendSelectChanged = "legendselectchanged"
21 | case legendSelected = "legendselected"
22 | case legendUnselected = "legendunselected"
23 | case legendScroll = "legendscroll"
24 | // datazoom
25 | case dataZoom = "datazoom"
26 | case dataRangeSelected = "datarangeselected"
27 | // timeline
28 | case timelineChanged = "timelinechanged"
29 | case timelinePlayChanged = "timelineplaychanged"
30 | // toolbox
31 | case restore = "restore"
32 | case dataViewChanged = "dataviewchanged"
33 | case magicTypeChanged = "magictypechanged"
34 | // geo
35 | case geoSelectChanged = "geoselectchanged"
36 | case geoSelected = "geoselected"
37 | case geoUnselected = "geounselected"
38 | // pie
39 | case pieSelectChanged = "pieselectchanged"
40 | case pieSelected = "pieselected"
41 | case pieUnselected = "pieunselected"
42 | // map
43 | case mapSelectChanged = "mapselectchanged"
44 | case mapSelected = "mapselected"
45 | case mapUnselected = "mapunselected"
46 | // axis
47 | case axisAreaSelected = "axisareaselected"
48 | // graph
49 | case focusNodeAdjacency = "focusnodeadjacency"
50 | case unfocusNodeAdjacency = "unfocusnodeadjacency"
51 | // brush
52 | case brush = "brush"
53 | case brushselected = "brushselected"
54 | }
55 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/AreaStyleSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AreaStyleSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 24/06/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | @testable import SwiftyEcharts
12 |
13 | class AreaStyleSpec: QuickSpec {
14 | override func spec() {
15 | let colorValue = Color.green
16 | let shadowBlurValue: Float = 2.7
17 | let shadowColorValue = Color.hexColor("#ff170c")
18 | let shadowOffsetXValue: Float = 18.2
19 | let shadowOffsetYValue: Float = 1.1
20 | let opacityValue: Float = 0.5
21 |
22 | let areaStyleNormal = AreaStyle()
23 | areaStyleNormal.color = colorValue
24 | areaStyleNormal.shadowBlur = shadowBlurValue
25 | areaStyleNormal.shadowColor = shadowColorValue
26 | areaStyleNormal.shadowOffsetX = shadowOffsetXValue
27 | areaStyleNormal.shadowOffsetY = shadowOffsetYValue
28 | areaStyleNormal.opacity = opacityValue
29 |
30 | describe("For AreaStyle") {
31 | it("needs to check the jsonString") {
32 | let resultDic: [String: Jsonable] = [
33 | "color": colorValue,
34 | "shadowBlur": shadowBlurValue,
35 | "shadowColor": shadowColorValue,
36 | "shadowOffsetX": shadowOffsetXValue,
37 | "shadowOffsetY": shadowOffsetYValue,
38 | "opacity": opacityValue
39 | ]
40 |
41 | expect(areaStyleNormal.jsonString).to(equal(resultDic.jsonString))
42 | }
43 |
44 | it("needs to check the Enumable") {
45 | let areaStyleByEnums = AreaStyle(
46 | .color(colorValue),
47 | .shadowBlur(shadowBlurValue),
48 | .shadowColor(shadowColorValue),
49 | .shadowOffsetX(shadowOffsetXValue),
50 | .shadowOffsetY(shadowOffsetYValue),
51 | .opacity(opacityValue)
52 | )
53 |
54 | expect(areaStyleByEnums.jsonString).to(equal(areaStyleNormal.jsonString))
55 | }
56 | }
57 |
58 | describe("EmphasisAreaStyle") {
59 | let areaStyleEmphasis = AreaStyle(
60 | .color(Color.auto),
61 | .shadowBlur(8.88),
62 | .shadowColor(Color.red),
63 | .shadowOffsetX(3.99999),
64 | .shadowOffsetY(0),
65 | .opacity(0.3)
66 | )
67 |
68 | let emphasisAreaStyle = EmphasisAreaStyle()
69 | emphasisAreaStyle.normal = areaStyleNormal
70 | emphasisAreaStyle.emphasis = areaStyleEmphasis
71 | it("needs to check jsonString") {
72 | let resutlDic: [String: Jsonable] = [
73 | "normal": areaStyleNormal,
74 | "emphasis": areaStyleEmphasis
75 | ]
76 |
77 | expect(emphasisAreaStyle.jsonString).to(equal(resutlDic.jsonString))
78 | }
79 |
80 | it("needs to check Enumable") {
81 | let emphasisAreaStyleByEnums = EmphasisAreaStyle(
82 | .normal(areaStyleNormal),
83 | .emphasis(areaStyleEmphasis)
84 | )
85 |
86 | expect(emphasisAreaStyleByEnums.jsonString).to(equal(emphasisAreaStyle.jsonString))
87 | }
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/AxisTickSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AxisTickSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 26/06/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class AxisTickSpec: QuickSpec {
14 | override func spec() {
15 | describe("For AxisTick") {
16 | let showValue = false
17 | let alignWithLabelValue = true
18 | let intervalValue = 12
19 | let insideValue = false
20 | let lengthValue: Float = 3.45
21 | let lineStyleValue = LineStyle(
22 | .color(Color.red),
23 | .width(12.0),
24 | .type(.dashed),
25 | .opacity(0.5),
26 | .curveness(12.55)
27 | )
28 | let splitNumberValue: UInt8 = 20
29 |
30 | let axisTick = AxisTick()
31 | axisTick.show = showValue
32 | axisTick.alignWithLabel = alignWithLabelValue
33 | axisTick.interval = intervalValue
34 | axisTick.inside = insideValue
35 | axisTick.length = lengthValue
36 | axisTick.lineStyle = lineStyleValue
37 | axisTick.splitNumber = splitNumberValue
38 |
39 | it("needs to check the jsonString") {
40 | let resultDic: [String: Jsonable] = [
41 | "show": showValue,
42 | "alignWithLabel": alignWithLabelValue,
43 | "interval": intervalValue,
44 | "inside": insideValue,
45 | "length": lengthValue,
46 | "lineStyle": lineStyleValue,
47 | "splitNumber": splitNumberValue
48 | ]
49 |
50 | expect(axisTick.jsonString).to(equal(resultDic.jsonString))
51 | }
52 |
53 | it("needs to check the Enumable") {
54 | let axisTickByEnums = AxisTick(
55 | .show(showValue),
56 | .alignWithLabel(alignWithLabelValue),
57 | .interval(intervalValue),
58 | .inside(insideValue),
59 | .length(lengthValue),
60 | .lineStyle(lineStyleValue),
61 | .splitNumber(splitNumberValue)
62 | )
63 |
64 | expect(axisTickByEnums.jsonString).to(equal(axisTick.jsonString))
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/AxisTypeSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AxisTypeSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 21/06/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class AxisTypeSpec: QuickSpec {
14 | override func spec() {
15 | describe("For AxisType") {
16 | it(" needs to check the jsonString ") {
17 | let valueString = "value"
18 | let categoryString = "category"
19 | let timeString = "time"
20 | let logString = "log"
21 |
22 | let valueAxisType = AxisType.value
23 | let categoryAxisType = AxisType.category
24 | let timeAxisType = AxisType.time
25 | let logAxisType = AxisType.log
26 |
27 | expect(valueAxisType.jsonString).to(equal(valueString.jsonString))
28 | expect(categoryAxisType.jsonString).to(equal(categoryString.jsonString))
29 | expect(timeAxisType.jsonString).to(equal(timeString.jsonString))
30 | expect(logAxisType.jsonString).to(equal(logString.jsonString))
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/BoundaryGapSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // BoundaryGapSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 05/05/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class BoundaryGapSpec: QuickSpec {
14 |
15 | override func spec() {
16 | describe("For BoundaryGap") {
17 |
18 | let enableBoundaryGap = BoundaryGap.category(true)
19 | let disableBoundaryGap = BoundaryGap.category(false)
20 | let rangeBoundaryGap = BoundaryGap.notCategory([20%, 20%])
21 |
22 | it(" needs to check the jsonString for the BoundaryGap ") {
23 | expect(enableBoundaryGap.jsonString).to(equal(true.jsonString))
24 | expect(disableBoundaryGap.jsonString).to(equal(false.jsonString))
25 | expect(rangeBoundaryGap.jsonString).to(equal([20%, 20%].jsonString))
26 | }
27 |
28 | it(" needs to check the Bool Literal Constructor ") {
29 | let trueBoundaryGap: BoundaryGap = true
30 | let falseBoundaryGap: BoundaryGap = false
31 |
32 | expect(trueBoundaryGap.jsonString).to(equal(enableBoundaryGap.jsonString))
33 | expect(falseBoundaryGap.jsonString).to(equal(disableBoundaryGap.jsonString))
34 | }
35 |
36 | it(" needs to check the Array Literal Constructor ") {
37 | let arrayBoundaryGap: BoundaryGap = [20%, 20%]
38 | let arrayBoundaryGap2: BoundaryGap = [0.5, 23]
39 | let rangeBoundaryGap2 = BoundaryGap.notCategory([0.5, 23])
40 |
41 | expect(arrayBoundaryGap.jsonString).to(equal(rangeBoundaryGap.jsonString))
42 | expect(arrayBoundaryGap2.jsonString).to(equal(rangeBoundaryGap2.jsonString))
43 | }
44 |
45 | }
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/CoordinateSystemSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CoordinateSystemSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 02/07/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | @testable import SwiftyEcharts
12 |
13 | class CoordinateSystemSpec: QuickSpec {
14 | override func spec() {
15 | describe("For CoordinateSystem") {
16 | let cartesian2dString = "cartesian2d"
17 | let polarString = "polar"
18 | let geoString = "geo"
19 | let parallelString = "parallel"
20 | let calendarString = "calendar"
21 | let noneString = "none"
22 |
23 | let cartesian2dCoordinateSystem = CoordinateSystem.cartesian2d
24 | let polarCoordinateSystem = CoordinateSystem.polar
25 | let geoCoordinateSystem = CoordinateSystem.geo
26 | let parallelCoordinateSystem = CoordinateSystem.parallel
27 | let calendarCoordinateSystem = CoordinateSystem.calendar
28 | let noneCoordinateSystem = CoordinateSystem.none
29 |
30 | it("needs to check the jsonString") {
31 | expect(cartesian2dCoordinateSystem.jsonString).to(equal(cartesian2dString.jsonString))
32 | expect(polarCoordinateSystem.jsonString).to(equal(polarString.jsonString))
33 | expect(geoCoordinateSystem.jsonString).to(equal(geoString.jsonString))
34 | expect(parallelCoordinateSystem.jsonString).to(equal(parallelString.jsonString))
35 | expect(calendarCoordinateSystem.jsonString).to(equal(calendarString.jsonString))
36 | expect(noneCoordinateSystem.jsonString).to(equal(noneString.jsonString))
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/DataZoomSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DataZoomSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 09/07/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class DataZoomSpec: QuickSpec {
14 | override func spec() {
15 | describe("For FilterMode") {
16 |
17 | let filterString = "filter"
18 | let emptyString = "empty"
19 |
20 | let filterFilterMode = FilterMode.filter
21 | let emptyFilterMode = FilterMode.empty
22 |
23 | it("needs to check the jsonString") {
24 | expect(filterFilterMode.jsonString).to(equal(filterString.jsonString))
25 | expect(emptyFilterMode.jsonString).to(equal(emptyString.jsonString))
26 | }
27 | }
28 |
29 | describe("For DataZoomAction") {
30 | let typeValue = EchartsActionType.dataZoom
31 | let dataZoomIndexValue = 23487348972398
32 | let startValue: Float = 0.000000
33 | let endValue: Float = 99.999999
34 | let startValueValue: Float = 92372.23894723894
35 | let endValueValue: Float = 2343.02394823
36 |
37 | let dataZoomAction = DataZoomAction()
38 | dataZoomAction.dataZoomIndex = dataZoomIndexValue
39 | dataZoomAction.start = startValue
40 | dataZoomAction.end = endValue
41 | dataZoomAction.startValue = startValueValue
42 | dataZoomAction.endValue = endValueValue
43 |
44 | it("needs to check the type value") {
45 | expect(dataZoomAction.type.jsonString).to(equal(typeValue.jsonString))
46 | }
47 |
48 | it("needs to check the jsonString") {
49 | let resultDic: [String: Jsonable] = [
50 | "type": typeValue,
51 | "dataZoomIndex": dataZoomIndexValue,
52 | "start": startValue,
53 | "end": endValue,
54 | "startValue": startValueValue,
55 | "endValue": endValueValue
56 | ]
57 |
58 | expect(dataZoomAction.jsonString).to(equal(resultDic.jsonString))
59 | }
60 |
61 | it("needs to check the Enumable") {
62 | let dataZoomActionByEnums = DataZoomAction(
63 | .dataZoomIndex(dataZoomIndexValue),
64 | .start(startValue),
65 | .end(endValue),
66 | .startValue(startValueValue),
67 | .endValue(endValueValue)
68 | )
69 |
70 | expect(dataZoomActionByEnums.jsonString).to(equal(dataZoomAction.jsonString))
71 | }
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/DownplayActionSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DownplayActionSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 13/10/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | @testable import SwiftyEcharts
12 |
13 | class DownplayActionSpec: QuickSpec {
14 | override func spec() {
15 | describe("For DownplayAction") {
16 | let typeValue = EchartsActionType.downplay
17 | let seriesIndexOriginValue: Int = 20
18 | let seriesIndexValue = OneOrMore(one: seriesIndexOriginValue)
19 | let seriesNameOriginValue = "higlightActionSeriesName"
20 | let seriesNameValue = OneOrMore(one: seriesNameOriginValue)
21 | let dataIndexValue: Int = Int.max
22 | let nameValue = "downplayActionName"
23 |
24 | let downplayAction = DownplayAction()
25 | downplayAction.seriesName = seriesNameValue
26 | downplayAction.seriesIndex = seriesIndexValue
27 | downplayAction.dataIndex = dataIndexValue
28 | downplayAction.name = nameValue
29 |
30 | it("needs to check the type value") {
31 | expect(downplayAction.type.jsonString).to(equal(typeValue.jsonString))
32 | }
33 |
34 | it("needs to check the jsonString") {
35 | let resultDic: [String: Jsonable] = [
36 | "type": typeValue,
37 | "seriesName": seriesNameValue,
38 | "seriesIndex": seriesIndexValue,
39 | "dataIndex": dataIndexValue,
40 | "name": nameValue
41 | ]
42 | expect(downplayAction.jsonString).to(equal(resultDic.jsonString))
43 | }
44 |
45 | it("needs to check the Enumable") {
46 | let downplayActionByEnums = DownplayAction(
47 | .seriesName(seriesNameOriginValue),
48 | .seriesIndex(seriesIndexOriginValue),
49 | .dataIndex(dataIndexValue),
50 | .name(nameValue)
51 | )
52 |
53 | expect(downplayActionByEnums.jsonString).to(equal(downplayAction.jsonString))
54 | }
55 |
56 | it("needs to check the seriesIndexes and seriesNames enum case") {
57 | let seriesIndexOriginValues: [Int] = [Int.min, Int.max]
58 | let seriesNameOriginValues: [String] = ["seriesName1", "seriesName2", "seriesName3"]
59 |
60 | downplayAction.seriesIndex = OneOrMore(more: seriesIndexOriginValues)
61 | downplayAction.seriesName = OneOrMore(more: seriesNameOriginValues)
62 |
63 | let downplayActionByEnums = DownplayAction(
64 | .seriesNames(seriesNameOriginValues),
65 | .seriesIndexes(seriesIndexOriginValues),
66 | .dataIndex(dataIndexValue),
67 | .name(nameValue)
68 | )
69 |
70 | expect(downplayActionByEnums.jsonString).to(equal(downplayAction.jsonString))
71 | }
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/EnumableSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // EnumableSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 13/07/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | @testable import SwiftyEcharts
12 |
13 | class EnumableSpec: QuickSpec {
14 | override func spec() {
15 | describe("For Enumable") {
16 | it("needs to check the constructor with only one enum") {
17 | let fontFamily = "fontFamilyValue"
18 |
19 | let textStyle = TextStyle()
20 | textStyle.fontFamily = fontFamily
21 |
22 | let textStyleByEnum = TextStyle(
23 | .fontFamily(fontFamily)
24 | )
25 |
26 | expect(textStyleByEnum.jsonString).to(equal(textStyle.jsonString))
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/FontSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // FontSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 30/11/2016.
6 | // Copyright © 2016 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class FontSpec: QuickSpec {
14 |
15 | override func spec() {
16 | describe("For font style ") {
17 |
18 | let normalStyle = FontStyle.normal
19 | let italicStyle = FontStyle.italic
20 | let obliqueStyle = FontStyle.oblique
21 |
22 | it("needs to check the description") {
23 | expect(normalStyle.description).to(equal("normal"))
24 | expect(italicStyle.description).to(equal("italic"))
25 | expect(obliqueStyle.description).to(equal("oblique"))
26 | }
27 | }
28 |
29 | describe("For font weight") {
30 | let weightValue = 100
31 | let valueWeight = FontWeight.weight(weightValue)
32 |
33 | it("needs to check the description") {
34 | let normalWeight = FontWeight.normal
35 | let boldWeight = FontWeight.bold
36 | let bolderWeight = FontWeight.bolder
37 | let lighterWeight = FontWeight.lighter
38 |
39 |
40 | expect(normalWeight.description).to(equal("normal"))
41 | expect(boldWeight.description).to(equal("bold"))
42 | expect(bolderWeight.description).to(equal("bolder"))
43 | expect(lighterWeight.description).to(equal("lighter"))
44 | expect(valueWeight.description).to(equal("\(weightValue)"))
45 | }
46 |
47 | it("needs to create from Int") {
48 | let intWeight: FontWeight = 100
49 | expect(intWeight.description).to(equal(valueWeight.description))
50 |
51 | }
52 |
53 | }
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/FormatterSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // FormatterSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 26/04/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | @testable import SwiftyEcharts
12 |
13 | class FormatterSpec: QuickSpec {
14 | override func spec() {
15 | describe("For Formatter") {
16 | beforeEach {
17 | JsCache.removeAll()
18 | }
19 |
20 | it(" needs to check the jsonString for Formatter ") {
21 | let function: Function = "function (params) {return params[0];}"
22 | let strFormatter: SwiftyEcharts.Formatter = .string("{c}%")
23 | let funcFormatter: SwiftyEcharts.Formatter = .function(function)
24 | expect(strFormatter.jsonString).to(equal("{c}%".jsonString))
25 | expect(funcFormatter.jsonString).to(equal(function.jsonString))
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/FunctionOrOthersSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // FunctionOrOthersSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 20/06/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | @testable import SwiftyEcharts
12 |
13 | class FunctionOrOthersSpec: QuickSpec {
14 |
15 | override func spec() {
16 | let errorJsonString = "null"
17 | let function: Function = "function (idx) {return idx * 0.65;}"
18 | let floatValue: Float = 3.1415
19 | let integerValue: Int = 10
20 |
21 | beforeEach {
22 | JsCache.removeAll()
23 | }
24 |
25 | describe("For FunctionOrFloat") {
26 | it(" needs to check the jsonString ") {
27 | let floatCase = FunctionOrFloat.value(floatValue)
28 | expect(floatCase.jsonString).to(equal(floatValue.jsonString))
29 |
30 | let functionCase = FunctionOrFloat.function(function)
31 | expect(functionCase.jsonString).to(equal(function.jsonString))
32 | }
33 |
34 | it(" needs to check the literal convertible ") {
35 | let floatLiteralCase: FunctionOrFloat = 3.1415
36 | let integerLieteralCase: FunctionOrFloat = 10
37 |
38 | expect(floatLiteralCase.jsonString).to(equal(floatValue.jsonString))
39 | expect(integerLieteralCase.jsonString).to(equal(Float(integerValue).jsonString))
40 | }
41 | }
42 |
43 | describe("For FunctionOrFloatOrPair") {
44 | let arrayLiteralValue: Point = [floatValue, 100%]
45 |
46 | it(" needs to check the jsonString ") {
47 | let floatCase = FunctionOrFloatOrPair.value(floatValue)
48 | expect(floatCase.jsonString).to(equal(floatValue.jsonString))
49 |
50 | let functionCase = FunctionOrFloatOrPair.function(function)
51 | expect(functionCase.jsonString).to(equal(function.jsonString))
52 |
53 | let pointCase = FunctionOrFloatOrPair.point(arrayLiteralValue)
54 | expect(pointCase.jsonString).to(equal(arrayLiteralValue.jsonString))
55 | }
56 |
57 | it(" need to check the literal convertible ") {
58 | let floatLiteralCase: FunctionOrFloatOrPair = 3.1415
59 | let integerLieteralCase: FunctionOrFloatOrPair = 10
60 | let errorArrayLiteralCase: FunctionOrFloatOrPair = [1]
61 | let arrayLiteralCase: FunctionOrFloatOrPair = [floatValue, 100%]
62 |
63 | expect(floatLiteralCase.jsonString).to(equal(floatValue.jsonString))
64 | expect(integerLieteralCase.jsonString).to(equal(Float(integerValue).jsonString))
65 | expect(arrayLiteralCase.jsonString).to(equal(arrayLiteralValue.jsonString))
66 | expect(errorArrayLiteralCase.jsonString).to(equal(errorJsonString))
67 | }
68 | }
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/FunctionSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // FunctionSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 19/09/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | @testable import SwiftyEcharts
12 |
13 | class FunctionSpec: QuickSpec {
14 | override func spec() {
15 | let errorJsonString = "null"
16 | let functionString = "function (idx) {return idx * 0.65;}"
17 | let functionPrefix = "_echartsFunc"
18 |
19 | describe("For Function") {
20 | beforeEach {
21 | JsCache.removeAll()
22 | }
23 |
24 | it("needs to check the prefix string") {
25 | expect(EchartsFunctionPrefix).to(equal(functionPrefix))
26 | }
27 |
28 | it("needs to check the jsonString") {
29 | let nullFunction = Function("null")
30 |
31 | expect(nullFunction.jsonString).to(equal(errorJsonString))
32 | expect(JsCache.allJsStrings().count).to(equal(0))
33 |
34 | let function = Function(functionString)
35 |
36 | expect(function.jsonString).to(equal("\(EchartsFunctionPrefix)0".jsonString))
37 | expect(function.jsonString).to(equal("\(EchartsFunctionPrefix)0".jsonString))
38 | expect(JsCache.allJsStrings().count).to(equal(1))
39 | expect(JsCache.allJsStrings().first).to(equal("var \(EchartsFunctionPrefix)0 = \(functionString);"))
40 | }
41 |
42 | it("needs to check the StringLiteralConvertible") {
43 | let function: Function = "function (idx) {return idx * 0.65;}"
44 |
45 | expect(function.jsonString).to(equal("\(EchartsFunctionPrefix)0".jsonString))
46 | expect(JsCache.allJsStrings().count).to(equal(1))
47 | expect(JsCache.allJsStrings().first).to(equal("var \(EchartsFunctionPrefix)0 = \(functionString);"))
48 | }
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/GraphicStyleSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // GraphicStyleSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 27/06/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class GraphicStyleSpec: QuickSpec {
14 | override func spec() {
15 | describe("For CommonGraphicStyle") {
16 | let fillValue = rgb(125, 33, 225)
17 | let strokeValue = rgba(250, 65, 221, 0.5)
18 | let lineWidthValue: Float = 12.5
19 | let shadowBlurValue: Float = 22.5
20 | let shadowOffsetXValue: Float = 78.5
21 | let shadowOffsetYValue: Float = 0.11
22 | let shadowColorValue = Color.linearGradient(0, 0, 0, 1,
23 | [
24 | ["offset": 0, "color": Color.hexColor("#83bff6")],
25 | ["offset": 0.5, "color": Color.hexColor("#188df0")],
26 | ["offset": 1, "color": Color.hexColor("#188df0")]
27 | ], false)
28 |
29 | let commonGraphicStyle = CommonGraphicStyle()
30 | commonGraphicStyle.fill = fillValue
31 | commonGraphicStyle.stroke = strokeValue
32 | commonGraphicStyle.lineWidth = lineWidthValue
33 | commonGraphicStyle.shadowBlur = shadowBlurValue
34 | commonGraphicStyle.shadowOffsetX = shadowOffsetXValue
35 | commonGraphicStyle.shadowOffsetY = shadowOffsetYValue
36 | commonGraphicStyle.shadowColor = shadowColorValue
37 | let commonGraphicStyleJsonString = commonGraphicStyle.jsonString
38 |
39 | beforeEach {
40 | // 避免 shadowColor 重复添加到 JsCache
41 | JsCache.removeAll()
42 | }
43 |
44 | it("needs to check the jsonString") {
45 | let resultDic: [String: Jsonable] = [
46 | "fill": fillValue,
47 | "stroke": strokeValue,
48 | "lineWidth": lineWidthValue,
49 | "shadowBlur": shadowBlurValue,
50 | "shadowOffsetX": shadowOffsetXValue,
51 | "shadowOffsetY": shadowOffsetYValue,
52 | "shadowColor": shadowColorValue
53 | ]
54 |
55 | expect(commonGraphicStyleJsonString).to(equal(resultDic.jsonString))
56 | }
57 |
58 | it("needs to check the Enumable") {
59 | let commonGraphicStyleByEnums = CommonGraphicStyle(
60 | .fill(fillValue),
61 | .stroke(strokeValue),
62 | .lineWidth(lineWidthValue),
63 | .shadowBlur(shadowBlurValue),
64 | .shadowOffsetX(shadowOffsetXValue),
65 | .shadowOffsetY(shadowOffsetYValue),
66 | .shadowColor(shadowColorValue)
67 | )
68 |
69 | expect(commonGraphicStyleByEnums.jsonString).to(equal(commonGraphicStyleJsonString))
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/GraphicTypeSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // GraphicTypeSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 27/06/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | @testable import SwiftyEcharts
12 |
13 | class GraphicTypeSpec: QuickSpec {
14 | override func spec() {
15 | describe("For GraphicType") {
16 | let groupString = "group"
17 | let imageString = "image"
18 | let textString = "text"
19 | let rectString = "rect"
20 | let circleString = "circle"
21 | let ringString = "ring"
22 | let sectorString = "sector"
23 | let arcString = "arc"
24 | let polygonString = "polygon"
25 | let polylineString = "polyline"
26 | let lineString = "line"
27 | let bezierCurveString = "bezierCurve"
28 |
29 | let groupGraphicType = GraphicType.group
30 | let imageGraphicType = GraphicType.image
31 | let textGraphicType = GraphicType.text
32 | let rectGraphicType = GraphicType.rect
33 | let circleGraphicType = GraphicType.circle
34 | let ringGraphicType = GraphicType.ring
35 | let sectorGraphicType = GraphicType.sector
36 | let arcGraphicType = GraphicType.arc
37 | let polygonGraphicType = GraphicType.polygon
38 | let polylineGraphicType = GraphicType.polyline
39 | let lineGraphicType = GraphicType.line
40 | let bezierCurveGraphicType = GraphicType.bezierCurve
41 |
42 | it("needs to check the jsonString") {
43 | expect(groupGraphicType.jsonString).to(equal(groupString.jsonString))
44 | expect(imageGraphicType.jsonString).to(equal(imageString.jsonString))
45 | expect(textGraphicType.jsonString).to(equal(textString.jsonString))
46 | expect(rectGraphicType.jsonString).to(equal(rectString.jsonString))
47 | expect(circleGraphicType.jsonString).to(equal(circleString.jsonString))
48 | expect(ringGraphicType.jsonString).to(equal(ringString.jsonString))
49 | expect(sectorGraphicType.jsonString).to(equal(sectorString.jsonString))
50 | expect(arcGraphicType.jsonString).to(equal(arcString.jsonString))
51 | expect(polygonGraphicType.jsonString).to(equal(polygonString.jsonString))
52 | expect(polylineGraphicType.jsonString).to(equal(polylineString.jsonString))
53 | expect(lineGraphicType.jsonString).to(equal(lineString.jsonString))
54 | expect(bezierCurveGraphicType.jsonString).to(equal(bezierCurveString.jsonString))
55 | }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/HighlightActionSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // HighlightActionSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 13/10/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | @testable import SwiftyEcharts
12 |
13 | class HighlightActionSpec: QuickSpec {
14 | override func spec() {
15 | describe("For HighlightAction") {
16 | let typeValue = EchartsActionType.highlight
17 | let seriesIndexOriginValue: Int = 20
18 | let seriesIndexValue = OneOrMore(one: seriesIndexOriginValue)
19 | let seriesNameOriginValue = "higlightActionSeriesName"
20 | let seriesNameValue = OneOrMore(one: seriesNameOriginValue)
21 | let dataIndexValue: Int = Int.max
22 | let nameValue = "highlightActionName"
23 |
24 | let highlightAction = HighlightAction()
25 | highlightAction.seriesName = seriesNameValue
26 | highlightAction.seriesIndex = seriesIndexValue
27 | highlightAction.dataIndex = dataIndexValue
28 | highlightAction.name = nameValue
29 |
30 | it("needs to check the type value") {
31 | expect(highlightAction.type.jsonString).to(equal(typeValue.jsonString))
32 | }
33 |
34 | it("needs to check the jsonString") {
35 | let resultDic: [String: Jsonable] = [
36 | "type": typeValue,
37 | "seriesName": seriesNameValue,
38 | "seriesIndex": seriesIndexValue,
39 | "dataIndex": dataIndexValue,
40 | "name": nameValue
41 | ]
42 | expect(highlightAction.jsonString).to(equal(resultDic.jsonString))
43 | }
44 |
45 | it("needs to check the Enumable") {
46 | let highlightActionByEnums = HighlightAction(
47 | .seriesName(seriesNameOriginValue),
48 | .seriesIndex(seriesIndexOriginValue),
49 | .dataIndex(dataIndexValue),
50 | .name(nameValue)
51 | )
52 |
53 | expect(highlightActionByEnums.jsonString).to(equal(highlightAction.jsonString))
54 | }
55 |
56 | it("needs to check the seriesIndexes and seriesNames enum case") {
57 | let seriesIndexOriginValues: [Int] = [Int.min, Int.max]
58 | let seriesNameOriginValues: [String] = ["seriesName1", "seriesName2", "seriesName3"]
59 |
60 | highlightAction.seriesIndex = OneOrMore(more: seriesIndexOriginValues)
61 | highlightAction.seriesName = OneOrMore(more: seriesNameOriginValues)
62 |
63 | let highlightActionByEnums = HighlightAction(
64 | .seriesNames(seriesNameOriginValues),
65 | .seriesIndexes(seriesIndexOriginValues),
66 | .dataIndex(dataIndexValue),
67 | .name(nameValue)
68 | )
69 |
70 | expect(highlightActionByEnums.jsonString).to(equal(highlightAction.jsonString))
71 | }
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/JsCacheSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // JsCacheSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 22/05/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class JsCacheSpec: QuickSpec {
14 | override func spec() {
15 | describe("For JsCache") {
16 | it("needs to check the methods") {
17 | let jsString1 = "function (idx) {return idx * 100;};"
18 | let jsString2 = "function (idx) {return idx * 0.65;};"
19 |
20 | JsCache.removeAll()
21 |
22 | JsCache.add(jsString1)
23 | expect(JsCache.allJsStrings()).to(equal([jsString1]))
24 | expect(JsCache.contain(jsString1)).to(beTrue())
25 | expect(JsCache.contain(jsString2)).to(beFalse())
26 |
27 | JsCache.add(jsString2)
28 | expect(JsCache.allJsStrings()).to(equal([jsString1, jsString2]))
29 | expect(JsCache.contain(jsString1)).to(beTrue())
30 | expect(JsCache.contain(jsString2)).to(beTrue())
31 |
32 | JsCache.removeAll()
33 | expect(JsCache.allJsStrings()).to(equal([]))
34 | expect(JsCache.contain(jsString1)).to(beFalse())
35 | expect(JsCache.contain(jsString2)).to(beFalse())
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/LengthValueSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // LengthValueSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 08/05/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class LengthValueSpec: QuickSpec {
14 |
15 | override func spec() {
16 | describe("For Length") {
17 |
18 | it(" needs to check all the type which conform to length value ") {
19 | // Float
20 | let floatLength: LengthValue = 3.14
21 | // Double
22 | let intLength: LengthValue = 5
23 | // Double
24 | let doubleLength: LengthValue = 10.0
25 | // Percent
26 | let percentLength: LengthValue = 20.5%
27 |
28 | expect(floatLength.jsonString).to(equal(3.14.jsonString))
29 | expect(intLength.jsonString).to(equal(5.jsonString))
30 | expect(doubleLength.jsonString).to(equal(10.0.jsonString))
31 | expect(percentLength.jsonString).to(equal((20.5%).jsonString))
32 | }
33 |
34 | }
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/LineSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // LineSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 24/04/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class LineSpec: QuickSpec {
14 |
15 | override func spec() {
16 | describe("For line type enum") {
17 | let solidType: LineType = .solid
18 | let dashType: LineType = .dashed
19 | let dottedType: LineType = .dotted
20 |
21 | expect(solidType.jsonString).to(equal("solid".jsonString))
22 | expect(dashType.jsonString).to(equal("dashed".jsonString))
23 | expect(dottedType.jsonString).to(equal("dotted".jsonString))
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/MapperSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // MapperSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 25/06/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | @testable import SwiftyEcharts
12 |
13 | class MapperSpec: QuickSpec {
14 | override func spec() {
15 | describe("For Mapper") {
16 | let firstElement = "World"
17 | let secondElement = 3.14
18 | let thirdElement = 4
19 | let fourthElement: Jsonable? = nil
20 | let finalElement = false
21 | let oneValue = "Hello"
22 | let mapper = Mapper()
23 | mapper.mapDic["firstElement"] = firstElement
24 | mapper.mapDic["secondElement"] = secondElement
25 | mapper.mapDic["thirdElement"] = thirdElement
26 | mapper.mapDic["fourthElement"] = fourthElement
27 | mapper.mapDic["finalElement"] = finalElement
28 | mapper.mapDic["oneValue"] = oneValue
29 |
30 | let resultWithoutNil: [String: Jsonable] = [
31 | "firstElement": firstElement,
32 | "secondElement": secondElement,
33 | "thirdElement": thirdElement,
34 | "finalElement": finalElement,
35 | "oneValue": oneValue
36 | ]
37 |
38 | let resultWithNig: [String: Jsonable?] = [
39 | "firstElement": firstElement,
40 | "secondElement": secondElement,
41 | "thirdElement": thirdElement,
42 | "fourthElement": fourthElement,
43 | "finalElement": finalElement,
44 | "oneValue": oneValue
45 | ]
46 |
47 | it("needs to check the ignoreNil and jsonString") {
48 | let originIgnoreNil = Mapper.ignoreNil
49 |
50 | Mapper.ignoreNil = false
51 | expect(mapper.jsonString).to(equal(resultWithNig.jsonString))
52 |
53 | Mapper.ignoreNil = true
54 | expect(mapper.jsonString).to(equal(resultWithoutNil.jsonString))
55 |
56 | Mapper.ignoreNil = originIgnoreNil
57 | }
58 |
59 | it("needs to check the subscript") {
60 | let newFirstElement = "One"
61 | let newSecondElement: Float = 6.66
62 | let newThirdElement: Jsonable? = nil
63 |
64 | mapper["firstElement"] = newFirstElement
65 | expect(mapper["firstElement"] as? String).notTo(beNil())
66 | expect(mapper["firstElement"] as? String).to(equal(newFirstElement))
67 |
68 | mapper["secondElement"] = newSecondElement
69 | expect(mapper["secondElement"] as? Float).notTo(beNil())
70 | expect(mapper["secondElement"] as? Float).to(equal(newSecondElement))
71 |
72 | mapper["thirdElement"] = newThirdElement
73 | expect(mapper["thirdElement"]).to(beNil())
74 |
75 | expect(mapper["noThisKey"]).to(beNil())
76 | }
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/MarkAreaSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // MarkAreaSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 25/07/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | @testable import SwiftyEcharts
12 |
13 | class MarkAreaSpec: QuickSpec {
14 | override func spec() {
15 | describe("For MarkArea") {
16 | let silentValue = true
17 | let labelValue = EmphasisLabel(
18 | .emphasis(LabelStyle(
19 | .show(false),
20 | .position(Position.insideBottomLeft)
21 | ))
22 | )
23 | let itemStyleValue = ItemStyle(
24 | .normal(CommonItemStyleContent(
25 | .areaColor(rgba(28, 94, 174, 0.2873)),
26 | .shadowOffsetX(283.8),
27 | .borderWidth(2)
28 | ))
29 | )
30 | let dataValue: [Jsonable] = [
31 | ["avg": "最大值"],
32 | "false",
33 | true,
34 | 283.82
35 | ]
36 | let animationValue = false
37 | let animationThresholdValue: Float = 82.375
38 | let animationDurationValue: Time = 1000
39 | let animationEasingValue = EasingFunction.elasticIn
40 | let animationDelayValue: Time = 3832
41 | let animationDurationUpdateValue: Time = 28.372
42 | let animationEasingUpdateValue = EasingFunction.backIn
43 | let animationDelayUpdateValue = Time.init(floatLiteral: 28.482)
44 |
45 | let markArea = MarkArea()
46 | markArea.silent = silentValue
47 | markArea.label = labelValue
48 | markArea.itemStyle = itemStyleValue
49 | markArea.data = dataValue
50 | markArea.animation = animationValue
51 | markArea.animationThreshold = animationThresholdValue
52 | markArea.animationDuration = animationDurationValue
53 | markArea.animationEasing = animationEasingValue
54 | markArea.animationDelay = animationDelayValue
55 | markArea.animationDurationUpdate = animationDurationUpdateValue
56 | markArea.animationEasingUpdate = animationEasingUpdateValue
57 | markArea.animationDelayUpdate = animationDelayUpdateValue
58 |
59 | it("needs to check the jsonString") {
60 | let resultDic: [String: Jsonable] = [
61 | "silent": silentValue,
62 | "label": labelValue,
63 | "itemStyle": itemStyleValue,
64 | "data": dataValue,
65 | "animation": animationValue,
66 | "animationThreshold": animationThresholdValue,
67 | "animationDuration": animationDurationValue,
68 | "animationEasing": animationEasingValue,
69 | "animationDelay": animationDelayValue,
70 | "animationDurationUpdate": animationDurationUpdateValue,
71 | "animationEasingUpdate": animationEasingUpdateValue,
72 | "animationDelayUpdate": animationDelayUpdateValue
73 | ]
74 |
75 | expect(markArea.jsonString).to(equal(resultDic.jsonString))
76 | }
77 |
78 | it("needs to check the Enumable") {
79 | let markAreaByEnums = MarkArea(
80 | .silent(silentValue),
81 | .label(labelValue),
82 | .itemStyle(itemStyleValue),
83 | .data(dataValue),
84 | .animation(animationValue),
85 | .animationThreshold(animationThresholdValue),
86 | .animationDuration(animationDurationValue),
87 | .animationEasing(animationEasingValue),
88 | .animationDelay(animationDelayValue),
89 | .animationDurationUpdate(animationDurationUpdateValue),
90 | .animationEasingUpdate(animationEasingUpdateValue),
91 | .animationDelayUpdate(animationDelayUpdateValue)
92 | )
93 |
94 | expect(markAreaByEnums.jsonString).to(equal(markArea.jsonString))
95 | }
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/MarkDataTypeSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // MarkDataTypeSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 26/06/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class MarkDataTypeSpec: QuickSpec {
14 | override func spec() {
15 | describe("For MarkDataType") {
16 | it("needs to check the jsonString") {
17 | let minString = "min"
18 | let maxString = "max"
19 | let averageString = "average"
20 |
21 | let minMarkDataType = MarkDataType.min
22 | let maxMarkDataType = MarkDataType.max
23 | let avgMarkDataType = MarkDataType.average
24 |
25 | expect(minMarkDataType.jsonString).to(equal(minString.jsonString))
26 | expect(maxMarkDataType.jsonString).to(equal(maxString.jsonString))
27 | expect(avgMarkDataType.jsonString).to(equal(averageString.jsonString))
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/OneOrMoreSepc.swift:
--------------------------------------------------------------------------------
1 | //
2 | // OneOrMoreSepc.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 20/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class OneOrMoreSepc: QuickSpec {
14 |
15 | override func spec() {
16 | describe("Testing for type named 'OneOrMore' ") {
17 | let firstElement = "World"
18 | let secondElement = 3.14
19 | let thirdElement = 4
20 | let finalElement = false
21 | let oneValue = "Hello"
22 | let moreValue: [Any] = [firstElement, secondElement, thirdElement, finalElement]
23 | it("needs to check the construct and jsonString") {
24 | // 测试默认构造器以及 jsonString 是否正确
25 | let one = OneOrMore(one: oneValue)
26 | expect(one.jsonString).to(equal(oneValue.jsonString))
27 |
28 | // 测试默认构造器以及 jsonString 是否正确
29 | let more = OneOrMore(more: moreValue)
30 | expect(more.jsonString).to(equal(moreValue.jsonString))
31 |
32 | // 测试默认数组只有一个元素的情况
33 | let onlyOneElements = OneOrMore(more: [firstElement])
34 | expect(onlyOneElements.jsonString).to(equal(firstElement.jsonString))
35 | expect(onlyOneElements.jsonString).notTo(equal([firstElement].jsonString))
36 |
37 | // 测试另一个构造器的情况
38 | let onlyOneElements2 = OneOrMore(arrayLiteral: firstElement)
39 | expect(onlyOneElements2.jsonString).to(equal(firstElement.jsonString))
40 | expect(onlyOneElements2.jsonString).notTo(equal([firstElement].jsonString))
41 | }
42 |
43 | // 测试数组常量的构造器
44 | it("needs to check the ArrayLiteralConvertible") {
45 | let more: OneOrMore = [firstElement, secondElement, thirdElement, finalElement]
46 | expect(more.jsonString).to(equal(moreValue.jsonString))
47 |
48 | let more1: OneOrMore = []
49 | let emptyArray: Array = []
50 | expect(more1.jsonString).to(equal(emptyArray.jsonString))
51 | }
52 |
53 | it("needs to check the subscript ") {
54 | // 测试下标是否能其作用
55 | expect(moreValue[0] as? String).to(equal(firstElement))
56 | expect(moreValue[1] as? Double).to(equal(secondElement))
57 | expect(moreValue[2] as? Int).to(equal(thirdElement))
58 | expect(moreValue[3] as? Bool).to(equal(finalElement))
59 |
60 | let intValue = 10
61 | let intValue2 = 18
62 | let oneInt = OneOrMore(one: intValue)
63 | expect(oneInt[0]).to(equal(intValue))
64 | expect(oneInt[1]).to(beNil())
65 |
66 | let moreInts = OneOrMore(more: [intValue, intValue2])
67 | expect(moreInts[0]).to(equal(intValue))
68 | expect(moreInts[1]).to(equal(intValue2))
69 | }
70 |
71 | }
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/OpacitableSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // OpacitableSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 25/06/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class OpacitableSpec: QuickSpec {
14 |
15 | private class OpacitableClass: Opacitable {
16 | var opacity: Float?
17 | }
18 |
19 | override func spec() {
20 | describe("For Opacitable") {
21 | let opacitableInstance = OpacitableClass()
22 |
23 | it("needs to check the validate function") {
24 | opacitableInstance.opacity = 0.0
25 | expect(opacitableInstance.validateOpacity()).to(equal(true))
26 | expect(opacitableInstance.opacity).to(equal(0.0))
27 | opacitableInstance.opacity = -0.01
28 | expect(opacitableInstance.validateOpacity()).to(equal(false))
29 | expect(opacitableInstance.opacity).to(equal(0.0))
30 | opacitableInstance.opacity = 0.99
31 | expect(opacitableInstance.validateOpacity()).to(equal(true))
32 | expect(opacitableInstance.opacity).to(equal(0.99))
33 | opacitableInstance.opacity = 1.0
34 | expect(opacitableInstance.validateOpacity()).to(equal(true))
35 | expect(opacitableInstance.opacity).to(equal(1.0))
36 | opacitableInstance.opacity = 1.01
37 | expect(opacitableInstance.validateOpacity()).to(equal(false))
38 | expect(opacitableInstance.opacity).to(equal(1.0))
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/OrientSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // OrientSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 07/05/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class OrientSpec: QuickSpec {
14 |
15 | override func spec() {
16 |
17 | describe("For Orient") {
18 |
19 | it(" needs to check the jsonString for the Orient") {
20 | let vertical = Orient.vertical
21 | let horizontal = Orient.horizontal
22 |
23 | expect(vertical.jsonString).to(equal("vertical".jsonString))
24 | expect(horizontal.jsonString).to(equal("horizontal".jsonString))
25 | }
26 |
27 | }
28 |
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/PaddingSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // PaddingSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 08/05/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class PaddingSpec: QuickSpec {
14 |
15 | override func spec() {
16 | describe("For Padding") {
17 |
18 | let allPadding = Padding.all(5.0)
19 | let allPadding2 = Padding.all(10)
20 | let verticalAndHorizontalPadding = Padding.verticalAndHorizontal(2.5, 10.2)
21 | let tlbrPadding = Padding.trbl(2.3, 3.14, 6.9, 2.7)
22 | let nullPadding = Padding.null
23 | it(" needs to check the jsonString ") {
24 | expect(allPadding.jsonString).to(equal("5.0"))
25 | expect(verticalAndHorizontalPadding.jsonString).to(equal("[2.5, 10.2]"))
26 | expect(tlbrPadding.jsonString).to(equal("[2.3, 3.14, 6.9, 2.7]"))
27 | expect(nullPadding.jsonString).to(equal("null"))
28 | }
29 |
30 | it(" needs to check the literal constructor ") {
31 | let floatPadding: Padding = 5.0
32 | let intPadding: Padding = 10
33 | let oneElementPadding: Padding = [5]
34 | let twoElementsPadding:Padding = [2.5, 10.2]
35 | let fourElementsPadding: Padding = [2.3, 3.14, 6.9, 2.7]
36 | let errorElemntPadding: Padding = [2.3, 5.2, 222]
37 |
38 | expect(floatPadding.jsonString).to(equal(allPadding.jsonString))
39 | expect(intPadding.jsonString).to(equal(allPadding2.jsonString))
40 | expect(oneElementPadding.jsonString).to(equal(allPadding.jsonString))
41 | expect(twoElementsPadding.jsonString).to(equal(verticalAndHorizontalPadding.jsonString))
42 | expect(fourElementsPadding.jsonString).to(equal(tlbrPadding.jsonString))
43 | expect(errorElemntPadding.jsonString).to(equal(nullPadding.jsonString))
44 |
45 | }
46 |
47 | }
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/PairSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // PairSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 15/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class PairSpec: QuickSpec {
14 |
15 | override func spec() {
16 |
17 | describe("Testing for type named 'SECTwoElement'") {
18 |
19 | it(" needs to check constructor and jsonString ") {
20 | let errorJsonString = "null"
21 | let noArgElements = Pair()
22 |
23 | expect(noArgElements.jsonString).to(equal(errorJsonString))
24 |
25 | let percentValue: Float = 3
26 | let floatValue: Float = 2.1
27 | let twoElements: Pair = [floatValue, percentValue%]
28 |
29 | expect(twoElements.jsonString).to(equal([floatValue, percentValue%].jsonString))
30 |
31 | let toMuchElements: Pair = [3, 4, 5, 6%]
32 | expect(toMuchElements.jsonString).to(equal(errorJsonString))
33 |
34 | let errorElements = Pair([floatValue])
35 | expect(errorElements.jsonString).to(equal(errorJsonString))
36 |
37 | // 如果不是 LengthValue 的话,就会产生编译错误
38 | // let errorType: Pair = ["hello", 4]
39 | }
40 |
41 | }
42 |
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/PercentSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // PercentSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 15/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class PercentSpec: QuickSpec {
14 | override func spec() {
15 | describe("Testing for type named 'Percent'") {
16 |
17 | it(" needs to check jsonString ") {
18 | let value = Double(Float(arc4random()) / Float(UINT32_MAX))
19 | let percent = Percent(value)
20 | let formatStr = String(format: "%%.%df", Percent.precision)
21 | expect(percent.jsonString).to(equal("\"\(String(format: formatStr, value))%\""))
22 | }
23 |
24 | it(" needs to support for 'num%' format constructor") {
25 | // 检查 Double + %
26 | let percent: Percent = 32.0%
27 | expect(percent.jsonString).to(equal("\"32.00%\""))
28 | // 检查 Float + %
29 | let percentFloat = Float(23.6)%
30 | expect(percentFloat.jsonString).to(equal("\"23.60%\""))
31 | // 检查 Int + %
32 | let percentInt = 10%
33 | expect(percentInt.jsonString).to(equal("\"10.00%\""))
34 | }
35 |
36 |
37 | it(" needs to check the precision for Percent") {
38 | // 检查精度问题
39 | let originPrecision = Percent.precision
40 |
41 | let precision = 4
42 | Percent.precision = precision
43 | let formatStr = String(format: "%%.%df", precision)
44 | let value = 78.9012345
45 | let percent: Percent = value%
46 | expect(percent.jsonString).to(equal("\"\(String(format: formatStr, value))%\""))
47 |
48 | Percent.precision = originPrecision
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/PolarSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // PolarSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 01/08/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | @testable import SwiftyEcharts
12 |
13 | class PolarSpec: QuickSpec {
14 | override func spec() {
15 | describe("For Polar") {
16 | let zlevelValue: Float = 85.72
17 | let zValue: Float = 1.01
18 | let centerValue: Point = [50%, 50%]
19 | let radiusValue: SwiftyEcharts.Range = [10, 85]
20 |
21 | let polar = Polar()
22 | polar.zlevel = zlevelValue
23 | polar.z = zValue
24 | polar.center = centerValue
25 | polar.radius = radiusValue
26 |
27 | it("needs to check the jsonString") {
28 | let resultDic: [String: Jsonable] = [
29 | "zlevel": zlevelValue,
30 | "z": zValue,
31 | "center": centerValue,
32 | "radius": radiusValue
33 | ]
34 |
35 | expect(polar.jsonString).to(equal(resultDic.jsonString))
36 | }
37 |
38 | it("needs to check the Enumable") {
39 | let polarByEnums = Polar(
40 | .zlevel(zlevelValue),
41 | .z(zValue),
42 | .center(centerValue),
43 | .radius(radiusValue)
44 | )
45 |
46 | expect(polarByEnums.jsonString).to(equal(polar.jsonString))
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/RoamSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // RoamSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 02/05/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class RoamSpec: QuickSpec {
14 |
15 | override func spec() {
16 | describe("For Roam jsonString") {
17 | let enableRoam = Roam.enable
18 | let disableRoam = Roam.disable
19 | it(" needs to check the jsonString for the Roam") {
20 | let scaleRoam = Roam.scale
21 | let zoomRoam = Roam.zoom
22 | let moveRoam = Roam.move
23 | let panRoam = Roam.pan
24 |
25 | expect(enableRoam.jsonString).to(equal("true"))
26 | expect(disableRoam.jsonString).to(equal("false"))
27 | expect(scaleRoam.jsonString).to(equal("scale".jsonString))
28 | expect(scaleRoam.jsonString).to(equal("scale".jsonString))
29 | expect(zoomRoam.jsonString).to(equal("zoom".jsonString))
30 | expect(moveRoam.jsonString).to(equal("move".jsonString))
31 | expect(panRoam.jsonString).to(equal("pan".jsonString))
32 | }
33 |
34 | it(" needs to check constructor for Bool") {
35 | let trueRoam: Roam = true
36 | let falseRoam: Roam = false
37 |
38 | expect(enableRoam.jsonString).to(equal(trueRoam.jsonString))
39 | expect(disableRoam.jsonString).to(equal(falseRoam.jsonString))
40 | }
41 | }
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/SelectedModeSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SelectedModeSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 10/03/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class SelectedModeSpec: QuickSpec {
14 |
15 | override func spec() {
16 |
17 | describe("For SelectedMode") {
18 | let enableMode: SelectedMode = .enable
19 | let disableMode: SelectedMode = .disable
20 | let singleMode: SelectedMode = .single
21 | let multipMode: SelectedMode = .multiple
22 |
23 | let trueLiteralMode: SelectedMode = true
24 | let falseLiteralMode: SelectedMode = false
25 |
26 | it(" needs to check the BooleanLiteral Constructor") {
27 | expect(trueLiteralMode.rawValue).to(equal(enableMode.rawValue))
28 | expect(falseLiteralMode.rawValue).to(equal(disableMode.rawValue))
29 | expect(trueLiteralMode.jsonString).to(equal("true"))
30 | expect(falseLiteralMode.jsonString).to(equal("false"))
31 | }
32 |
33 | it(" needs to check the jsonString ") {
34 | expect(enableMode.jsonString).to(equal("true"))
35 | expect(disableMode.jsonString).to(equal("false"))
36 | expect(singleMode.jsonString).to(equal("\"single\""))
37 | expect(multipMode.jsonString).to(equal("\"multiple\""))
38 | }
39 |
40 | }
41 |
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/ShadowStyleSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ShadowStyleSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 03/08/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | @testable import SwiftyEcharts
12 |
13 | class ShadowStyleSpec: QuickSpec {
14 | override func spec() {
15 | describe("For ShadowStyle") {
16 | let colorValue = rgb(128, 128, 128)
17 | let shadowBlurValue: Float = 10
18 | let shadowColorValue = Color.hexColor("#ff00ff")
19 | let shadowOffsetXValue: Float = 85.273
20 | let shadowOffsetYValue: Float = 0.9472
21 | let opacityValue: Float = 0.572
22 |
23 | let shadowStyle = ShadowStyle()
24 | shadowStyle.color = colorValue
25 | shadowStyle.shadowBlur = shadowBlurValue
26 | shadowStyle.shadowColor = shadowColorValue
27 | shadowStyle.shadowOffsetX = shadowOffsetXValue
28 | shadowStyle.shadowOffsetY = shadowOffsetYValue
29 | shadowStyle.opacity = opacityValue
30 |
31 |
32 | it("needs to check the jsonString") {
33 | let resultDic: [String: Jsonable] = [
34 | "color": colorValue,
35 | "shadowBlur": shadowBlurValue,
36 | "shadowColor": shadowColorValue,
37 | "shadowOffsetX": shadowOffsetXValue,
38 | "shadowOffsetY": shadowOffsetYValue,
39 | "opacity": opacityValue
40 | ]
41 |
42 | expect(shadowStyle.jsonString).to(equal(resultDic.jsonString))
43 | }
44 |
45 | it("needs to check the Enumable") {
46 | let shadowStyleByEnums = ShadowStyle(
47 | .color(colorValue),
48 | .shadowBlur(shadowBlurValue),
49 | .shadowColor(shadowColorValue),
50 | .shadowOffsetX(shadowOffsetXValue),
51 | .shadowOffsetY(shadowOffsetYValue),
52 | .opacity(opacityValue)
53 | )
54 |
55 | expect(shadowStyleByEnums.jsonString).to(equal(shadowStyle.jsonString))
56 | }
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/SplitAreaSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SplitAreaSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 28/06/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | @testable import SwiftyEcharts
12 |
13 | class SplitAreaSpec: QuickSpec {
14 | override func spec() {
15 | describe("For SplitArea") {
16 | let showValue = true
17 | let intervalValue: UInt = 12
18 | let areaStyleValue = AreaStyle(
19 | .color(.array([.rgba(114, 172, 209, 0.2), .rgba(114, 172, 209, 0.4), .rgba(114, 172, 209, 0.6), .rgba(114, 172, 209, 0.8), .rgba(114, 172, 209, 1)])),
20 | .shadowColor(.rgba(0, 0, 0, 0.3)),
21 | .shadowBlur(10)
22 | )
23 |
24 | let splitArea = SplitArea()
25 | splitArea.show = showValue
26 | splitArea.interval = intervalValue
27 | splitArea.areaStyle = areaStyleValue
28 |
29 | it("needs to check the jsonString") {
30 | let resultDic: [String: Jsonable] = [
31 | "show": showValue,
32 | "interval": intervalValue,
33 | "areaStyle": areaStyleValue
34 | ]
35 |
36 | expect(splitArea.jsonString).to(equal(resultDic.jsonString))
37 | }
38 |
39 | it("needs to check the Enumable") {
40 | let splitAreaByEnums = SplitArea(
41 | .show(showValue),
42 | .interval(intervalValue),
43 | .areaStyle(areaStyleValue)
44 | )
45 |
46 | expect(splitAreaByEnums.jsonString).to(equal(splitArea.jsonString))
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/SplitLineSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SplitLineSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 22/06/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | @testable import SwiftyEcharts
12 |
13 | class SplitLineSpec: QuickSpec {
14 | override func spec() {
15 | describe("For SplitLine") {
16 |
17 | let showValue = false
18 | let intervalValue: LengthValue = 2
19 | let lengthValue = 20%
20 | let lineStyleValue = LineStyle(
21 | .color(Color.red),
22 | .width(30),
23 | .type(.dotted),
24 | .opacity(0.88),
25 | .shadowBlur(0.65),
26 | .shadowColor("#fff"),
27 | .shadowOffsetX(16.5),
28 | .shadowOffsetY(8.9992),
29 | .curveness(0.72)
30 | )
31 |
32 | let splitLine = SplitLine()
33 | splitLine.show = showValue
34 | splitLine.interval = intervalValue
35 | splitLine.length = lengthValue
36 | splitLine.lineStyle = lineStyleValue
37 |
38 | it("needs to check the jsonString") {
39 | let resultDic: [String: Jsonable] = [
40 | "show": showValue,
41 | "interval": intervalValue,
42 | "length": lengthValue,
43 | "lineStyle": lineStyleValue
44 | ]
45 |
46 | expect(splitLine.jsonString).to(equal(resultDic.jsonString))
47 | }
48 |
49 | it("needs to check the Enumable") {
50 | let splitLineByEnums = SplitLine(
51 | .show(showValue),
52 | .interval(intervalValue),
53 | .length(lengthValue),
54 | .lineStyle(lineStyleValue)
55 | )
56 |
57 | expect(splitLineByEnums.jsonString).to(equal(splitLine.jsonString))
58 | }
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/SymbolSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SymbolSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 03/05/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class SymbolSpec: QuickSpec {
14 | override func spec() {
15 | describe("For enum named `Symbol`") {
16 | it("needs to check the support enum") {
17 | let imageString = "image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAA2CAYAAADUOvnEAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA5tJREFUeNrcWE1oE0EUnp0kbWyUpCiNYEpCFSpIMdpLRTD15s2ePHixnj00N4/GoyfTg2fbiwdvvagHC1UQ66GQUIQKKgn1UAqSSFua38b3prPJZDs7s5ufKn0w7CaZ2W/fe9/73kyMRqNB3Nrj1zdn4RJ6du9T2u1a2iHYSxjP4d41oOHGQwAIwSUHIyh8/RA8XeiXh0kLGFoaXiTecw/hoTG4ZCSAaFkY0+BpsZceLtiAoV2FkepZSDk5EpppczBvpuuQCqx0YnkYcVVoqQYMyeCG+lFdaGkXeVOFNu4aEBalOBk6sbQrQF7gSdK5JXjuHXuYVIVyr0TZ0FjKDeCs6km7JYMUdrWAUVmZUBtmRnVPK+x6nIR2xomH06R35ggwJPeofWphr/W5UjPIxq8B2bKgE8C4HVHWvg+2gZjXj19PkdFztY7bk9TDCH/g6oafDPpaoMvZIRI5WyMB/0Hv++HkpTKE0kM+A+h20cPAfN4GuRyp9G+LMTW+z8rCLI8b46XO9zRcYZTde/j0AZm8WGb3Y2F9KLlE2nqYkjFLJAsDOl/lea0q55mqxXcL7YBc++bsCPMe8mUyU2ZIpnCoblca6TZA/ga2Co8PGg7UGUlEDd0ueptglbrRZLLE7poti6pCaWUo2pu1oaYI1CF9b9cCZPO3F8ikJQ/rPpQT5YETht26ss+uCIL2Y8vHwJGpA96GI5mjOlaKhowUy6BcNcgIhDviTGWCGFaqEuufWz4pgcbCh+w0gEOyOjTlTtYYlIWPYWKEsLDzOs+nhzaO1KEpd+MXpOoTUgKiNyhdy5aSMPNVqxtSsJFgza5EWA4zKtCJ2OGbLn0JSLu8+SL4G86p1Fpr7ABXdGFF/UTD4rfmFYFw4G9VAJ9SM3aF8l3yok4/J6IV9sDVb36ynmtJ2M5+CwxTYBdKNMBaocKGV2nYgkz6r+cHBP30MzAfi4Sy+BebSoPIOi8PW1PpCCvr/KOD4k9Zu0WSH0Y0+SxJ2awp/nlwKtcGyHOJ8vNHtRJzhPlsHr8MogtlVtwUU0tSM1x58upSKbfJnSKUR07GVMKkDNfXpzpv0RTHy3nZMVx5IOWdZIaPabGFvfpwpjnvfmJHXLaEvZUTseu/TeLc+xgAPhEAb/PbjO6PBaOTf6LQRh/dERde23zxLtOXbaKNhfq2L/1fAOPHDUhOpIf5485h7l+GNHHiSYPKE3Myz9sFxoJuAyazvwIMAItferha5LTqAAAAAElFTkSuQmCC"
18 | let pathString = "path://M1705.06,1318.313v-89.254l-319.9-221.799l0.073-208.063c0.521-84.662-26.629-121.796-63.961-121.491c-37.332-0.305-64.482,36.829-63.961,121.491l0.073,208.063l-319.9,221.799v89.254l330.343-157.288l12.238,241.308l-134.449,92.931l0.531,42.034l175.125-42.917l175.125,42.917l0.531-42.034l-134.449-92.931l12.238-241.308L1705.06,1318.313z"
19 | let emptyCircle = Symbol.emptyCircle
20 | let circle = Symbol.circle
21 | let rect = Symbol.rect
22 | let roundRect = Symbol.roundRect
23 | let triangle = Symbol.triangle
24 | let diamond = Symbol.diamond
25 | let pin = Symbol.pin
26 | let arrow = Symbol.arrow
27 | let none = Symbol.none
28 | let img = Symbol.image(imageString)
29 | let path = Symbol.path(pathString)
30 |
31 | expect(emptyCircle.jsonString).to(equal("emptyCircle".jsonString))
32 | expect(circle.jsonString).to(equal("circle".jsonString))
33 | expect(rect.jsonString).to(equal("rect".jsonString))
34 | expect(roundRect.jsonString).to(equal("roundRect".jsonString))
35 | expect(triangle.jsonString).to(equal("triangle".jsonString))
36 | expect(diamond.jsonString).to(equal("diamond".jsonString))
37 | expect(pin.jsonString).to(equal("pin".jsonString))
38 | expect(arrow.jsonString).to(equal("arrow".jsonString))
39 | expect(none.jsonString).to(equal("none".jsonString))
40 | expect(img.jsonString).to(equal(imageString.jsonString))
41 | expect(path.jsonString).to(equal(pathString.jsonString))
42 | }
43 | }
44 | }
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/TargetSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TargetSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 21/06/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class TargetSpec: QuickSpec {
14 | override func spec() {
15 | describe("For Target") {
16 | it(" needs to check the jsonString ") {
17 | let selfTarget = Target.`self`
18 | let blankTarget = Target.blank
19 | let selfString = "self"
20 | let blankString = "blank"
21 |
22 | expect(selfTarget.description).to(equal(selfString))
23 | expect(blankTarget.description).to(equal(blankString))
24 | expect(selfTarget.jsonString).to(equal(selfString.jsonString))
25 | expect(blankTarget.jsonString).to(equal(blankString.jsonString))
26 |
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/TextSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TextSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 12/05/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class TextSpec: QuickSpec {
14 |
15 | override func spec() {
16 | describe("For Align") {
17 | it(" needs to check the jsonString ") {
18 | let leftAlign = Align.left
19 | let rightAlign = Align.right
20 | let centerAlign = Align.center
21 | let autoAlign = Align.auto
22 | let noneAlign = Align.none
23 |
24 | expect(leftAlign.jsonString).to(equal("left".jsonString))
25 | expect(rightAlign.jsonString).to(equal("right".jsonString))
26 | expect(centerAlign.jsonString).to(equal("center".jsonString))
27 | expect(autoAlign.jsonString).to(equal("auto".jsonString))
28 | expect(noneAlign.jsonString).to(equal("".jsonString))
29 | }
30 | }
31 |
32 | describe("For VerticalAlign") {
33 | it(" needs to check the jsonString ") {
34 | let topVerticalAlign = VerticalAlign.top
35 | let middleVerticalAlign = VerticalAlign.middle
36 | let bottomVerticalAlign = VerticalAlign.bottom
37 |
38 | expect(topVerticalAlign.jsonString).to(equal("top".jsonString))
39 | expect(middleVerticalAlign.jsonString).to(equal("middle".jsonString))
40 | expect(bottomVerticalAlign.jsonString).to(equal("bottom".jsonString))
41 | }
42 | }
43 |
44 | describe("For TextStyle") {
45 | let color: Color = .red
46 | let fontStyle: FontStyle = .italic
47 | let fontWeight: FontWeight = .bolder
48 | let fontFamily: String = "Arial"
49 | let fontSize: UInt = 32
50 | let align: Position = .center
51 |
52 | let textStyle = TextStyle()
53 | textStyle.color = color
54 | textStyle.fontStyle = fontStyle
55 | textStyle.fontWeight = fontWeight
56 | textStyle.fontFamily = fontFamily
57 | textStyle.fontSize = fontSize
58 | textStyle.align = align
59 |
60 | it(" needs to check the jsonString ") {
61 | let textStyleDic: [String: Jsonable] = ["color": color, "fontStyle": fontStyle, "fontWeight": fontWeight, "fontFamily": fontFamily, "fontSize": fontSize, "align": align]
62 |
63 | expect(textStyle.jsonString).to(equal(textStyleDic.jsonString))
64 | }
65 |
66 | it(" needs to check the Enumable ") {
67 | let textStyleCreatedByEnum = TextStyle(
68 | .color(color),
69 | .fontStyle(fontStyle),
70 | .fontWeight(fontWeight),
71 | .fontFamily(fontFamily),
72 | .fontSize(fontSize),
73 | .align(align)
74 | )
75 |
76 | expect(textStyleCreatedByEnum.jsonString).to(equal(textStyle.jsonString))
77 | }
78 | }
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/SwiftyEchartsTest_iOS/VisualMapSpec.swift:
--------------------------------------------------------------------------------
1 | //
2 | // VisualMapSpec.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 26/06/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import Quick
10 | import Nimble
11 | import SwiftyEcharts
12 |
13 | class VisualMapSpec: QuickSpec {
14 | override func spec() {
15 | describe("For VisualMapController") {
16 | let inRange: [String: Jsonable] = ["color": Color.hexColor("#2f4554")]
17 | let outRange: [String: Jsonable] = [
18 | "symbolSize": [10, 70],
19 | "color": ["rgba(255, 255, 255, 0.2"]
20 | ]
21 | let visualMapController = VisualMapController()
22 | visualMapController.inRange = inRange
23 | visualMapController.outRange = outRange
24 | it("needs to check the jsonString") {
25 | let resultDic = [
26 | "inRange": inRange,
27 | "outRange": outRange
28 | ]
29 |
30 | expect(visualMapController.jsonString).to(equal(resultDic.jsonString))
31 | }
32 |
33 | it("needs to check the Enumable") {
34 | let visualMapControllerByEnums = VisualMapController(
35 | .inRange(inRange),
36 | .outRange(outRange)
37 | )
38 | expect(visualMapControllerByEnums.jsonString).to(equal(visualMapController.jsonString))
39 | }
40 | }
41 |
42 | context("For the actions of VisualMap") {
43 | describe("For VisualMapSelectDataRangeAction") {
44 | let typeValue = EchartsActionType.selectDataRange
45 | let visualMapIndexValue = 20
46 | let selectedValue: Jsonable = [20, 40]
47 |
48 | let visualMapSelectDataRangeAction = VisualMapSelectDataRangeAction()
49 | visualMapSelectDataRangeAction.visualMapIndex = visualMapIndexValue
50 | visualMapSelectDataRangeAction.selected = selectedValue
51 |
52 | it("needs to check the type value") {
53 | expect(visualMapSelectDataRangeAction.type.jsonString).to(equal(typeValue.jsonString))
54 | }
55 |
56 | it("needs to check the jsonString") {
57 | let resultDic: [String: Jsonable] = [
58 | "type": typeValue,
59 | "visualMapIndex": visualMapIndexValue,
60 | "selected": selectedValue
61 | ]
62 |
63 | expect(visualMapSelectDataRangeAction.jsonString).to(equal(resultDic.jsonString))
64 | }
65 |
66 | it("needs to check the Enumable") {
67 | let visualMapSelectDataRangeActionByEnums = VisualMapSelectDataRangeAction(
68 | .visualMapIndex(visualMapIndexValue),
69 | .selected(selectedValue)
70 | )
71 |
72 | expect(visualMapSelectDataRangeActionByEnums.jsonString).to(equal(visualMapSelectDataRangeAction.jsonString))
73 | }
74 | }
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/iOS_Example/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // iOS_Example
4 | //
5 | // Created by Pluto Y on 25/11/2016.
6 | // Copyright © 2016 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
18 | return true
19 | }
20 |
21 | func applicationWillResignActive(_ application: UIApplication) {
22 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
23 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
24 | }
25 |
26 | func applicationDidEnterBackground(_ application: UIApplication) {
27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
29 | }
30 |
31 | func applicationWillEnterForeground(_ application: UIApplication) {
32 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
33 | }
34 |
35 | func applicationDidBecomeActive(_ application: UIApplication) {
36 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
37 | }
38 |
39 | func applicationWillTerminate(_ application: UIApplication) {
40 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
41 | }
42 |
43 |
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/iOS_Example/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | }
43 | ],
44 | "info" : {
45 | "version" : 1,
46 | "author" : "xcode"
47 | }
48 | }
--------------------------------------------------------------------------------
/iOS_Example/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/iOS_Example/DemoControllers/BaseDemoController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // BaseDemoController.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 25/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import SwiftyEcharts
11 |
12 | class BaseDemoController: UIViewController, UITableViewDelegate, UITableViewDataSource {
13 |
14 | var menuTableView: UITableView!
15 | var echartsView: EchartsView!
16 | var option: Option! {
17 | didSet {
18 | echartsView.option = option
19 | echartsView.loadEcharts()
20 | }
21 | }
22 | var menus: [String] = []
23 | var optionClosures: [() -> Option] = []
24 |
25 | override func viewDidLoad() {
26 | super.viewDidLoad()
27 |
28 | self.view.backgroundColor = UIColor.white
29 |
30 | let width = self.view.frame.width
31 | let height = self.view.frame.height
32 |
33 | menuTableView = UITableView(frame: CGRect(x: 0, y: 0, width: width, height: height - 300))
34 | menuTableView.delegate = self
35 | menuTableView.dataSource = self
36 | menuTableView.register(UITableViewCell.self, forCellReuseIdentifier: "DemoCell")
37 | self.view.addSubview(menuTableView)
38 |
39 | let line = UIView(frame: CGRect(x: 0, y: height - 300, width: width, height: 1))
40 | line.backgroundColor = UIColor(red: 239/255.0, green: 239/255.0, blue: 245/255.0, alpha: 1.0)
41 | self.view.addSubview(line)
42 |
43 | echartsView = EchartsView(frame: CGRect(x: 0, y: height - 299, width: width, height: 300))
44 | self.view.addSubview(echartsView!)
45 |
46 | Mapper.ignoreNil = true
47 |
48 | }
49 |
50 | override func viewWillAppear(_ animated: Bool) {
51 | super.viewWillAppear(animated)
52 | option = optionClosures[0]()
53 | }
54 |
55 | // MARK: - UITableViewDataSource
56 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
57 | return menus.count
58 | }
59 |
60 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
61 | let cell = tableView.dequeueReusableCell(withIdentifier: "DemoCell", for: indexPath)
62 | cell.textLabel?.text = menus[indexPath.row]
63 | cell.selectionStyle = .none
64 | return cell
65 | }
66 |
67 | // MARK: - UITableViewDelegate
68 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
69 | echartsView.reset()
70 | option = optionClosures[indexPath.row]()
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/iOS_Example/DemoControllers/BoxplotsControllers.swift:
--------------------------------------------------------------------------------
1 | //
2 | // BoxplotsControllers.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 08/09/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class BoxplotsControllers: BaseDemoController {
12 |
13 | override func viewDidLoad() {
14 | super.viewDidLoad()
15 |
16 | self.menus = ["Boxplot Light Velocity", "Boxplot Light Velocity2", "Multiple Categories"]
17 |
18 | self.optionClosures = [BoxplotOptions.boxplotLightVelocityOption, BoxplotOptions.boxplotLightVelocity2Option, BoxplotOptions.boxplotMultiOption]
19 |
20 | self.title = "箱线图"
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/iOS_Example/DemoControllers/CandlesticksController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CandlesticksController.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 13/09/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class CandlesticksController: BaseDemoController {
12 |
13 | override func viewDidLoad() {
14 | super.viewDidLoad()
15 |
16 | self.menus = ["Candlestick Brush(暂缺)", "2015 年上证指数", "上证指数", "触屏上的坐标轴指示器", "OHLC Chart"]
17 |
18 | self.optionClosures = [CandlestickOptions.candlestickBrushOption, CandlestickOptions.candlestickSh2015Option, CandlestickOptions.candlestickShOption, CandlestickOptions.candlestickTouchOption, CandlestickOptions.customOhlcOption]
19 |
20 | self.title = "k线图"
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/iOS_Example/DemoControllers/FunnelController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // FunnelController.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by 李岳敏 on 2017/3/7.
6 | // Copyright © 2017年 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import SwiftyEcharts
11 |
12 | class FunnelController: BaseDemoController {
13 |
14 | override func viewDidLoad() {
15 | super.viewDidLoad()
16 |
17 | self.menus = ["漏斗图(对比)", "漏斗图", "漏斗图", "漏斗图"]
18 |
19 | self.optionClosures = [FunnelOptions.unnelAlignOption, FunnelOptions.funnelCustomizeOption, FunnelOptions.funnelMutipleOption, FunnelOptions.funnelOption]
20 |
21 | self.title = "漏斗图"
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/iOS_Example/DemoControllers/GaugesController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // GaugesController.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 07/03/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import SwiftyEcharts
11 |
12 | class GaugesController: BaseDemoController {
13 |
14 | fileprivate var timer: Timer?
15 |
16 | override func viewDidLoad() {
17 | super.viewDidLoad()
18 |
19 | self.menus = ["Gauge Car Dark(暂缺)", "Gauge Car", "Gauge"]
20 |
21 | self.optionClosures = [GaugeOptions.gaugeCarDarkOption, GaugeOptions.gaugeCarOption, GaugeOptions.gaugeOption]
22 |
23 | self.title = "仪表盘"
24 | }
25 |
26 | override func viewDidDisappear(_ animated: Bool) {
27 | super.viewDidDisappear(animated)
28 | if timer != nil {
29 | timer?.invalidate()
30 | timer = nil
31 | }
32 | }
33 |
34 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
35 | super.tableView(tableView, didSelectRowAt: indexPath)
36 |
37 | if timer != nil {
38 | timer?.invalidate()
39 | timer = nil
40 | }
41 |
42 | switch indexPath.row {
43 | case 0:
44 | print("")
45 | case 1:
46 | timer = Timer(timeInterval: 2, target: self, selector: #selector(self.randomForGaugeCar), userInfo: nil, repeats: true)
47 | case 2:
48 | timer = Timer(timeInterval: 2, target: self, selector: #selector(self.randomForGauge), userInfo: nil, repeats: true)
49 | default:
50 | print("错误输入")
51 | }
52 | if let t = timer {
53 | RunLoop.current.add(t, forMode: RunLoopMode.commonModes)
54 | }
55 | }
56 |
57 | func randomForGauge() {
58 | let option = self.option
59 | let data: [String: Jsonable] = ["value": Double(arc4random_uniform(100) + 1), "name": "完成率"]
60 | let serie = option?.series![0] as! GaugeSerie
61 | serie.data = [data]
62 | option?.series = [serie]
63 | self.echartsView.refreshEcharts(option!)
64 | }
65 |
66 | func randomForGaugeCar() {
67 | let option = self.option
68 | let data1: [String: Jsonable] = ["value": Double(arc4random_uniform(100) + 1), "name": "km/h"]
69 | let serie1 = option?.series![0] as! GaugeSerie
70 | serie1.data = [data1]
71 | let data2: [String: Jsonable] = ["value": Double(arc4random_uniform(7) + 1), "name": "x1000 r/min"]
72 | let serie2 = option?.series![1] as! GaugeSerie
73 | serie2.data = [data2]
74 | let data3: [String: Jsonable] = ["value": Double(arc4random_uniform(2) + 1), "name": "gas"]
75 | let serie3 = option?.series![2] as! GaugeSerie
76 | serie3.data = [data3]
77 | let data4: [String: Jsonable] = ["value": Double(arc4random_uniform(2) + 1), "name": "gas"]
78 | let serie4 = option?.series![3] as! GaugeSerie
79 | serie4.data = [data4]
80 |
81 | option?.series = [serie1, serie2, serie3, serie4]
82 | self.echartsView.refreshEcharts(option!)
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/iOS_Example/DemoControllers/GraphsController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // GraphsController.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 26/10/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class GraphsController: BaseDemoController {
12 |
13 | override func viewDidLoad() {
14 | super.viewDidLoad()
15 | menus = ["Les Miserables(暂缺)", "力引导布局(暂缺)", "力引导布局", "笛卡尔坐标系上的 Graph", "Graph Life Expectancy(暂缺)", "NPM Dependencies", "Graph 简单示例", "Graph Webkit Dep", "Les Miserables(暂缺)", "Calendar Graph"]
16 |
17 | optionClosures = [GraphOptions.graphCircularLayoutOption, GraphOptions.graphForceOption, GraphOptions.graphForce2Option, GraphOptions.graphGridOption, GraphOptions.graphLifeExpectancyOption, GraphOptions.graphNpmOption, GraphOptions.graphSimpleOption, GraphOptions.graphWebkitDepOption, GraphOptions.graphOption, GraphOptions.calendarGraphOption]
18 |
19 | self.title = "关系图"
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/iOS_Example/DemoControllers/HeatmapsController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // HeatmapsController.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 23/10/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class HeatmapsController: BaseDemoController {
12 |
13 | override func viewDidLoad() {
14 | super.viewDidLoad()
15 |
16 | menus = ["热力图与百度地图扩展(暂缺)", "笛卡尔坐标系上的热力图", "热力图 - 颜色的离散映射(暂缺)", "热力图 - 2w 数据(暂缺)", "Calendar Heatmap Vertical", "Calendar Heatmap Horizontal"]
17 | optionClosures = [HeatmapOptions.heatmapBmapOption, HeatmapOptions.heatmapCartesianOption, HeatmapOptions.heatmapLargePiecewiseOption, HeatmapOptions.heatmapLargeOption, HeatmapOptions.calendarVerticalOption, HeatmapOptions.calendarHorizontalOption]
18 |
19 | self.title = "热力图"
20 | }
21 |
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/iOS_Example/DemoControllers/LinesController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // LinesController.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 25/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import SwiftyEcharts
11 |
12 | class LinesController: BaseDemoController {
13 |
14 | private var timer: Timer?
15 |
16 | override func viewDidLoad() {
17 | super.viewDidLoad()
18 |
19 | menus = ["雨量流量关系图", "大数据量面积图", "堆叠区域图", "Confidence Band(暂缺)", "动态数据 + 时间坐标轴", "雨量流量关系图", "Beijing AQI", "Try Dragging these Points(暂缺)", "Different Easing Functions(暂缺)", "对数轴示例", "未来一周气温变化", "Click to Add Points(暂缺)", "极坐标双数值轴", "极坐标双数值轴", "一天用电量分布", "折线图堆叠", "Step Line", "高度(km)与气温(°C)变化关系", "Multiple X Axes", "Tooltip and DataZoom on Mobile(暂缺)", "折线图的渐变"]
20 |
21 | optionClosures = [LineOptions.areaRainfallOption, LineOptions.areaSimpleOption, LineOptions.areaStackOption, LineOptions.confidenceBandOption, LineOptions.dynamicData2Option, LineOptions.gridMultipleOption, LineOptions.lineApiOption, LineOptions.lineDraggableOption, LineOptions.lineEasingOption, LineOptions.lineLogOption, LineOptions.lineMarkerOption, LineOptions.linePenOption, LineOptions.linePolarOption, LineOptions.linePolar2Option, LineOptions.lineSectionsOption, LineOptions.lineStackOption, LineOptions.lineStepOption, LineOptions.lineYCategoryOption, LineOptions.multipleXAxisOption, LineOptions.lineTooltipTouchOption, LineOptions.lineGradientOption]
22 |
23 | self.title = "折线图"
24 | }
25 |
26 | override func viewDidDisappear(_ animated: Bool) {
27 | super.viewDidDisappear(animated)
28 | if timer != nil {
29 | timer?.invalidate()
30 | timer = nil
31 | }
32 | }
33 |
34 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
35 | super.tableView(tableView, didSelectRowAt: indexPath)
36 | if timer != nil {
37 | timer?.invalidate()
38 | timer = nil
39 | }
40 |
41 | if indexPath.row == 4 { // 动态数据 + 时间坐标轴
42 | timer = Timer(timeInterval: 1.0, target: self, selector: #selector(self.dynamicData), userInfo: nil, repeats: true)
43 | RunLoop.current.add(timer!, forMode: .commonModes)
44 | }
45 | }
46 |
47 | func dynamicData() {
48 | if let serie = self.option.series?[0] as? LineSerie {
49 | for _ in 0 ..< 5 {
50 | LineOptions.data.removeFirst()
51 | LineOptions.data.append(LineOptions.randomData())
52 | }
53 | serie.data = LineOptions.data
54 | self.option.series = [serie]
55 | self.echartsView.refreshEcharts(self.option, true)
56 | }
57 | }
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/iOS_Example/DemoControllers/PictorialBarsController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // PictorialBarsController.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 04/04/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import SwiftyEcharts
11 |
12 | class PictorialBarsController: BaseDemoController {
13 |
14 | var timer: Timer?
15 |
16 | override func viewDidLoad() {
17 | super.viewDidLoad()
18 |
19 | menus = ["圣诞节儿童愿望清单和山峰高度", "驯鹿的速度", "交通工具", "精灵", "人体含水量", "虚线柱状图效果", "森林的增长"]
20 |
21 | optionClosures = [PictorialBarOptions.pictorialBarHillOption, PictorialBarOptions.pictorialBarVelocityOption, PictorialBarOptions.pictorialBarVehicleOption, PictorialBarOptions.pictorialBarSpiritOption, PictorialBarOptions.pictorialBarBodyFillOption, PictorialBarOptions.pictorialBarDottedOption, PictorialBarOptions.pictorialBarForestOption]
22 |
23 | self.title = "象形柱图"
24 |
25 | }
26 |
27 | override func viewDidDisappear(_ animated: Bool) {
28 | super.viewDidDisappear(animated)
29 | if timer != nil {
30 | timer?.invalidate()
31 | timer = nil
32 | }
33 | }
34 |
35 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
36 | super.tableView(tableView, didSelectRowAt: indexPath)
37 | if timer != nil {
38 | timer?.invalidate()
39 | timer = nil
40 | }
41 | if indexPath.row == 3 { // 精灵
42 | timer = Timer(timeInterval: 3, target: self, selector: #selector(self.pictorialBarSpirit), userInfo: nil, repeats: true)
43 | RunLoop.current.add(timer!, forMode: .commonModes)
44 | } else if indexPath.row == optionClosures.count - 1 { // 森林的增长
45 | timer = Timer(timeInterval: 0.8, target: self, selector: #selector(self.pictorialBarForest), userInfo: nil, repeats: true)
46 | RunLoop.current.add(timer!, forMode: .commonModes)
47 | }
48 | }
49 |
50 | func pictorialBarSpirit() {
51 | let random = {
52 | return Float(Float(arc4random_uniform(1000))/1000.0) * 1990 as Jsonable
53 | }
54 | let dynamicData = [random(), random(), random(), random()]
55 | let tmpOption = self.option
56 | var tmpSeries: [PictorialBarSerie] = []
57 | for serie in (tmpOption!.series!) {
58 | let tmpSerie = serie as! PictorialBarSerie
59 | tmpSerie.data = dynamicData
60 | tmpSeries.append(tmpSerie)
61 | }
62 | tmpOption?.series = tmpSeries.map { $0 as Serie }
63 | self.echartsView.refreshEcharts(tmpOption!)
64 |
65 | }
66 |
67 | var currentYear = PictorialBarOptions.beginYear
68 | func pictorialBarForest() {
69 | currentYear += 1
70 | if currentYear > PictorialBarOptions.endYear {
71 | currentYear = PictorialBarOptions.beginYear
72 | }
73 |
74 | self.echartsView.refreshEcharts(Option(
75 | .xAxis(Axis(
76 | .name("\(currentYear)")
77 | )),
78 | .series([
79 | PictorialBarSerie(
80 | .data(PictorialBarOptions.makeSeriesData(currentYear))
81 | ),
82 | PictorialBarSerie(
83 | .data(PictorialBarOptions.makeSeriesData(currentYear, true))
84 | )
85 | ])
86 | ))
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/iOS_Example/DemoControllers/PiesController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // PiesControllerViewController.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 25/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import SwiftyEcharts
11 |
12 | class PiesController: BaseDemoController {
13 |
14 | private var timer: Timer?
15 |
16 | override func viewDidLoad() {
17 | super.viewDidLoad()
18 |
19 | menus = ["Customized Pie", "环形图", "嵌套环形图", "饼图纹理", "某站点用户访问来源", "南丁格尔玫瑰图", "富文本标签", "可滚动的图例(暂无)"]
20 |
21 | optionClosures = [PieOptions.pieCustomOption, PieOptions.pieDoughnutOption, PieOptions.pieNestOption, PieOptions.piePatternOption, PieOptions.pieSimpleOption, PieOptions.pieRoseTypeOption, PieOptions.pieRichTextOption, PieOptions.pieLegendOption]
22 |
23 | self.title = "饼图"
24 | }
25 |
26 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
27 | super.tableView(tableView, didSelectRowAt: indexPath)
28 | if indexPath.row == 4 {
29 |
30 | if let _ = timer {
31 | self.timer?.invalidate()
32 | self.timer = nil
33 | }
34 | timer = Timer(timeInterval: 1.0, target: self, selector: #selector(self.dispatchAction), userInfo: nil, repeats: true)
35 | RunLoop.current.add(timer!, forMode: .commonModes)
36 | // echartsView.addListener(for: .click, with: { (params) in
37 | // print("params: \(params)")
38 | // })
39 | }
40 | }
41 |
42 | var currentIndex: Int = -1
43 | internal func dispatchAction() {
44 | let dataLen = (option.series![0] as! PieSerie).data!.count
45 | echartsView.dispatchAction(DownplayAction(
46 | .seriesIndex(0),
47 | .dataIndex(currentIndex)
48 | ))
49 | currentIndex = (currentIndex + 1) % dataLen
50 | echartsView.dispatchAction(HighlightAction(
51 | .seriesIndex(0),
52 | .dataIndex(currentIndex)
53 | ))
54 | echartsView.dispatchAction(Tooltip.ShowTipAction(
55 | .seriesIndex(0),
56 | .dataIndex(currentIndex)
57 | ))
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/iOS_Example/DemoControllers/RadarsController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // RadarsController.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 28/02/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class RadarsController: BaseDemoController {
12 |
13 | override func viewDidLoad() {
14 | super.viewDidLoad()
15 |
16 | self.menus = ["AQI - 雷达图", "自定义雷达图", "多雷达图", "基础雷达图", "浏览器占比变化"]
17 |
18 | self.optionClosures = [RadarOptions.radarAqiOption, RadarOptions.radarCustomOption, RadarOptions.radarMultipleOption, RadarOptions.radarOption, RadarOptions.radar2Option]
19 |
20 | self.title = "雷达图"
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/iOS_Example/DemoControllers/SankeysController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SankeysController.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 14/03/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class SankeysController: BaseDemoController {
12 |
13 | override func viewDidLoad() {
14 | super.viewDidLoad()
15 |
16 | menus = ["Sankey Diagram", "Sankey Diagram"]
17 |
18 | optionClosures = [SankeyOptions.sankeyEnergyOption, SankeyOptions.sankeyProductOption]
19 |
20 | self.title = "桑基图"
21 |
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/iOS_Example/DemoControllers/ScattersController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ScattersController.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto Y on 23/05/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class ScattersController: BaseDemoController {
12 |
13 | override func viewDidLoad() {
14 | super.viewDidLoad()
15 |
16 | menus = ["气泡图", "全国主要城市空气质量 - 百度地图(暂缺)", "全国主要城市空气质量", "Prices and Earnings 2012(暂缺)", "Anscombe's quartet", "Scatter Aqi Color", "大规模散点图", "各国人均寿命与GDP关系演变(暂缺)", "Scatter Map Brush(暂缺)", "全国主要城市空气质量", "Scatter Nutrients(暂缺)", "Master Painter Color Choices Throughout History(暂缺)", "Punch Card of Github", "Punch Card of Github", "单轴散点图(暂缺)", "微博签到数据点亮中国(暂缺)", "男性女性身高体重分布", "World Population (2010)(暂缺)", "Scatter Nutrients Matrix(暂缺)", "Clustering Process(暂缺)", "Linear Regression(暂缺)", "Exponential Regression(暂缺)", "Logarithmic Regression(暂缺)", "Polynomial Regression(暂缺)", "Calendar Effectscatter(暂缺)"]
17 |
18 | optionClosures = [ScatterOptions.bubbleGradientOption, ScatterOptions.effectScatterBmapOption, ScatterOptions.effectScatterMapOption, ScatterOptions.mapParallelPricesOption, ScatterOptions.scatterAnscombeQuartetOption, ScatterOptions.scatterAqiColorOption, ScatterOptions.scatterLargeOption, ScatterOptions.scatterLifeExpectancyTimelineOption, ScatterOptions.scatterMapBrushOption, ScatterOptions.scatterMapOption, ScatterOptions.scatterNutrientsOption, ScatterOptions.scatterPainterChoiceOption, ScatterOptions.scatterPolarPunchCardOption, ScatterOptions.scatterPunchCardOption, ScatterOptions.scatterSingleAxisOption, ScatterOptions.scatterWeiboOption, ScatterOptions.scatterWeightOption, ScatterOptions.scatterWorldPopulationOption, ScatterOptions.scatterNutrientsMatrixOption, ScatterOptions.scatterClusteringProcessOption, ScatterOptions.scatterLinearRegressionOption, ScatterOptions.scatterExponentialRegressionOption, ScatterOptions.scatterLogarithmicRegressionOption, ScatterOptions.scatterPolynomialRegressionOption, ScatterOptions.calendarEffectscatterOption]
19 |
20 | self.title = "散点图"
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/iOS_Example/DemoControllers/ThemeRiversController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ThemeRiversController.swift
3 | // SwiftyEcharts
4 | //
5 | // Created by Pluto-Y on 13/03/2017.
6 | // Copyright © 2017 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import SwiftyEcharts
11 |
12 | class ThemeRiversController: BaseDemoController {
13 |
14 |
15 | override func viewDidLoad() {
16 | super.viewDidLoad()
17 |
18 | menus = ["主题河流图", "ThemeRiver Lastfm"]
19 |
20 | optionClosures = [ThemeRiverOptions.themeRiverBasicOption, ThemeRiverOptions.themeRiverLastfmOption]
21 |
22 | self.title = "主题河流图"
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/iOS_Example/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | NSAppTransportSecurity
38 |
39 | NSAllowsArbitraryLoads
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/iOS_Example/MenuController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // iOS_Example
4 | //
5 | // Created by Pluto Y on 25/11/2016.
6 | // Copyright © 2016 com.pluto-y. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import SwiftyEcharts
11 |
12 | class MenuController: UITableViewController {
13 |
14 | var echartsView: EchartsView?
15 |
16 | override func viewDidLoad() {
17 | super.viewDidLoad()
18 | }
19 |
20 | override func viewDidAppear(_ animated: Bool) {
21 | super.viewDidAppear(animated)
22 | }
23 |
24 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
25 | switch indexPath.row {
26 | case 0: // 散点图
27 | self.navigationController?.pushViewController(ScattersController(), animated: true)
28 | case 1: // 折线图
29 | self.navigationController?.pushViewController(LinesController(), animated: true)
30 | case 2: // 柱状图
31 | self.navigationController?.pushViewController(BarsController(), animated: true)
32 | case 3: // 地图
33 | self.navigationController?.pushViewController(MapsController(), animated: true)
34 | case 4: // 饼图的
35 | self.navigationController?.pushViewController(PiesController(), animated: true)
36 | case 5: // 雷达图
37 | self.navigationController?.pushViewController(RadarsController(), animated: true)
38 | case 6: // k线图
39 | self.navigationController?.pushViewController(CandlesticksController(), animated: true)
40 | case 7: // 箱线图
41 | self.navigationController?.pushViewController(BoxplotsControllers(), animated: true)
42 | case 8: // 热力图
43 | self.navigationController?.pushViewController(HeatmapsController(), animated: true)
44 | case 9: // 关系图
45 | self.navigationController?.pushViewController(GraphsController(), animated: true)
46 | case 10: // 桑基图
47 | self.navigationController?.pushViewController(SankeysController(), animated: true)
48 | case 11: // 漏斗图
49 | self.navigationController?.pushViewController(FunnelController(), animated: true)
50 | case 12: // 仪表盘
51 | self.navigationController?.pushViewController(GaugesController(), animated: true)
52 | case 13: // 象形柱图
53 | self.navigationController?.pushViewController(PictorialBarsController(), animated: true)
54 | case 14: // 主题河流图
55 | self.navigationController?.pushViewController(ThemeRiversController(), animated: true)
56 | default:
57 | print("敬请期待...")
58 | }
59 | }
60 |
61 | }
62 |
63 |
--------------------------------------------------------------------------------
/script.vim:
--------------------------------------------------------------------------------
1 | " 设置工程项目所有文件,保证能通过 `fg` 来跳转
2 | set path+=SwiftyEcharts/**
3 | " 设置在跳转情况下,自动在文件名后面加 `.swift` 后缀名
4 | set suffixesadd+=.swift
5 | " 设置 Tab 键为4个空格的长度
6 | setlocal sts=4 ts=4 sw=4 noet
7 | " Tab 键常量
8 | let @t = ' '
9 | " Enumable 的宏
10 | let @a = 'gg/public struct
2wyiwGooextension pa : SECEnumable {
}O"tpapublic enum Enums {
"tpa}O"tp.acasejoo"tpapublic typealias ContentEnum = Enumsoo"tpapublic init(_ elements: Enums...) {
"tpa}O"tp.afor ele in elements {
"tp.a}O"tp..aswitch ele {
"tp..a}'
11 | let @b = '03wmmyiwG:?case
A pa(`m2wyt?G:?case
Apa),`mj'
12 | let @c = '03wmmyiwG4ko5"tpicase let .pa(pa):
4"tpaself.pa = p`mj'
13 | " Mappable 的宏
14 | let @d = 'gg/public struct
2wyiwGooextension pa : SECMappable {
}O"tpapublic func mapping(map: SECMap) {
"tpa}'
15 | let @e = '03wyiwmmG2ko2"tpamap["pa"] = p`mj'
16 |
--------------------------------------------------------------------------------