├── .gitignore ├── README.md ├── echarts ├── .editorconfig ├── .github │ ├── CONTRIBUTING.md │ └── ISSUE_TEMPLATE.md ├── .gitignore ├── .jshintrc ├── .npmignore ├── LICENSE ├── README.md ├── asset │ └── logo.png ├── benchmark │ ├── dep │ │ ├── bootstrap │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.js │ │ ├── filesaver │ │ │ └── FileSaver.min.js │ │ ├── jquery │ │ │ └── jquery-2.2.4.js │ │ ├── lodash │ │ │ └── lodash.js │ │ └── vue │ │ │ └── vue.min.js │ ├── gulpfile.js │ ├── index.html │ └── src │ │ ├── app.js │ │ ├── testCase.js │ │ ├── testFactory.js │ │ └── testManager.js ├── build │ ├── amd2common.js │ ├── build.sh │ ├── mangleString.js │ └── optimize.js ├── demo │ ├── bar-setOption-test.html │ ├── bar.html │ ├── echarts.js │ ├── jslibs │ │ ├── esl.js │ │ ├── sea-debug.js │ │ └── sea.js │ ├── line-draggable.html │ ├── line-graphic.html │ └── line.html ├── dist-initial │ ├── echarts.common.js │ ├── echarts.common.min.js │ ├── echarts.js │ ├── echarts.min.js │ ├── echarts.simple.js │ ├── echarts.simple.min.js │ └── extension │ │ ├── bmap.js │ │ ├── bmap.min.js │ │ ├── dataTool.js │ │ └── dataTool.min.js ├── dist │ ├── echarts.common.js │ ├── echarts.common.min.js │ ├── echarts.js │ ├── echarts.min.js │ ├── echarts.simple.js │ └── echarts.simple.min.js ├── extension │ ├── bmap │ │ ├── BMapCoordSys.js │ │ ├── BMapModel.js │ │ ├── BMapView.js │ │ ├── README.md │ │ └── bmap.js │ ├── dataTool │ │ ├── gexf.js │ │ ├── index.js │ │ ├── prepareBoxplotData.js │ │ └── quantile.js │ ├── echarts.js │ └── webpack.config.js ├── index.common.js ├── index.js ├── index.simple.js ├── map │ ├── js │ │ ├── china-contour.js │ │ ├── china.js │ │ ├── province │ │ │ ├── anhui.js │ │ │ ├── aomen.js │ │ │ ├── beijing.js │ │ │ ├── chongqing.js │ │ │ ├── fujian.js │ │ │ ├── gansu.js │ │ │ ├── guangdong.js │ │ │ ├── guangxi.js │ │ │ ├── guizhou.js │ │ │ ├── hainan.js │ │ │ ├── hebei.js │ │ │ ├── heilongjiang.js │ │ │ ├── henan.js │ │ │ ├── hubei.js │ │ │ ├── hunan.js │ │ │ ├── jiangsu.js │ │ │ ├── jiangxi.js │ │ │ ├── jilin.js │ │ │ ├── liaoning.js │ │ │ ├── neimenggu.js │ │ │ ├── ningxia.js │ │ │ ├── qinghai.js │ │ │ ├── shandong.js │ │ │ ├── shanghai.js │ │ │ ├── shanxi.js │ │ │ ├── shanxi1.js │ │ │ ├── sichuan.js │ │ │ ├── taiwan.js │ │ │ ├── tianjin.js │ │ │ ├── xianggang.js │ │ │ ├── xinjiang.js │ │ │ ├── xizang.js │ │ │ ├── yunnan.js │ │ │ └── zhejiang.js │ │ └── world.js │ └── json │ │ ├── china-cities.json │ │ ├── china-contour.json │ │ ├── china.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 │ │ ├── taiwan.json │ │ ├── tianjin.json │ │ ├── xianggang.json │ │ ├── xinjiang.json │ │ ├── xizang.json │ │ ├── yunnan.json │ │ └── zhejiang.json │ │ └── world.json ├── package.json ├── src │ ├── CoordinateSystem.js │ ├── ExtensionAPI.js │ ├── action │ │ ├── createDataSelectAction.js │ │ ├── geoRoam.js │ │ └── roamHelper.js │ ├── chart │ │ ├── bar.js │ │ ├── bar │ │ │ ├── BarSeries.js │ │ │ ├── BarView.js │ │ │ ├── BaseBarSeries.js │ │ │ ├── PictorialBarSeries.js │ │ │ ├── PictorialBarView.js │ │ │ ├── barItemStyle.js │ │ │ └── helper.js │ │ ├── boxplot.js │ │ ├── boxplot │ │ │ ├── BoxplotSeries.js │ │ │ ├── BoxplotView.js │ │ │ ├── boxplotLayout.js │ │ │ └── boxplotVisual.js │ │ ├── candlestick.js │ │ ├── candlestick │ │ │ ├── CandlestickSeries.js │ │ │ ├── CandlestickView.js │ │ │ ├── candlestickLayout.js │ │ │ ├── candlestickVisual.js │ │ │ └── preprocessor.js │ │ ├── chord.js │ │ ├── chord │ │ │ ├── ChordSeries.js │ │ │ ├── ChordView.js │ │ │ ├── Ribbon.js │ │ │ └── chordCircularLayout.js │ │ ├── effectScatter.js │ │ ├── effectScatter │ │ │ ├── EffectScatterSeries.js │ │ │ └── EffectScatterView.js │ │ ├── funnel.js │ │ ├── funnel │ │ │ ├── FunnelSeries.js │ │ │ ├── FunnelView.js │ │ │ └── funnelLayout.js │ │ ├── gauge.js │ │ ├── gauge │ │ │ ├── GaugeSeries.js │ │ │ ├── GaugeView.js │ │ │ └── PointerPath.js │ │ ├── graph.js │ │ ├── graph │ │ │ ├── GraphSeries.js │ │ │ ├── GraphView.js │ │ │ ├── adjustEdge.js │ │ │ ├── backwardCompat.js │ │ │ ├── categoryFilter.js │ │ │ ├── categoryVisual.js │ │ │ ├── circularLayout.js │ │ │ ├── circularLayoutHelper.js │ │ │ ├── createView.js │ │ │ ├── edgeVisual.js │ │ │ ├── forceHelper.js │ │ │ ├── forceLayout.js │ │ │ ├── graphAction.js │ │ │ ├── simpleLayout.js │ │ │ ├── simpleLayoutEdge.js │ │ │ └── simpleLayoutHelper.js │ │ ├── heatmap.js │ │ ├── heatmap │ │ │ ├── HeatmapLayer.js │ │ │ ├── HeatmapSeries.js │ │ │ └── HeatmapView.js │ │ ├── helper │ │ │ ├── EffectLine.js │ │ │ ├── EffectPolyline.js │ │ │ ├── EffectSymbol.js │ │ │ ├── LargeLineDraw.js │ │ │ ├── LargeSymbolDraw.js │ │ │ ├── Line.js │ │ │ ├── LineDraw.js │ │ │ ├── LinePath.js │ │ │ ├── Polyline.js │ │ │ ├── Symbol.js │ │ │ ├── SymbolDraw.js │ │ │ ├── WhiskerBoxDraw.js │ │ │ ├── createGraphFromNodeEdge.js │ │ │ ├── createGraphFromNodeMatrix.js │ │ │ ├── createListFromArray.js │ │ │ └── whiskerBoxCommon.js │ │ ├── line.js │ │ ├── line │ │ │ ├── LineSeries.js │ │ │ ├── LineView.js │ │ │ ├── lineAnimationDiff.js │ │ │ └── poly.js │ │ ├── lines.js │ │ ├── lines │ │ │ ├── LinesSeries.js │ │ │ ├── LinesView.js │ │ │ └── linesLayout.js │ │ ├── map.js │ │ ├── map │ │ │ ├── MapSeries.js │ │ │ ├── MapView.js │ │ │ ├── backwardCompat.js │ │ │ ├── mapDataStatistic.js │ │ │ ├── mapSymbolLayout.js │ │ │ └── mapVisual.js │ │ ├── parallel.js │ │ ├── parallel │ │ │ ├── ParallelSeries.js │ │ │ ├── ParallelView.js │ │ │ └── parallelVisual.js │ │ ├── pictorialBar.js │ │ ├── pie.js │ │ ├── pie │ │ │ ├── PieSeries.js │ │ │ ├── PieView.js │ │ │ ├── labelLayout.js │ │ │ └── pieLayout.js │ │ ├── radar.js │ │ ├── radar │ │ │ ├── RadarSeries.js │ │ │ ├── RadarView.js │ │ │ ├── backwardCompat.js │ │ │ └── radarLayout.js │ │ ├── sankey.js │ │ ├── sankey │ │ │ ├── SankeySeries.js │ │ │ ├── SankeyView.js │ │ │ ├── sankeyLayout.js │ │ │ └── sankeyVisual.js │ │ ├── scatter.js │ │ ├── scatter │ │ │ ├── ScatterSeries.js │ │ │ └── ScatterView.js │ │ ├── themeRiver.js │ │ ├── themeRiver │ │ │ ├── ThemeRiverSeries.js │ │ │ ├── ThemeRiverView.js │ │ │ ├── themeRiverLayout.js │ │ │ └── themeRiverVisual.js │ │ ├── treemap.js │ │ └── treemap │ │ │ ├── Breadcrumb.js │ │ │ ├── TreemapSeries.js │ │ │ ├── TreemapView.js │ │ │ ├── helper.js │ │ │ ├── treemapAction.js │ │ │ ├── treemapLayout.js │ │ │ └── treemapVisual.js │ ├── component │ │ ├── angleAxis.js │ │ ├── axis.js │ │ ├── axis │ │ │ ├── AngleAxisView.js │ │ │ ├── AxisBuilder.js │ │ │ ├── AxisView.js │ │ │ ├── ParallelAxisView.js │ │ │ ├── RadiusAxisView.js │ │ │ ├── SingleAxisView.js │ │ │ └── parallelAxisAction.js │ │ ├── brush.js │ │ ├── brush │ │ │ ├── BrushModel.js │ │ │ ├── BrushView.js │ │ │ ├── brushAction.js │ │ │ ├── preprocessor.js │ │ │ ├── selector.js │ │ │ └── visualEncoding.js │ │ ├── dataZoom.js │ │ ├── dataZoom │ │ │ ├── AxisProxy.js │ │ │ ├── DataZoomModel.js │ │ │ ├── DataZoomView.js │ │ │ ├── InsideZoomModel.js │ │ │ ├── InsideZoomView.js │ │ │ ├── SelectZoomModel.js │ │ │ ├── SelectZoomView.js │ │ │ ├── SliderZoomModel.js │ │ │ ├── SliderZoomView.js │ │ │ ├── dataZoomAction.js │ │ │ ├── dataZoomProcessor.js │ │ │ ├── helper.js │ │ │ ├── history.js │ │ │ ├── roams.js │ │ │ └── typeDefaulter.js │ │ ├── dataZoomInside.js │ │ ├── dataZoomSelect.js │ │ ├── geo.js │ │ ├── geo │ │ │ └── GeoView.js │ │ ├── graphic.js │ │ ├── grid.js │ │ ├── helper │ │ │ ├── BrushController.js │ │ │ ├── MapDraw.js │ │ │ ├── RoamController.js │ │ │ ├── brushHelper.js │ │ │ ├── interactionMutex.js │ │ │ ├── listComponent.js │ │ │ ├── selectableMixin.js │ │ │ └── sliderMove.js │ │ ├── legend.js │ │ ├── legend │ │ │ ├── LegendModel.js │ │ │ ├── LegendView.js │ │ │ ├── legendAction.js │ │ │ └── legendFilter.js │ │ ├── markArea.js │ │ ├── markLine.js │ │ ├── markPoint.js │ │ ├── marker │ │ │ ├── MarkAreaModel.js │ │ │ ├── MarkAreaView.js │ │ │ ├── MarkLineModel.js │ │ │ ├── MarkLineView.js │ │ │ ├── MarkPointModel.js │ │ │ ├── MarkPointView.js │ │ │ ├── MarkerModel.js │ │ │ ├── MarkerView.js │ │ │ └── markerHelper.js │ │ ├── parallel.js │ │ ├── parallelAxis.js │ │ ├── polar.js │ │ ├── radar.js │ │ ├── radar │ │ │ └── RadarView.js │ │ ├── radiusAxis.js │ │ ├── singleAxis.js │ │ ├── timeline.js │ │ ├── timeline │ │ │ ├── SliderTimelineModel.js │ │ │ ├── SliderTimelineView.js │ │ │ ├── TimelineAxis.js │ │ │ ├── TimelineModel.js │ │ │ ├── TimelineView.js │ │ │ ├── preprocessor.js │ │ │ ├── timelineAction.js │ │ │ └── typeDefaulter.js │ │ ├── title.js │ │ ├── toolbox.js │ │ ├── toolbox │ │ │ ├── ToolboxModel.js │ │ │ ├── ToolboxView.js │ │ │ ├── feature │ │ │ │ ├── Brush.js │ │ │ │ ├── DataView.js │ │ │ │ ├── DataZoom.js │ │ │ │ ├── MagicType.js │ │ │ │ ├── Restore.js │ │ │ │ └── SaveAsImage.js │ │ │ └── featureManager.js │ │ ├── tooltip.js │ │ ├── tooltip │ │ │ ├── TooltipContent.js │ │ │ ├── TooltipModel.js │ │ │ └── TooltipView.js │ │ ├── visualMap.js │ │ ├── visualMap │ │ │ ├── ContinuousModel.js │ │ │ ├── ContinuousView.js │ │ │ ├── PiecewiseModel.js │ │ │ ├── PiecewiseView.js │ │ │ ├── VisualMapModel.js │ │ │ ├── VisualMapView.js │ │ │ ├── helper.js │ │ │ ├── preprocessor.js │ │ │ ├── typeDefaulter.js │ │ │ ├── visualEncoding.js │ │ │ └── visualMapAction.js │ │ ├── visualMapContinuous.js │ │ └── visualMapPiecewise.js │ ├── coord │ │ ├── Axis.js │ │ ├── View.js │ │ ├── axisDefault.js │ │ ├── axisHelper.js │ │ ├── axisModelCommonMixin.js │ │ ├── axisModelCreator.js │ │ ├── cartesian │ │ │ ├── Axis2D.js │ │ │ ├── AxisModel.js │ │ │ ├── Cartesian.js │ │ │ ├── Cartesian2D.js │ │ │ ├── Grid.js │ │ │ ├── GridModel.js │ │ │ └── axisLabelInterval.js │ │ ├── geo │ │ │ ├── Geo.js │ │ │ ├── GeoModel.js │ │ │ ├── Region.js │ │ │ ├── fix │ │ │ │ ├── geoCoord.js │ │ │ │ ├── nanhai.js │ │ │ │ └── textCoord.js │ │ │ ├── geoCreator.js │ │ │ └── parseGeoJson.js │ │ ├── parallel │ │ │ ├── AxisModel.js │ │ │ ├── Parallel.js │ │ │ ├── ParallelAxis.js │ │ │ ├── ParallelModel.js │ │ │ ├── parallelCreator.js │ │ │ └── parallelPreprocessor.js │ │ ├── polar │ │ │ ├── AngleAxis.js │ │ │ ├── AxisModel.js │ │ │ ├── Polar.js │ │ │ ├── PolarModel.js │ │ │ ├── RadiusAxis.js │ │ │ └── polarCreator.js │ │ ├── radar │ │ │ ├── IndicatorAxis.js │ │ │ ├── Radar.js │ │ │ └── RadarModel.js │ │ └── single │ │ │ ├── AxisModel.js │ │ │ ├── Single.js │ │ │ ├── SingleAxis.js │ │ │ └── singleCreator.js │ ├── data │ │ ├── DataDiffer.js │ │ ├── Graph.js │ │ ├── List.js │ │ ├── Tree.js │ │ └── helper │ │ │ ├── completeDimensions.js │ │ │ └── linkList.js │ ├── echarts.js │ ├── layout │ │ ├── barGrid.js │ │ └── points.js │ ├── loading │ │ └── default.js │ ├── model │ │ ├── Component.js │ │ ├── Global.js │ │ ├── Model.js │ │ ├── OptionManager.js │ │ ├── Series.js │ │ ├── globalDefault.js │ │ └── mixin │ │ │ ├── areaStyle.js │ │ │ ├── boxLayout.js │ │ │ ├── colorPalette.js │ │ │ ├── itemStyle.js │ │ │ ├── lineStyle.js │ │ │ ├── makeStyleMapper.js │ │ │ └── textStyle.js │ ├── preprocessor │ │ ├── backwardCompat.js │ │ └── helper │ │ │ └── compatStyle.js │ ├── processor │ │ ├── dataFilter.js │ │ └── dataSample.js │ ├── scale │ │ ├── Interval.js │ │ ├── Log.js │ │ ├── Ordinal.js │ │ ├── Scale.js │ │ └── Time.js │ ├── util │ │ ├── KDTree.js │ │ ├── animation.js │ │ ├── array │ │ │ └── nest.js │ │ ├── clazz.js │ │ ├── component.js │ │ ├── format.js │ │ ├── graphic.js │ │ ├── layout.js │ │ ├── model.js │ │ ├── number.js │ │ ├── quickSelect.js │ │ ├── symbol.js │ │ └── throttle.js │ ├── view │ │ ├── Chart.js │ │ └── Component.js │ └── visual │ │ ├── VisualMapping.js │ │ ├── dataColor.js │ │ ├── seriesColor.js │ │ ├── symbol.js │ │ ├── visualDefault.js │ │ └── visualSolution.js ├── test │ ├── -primary-cases.html │ ├── README.md │ ├── allZero.html │ ├── area.html │ ├── area2.html │ ├── areaLineUpdate.html │ ├── axes.html │ ├── axis-extrema.html │ ├── axis.html │ ├── bar-large.html │ ├── bar.html │ ├── bar2.html │ ├── bar3.html │ ├── bmap.html │ ├── boxplot-multi.html │ ├── boxplot.html │ ├── brush.html │ ├── brush2.html │ ├── candlestick.html │ ├── candlestickConnect.html │ ├── chord.html │ ├── color-mix-aqi.html │ ├── config.js │ ├── connect-manually.html │ ├── connect.html │ ├── connect2.html │ ├── css-transform.html │ ├── data │ │ ├── Michelson-Morley.json.js │ │ ├── aqi │ │ │ ├── BJdata.js │ │ │ ├── GZdata.js │ │ │ ├── SHdata.js │ │ │ └── processAQI.js │ │ ├── disk.tree.js │ │ ├── energy.json │ │ ├── hangzhou-tracks.json │ │ ├── les-miserables.gexf │ │ ├── lines-bus.json │ │ ├── masterPainterColorChoice.json │ │ ├── nutrients.json │ │ ├── obama_budget_proposal_2012.tree.js │ │ ├── option-view.json │ │ ├── option-view2.json │ │ ├── product.json │ │ ├── rainfall.json.js │ │ ├── security-sh-2013.json.js │ │ ├── stock-DJI.json.js │ │ └── timelineGDP.js │ ├── dataView.html │ ├── dataZoom-axes.html │ ├── dataZoom-axis-type.html │ ├── dataZoom-cartesian-h.html │ ├── dataZoom-cartesian-v.html │ ├── dataZoom-dataShadow.html │ ├── dataZoom-dataShadow0.html │ ├── dataZoom-dataShadow1.html │ ├── dataZoom-dataShadow2.html │ ├── dataZoom-dynamic.html │ ├── dataZoom-geo.html │ ├── dataZoom-rainfall-connect.html │ ├── dataZoom-rainfall-inside.html │ ├── dataZoom-rainfall.html │ ├── dataZoom-scatter-category.html │ ├── dataZoom-scatter-hv-polar.html │ ├── dataZoom-scatter-hv.html │ ├── dataZoom-scatter-toolbox.html │ ├── dataZoomHighPrecision.html │ ├── diff.html │ ├── dynamicData.html │ ├── dynamicData2.html │ ├── dynamicData3.html │ ├── effectScatter.html │ ├── esl.js │ ├── force.html │ ├── force2.html │ ├── force3.html │ ├── funnel.html │ ├── gauge.html │ ├── geo-map.html │ ├── geoLine.html │ ├── geoScatter.html │ ├── getOption.html │ ├── graph-grid.html │ ├── graph-simple.html │ ├── graph.html │ ├── graphicOption.html │ ├── heatmap-large.html │ ├── heatmap-map.html │ ├── heatmap.html │ ├── ie8.html │ ├── largeLine.html │ ├── lazyUpdate.html │ ├── lib │ │ ├── dat.gui.min.js │ │ ├── draggable.js │ │ ├── facePrint.js │ │ ├── jquery.min.js │ │ └── perlin.js │ ├── line-visual.html │ ├── line.html │ ├── lines-bus.html │ ├── lines-symbol.html │ ├── lines-track.html │ ├── loading.html │ ├── logScale.html │ ├── map-contour.html │ ├── map-parallel.html │ ├── map.html │ ├── mapWorld.html │ ├── markArea.html │ ├── markLine.html │ ├── markPoint.html │ ├── masterPainterColorChoice.html │ ├── media-dataZoom.html │ ├── media-finance.html │ ├── media-pie.html │ ├── mix.html │ ├── mobileBench.html │ ├── multipleGrid.html │ ├── parallel-aqi.html │ ├── parallel-nutrients.html │ ├── pictorial-repeat.html │ ├── pictorial-single.html │ ├── pie-calculable.html │ ├── pie.html │ ├── pie2.html │ ├── pie3.html │ ├── pieDynamic.html │ ├── polarLine.html │ ├── polarLine2.html │ ├── polarScatter.html │ ├── punchCard.html │ ├── radar.html │ ├── radar2.html │ ├── radar3.html │ ├── radar4.html │ ├── reset.css │ ├── roseType.html │ ├── sankey.html │ ├── scale-integer.html │ ├── scatter-single-axis.html │ ├── scatter.html │ ├── scatterMatrix.html │ ├── selectedMode.html │ ├── showTip.html │ ├── singleAxisScales.html │ ├── symbol.html │ ├── theme.html │ ├── themeRiver.html │ ├── themeRiver2.html │ ├── timeScale.html │ ├── timeline-finance.html │ ├── timeline-layout.html │ ├── tooltip.html │ ├── touch-slide.html │ ├── touch-test.html │ ├── touch-tooltip.html │ ├── treemap-disk.html │ ├── treemap-obama.html │ ├── treemap-option.html │ ├── treemap-option2.html │ ├── treemap-simple.html │ ├── treemap-visual.html │ ├── ut │ │ ├── .jshintrc │ │ ├── MIT.LICENSE │ │ ├── config.js │ │ ├── configure │ │ ├── core │ │ │ ├── uiHelper.js │ │ │ └── utHelper.js │ │ ├── lib │ │ │ ├── canteen.js │ │ │ ├── imagediff.js │ │ │ └── jasmine-2.3.4 │ │ │ │ ├── boot.js │ │ │ │ ├── console.js │ │ │ │ ├── jasmine-html.js │ │ │ │ ├── jasmine.css │ │ │ │ ├── jasmine.js │ │ │ │ └── jasmine_favicon.png │ │ ├── spec │ │ │ ├── api │ │ │ │ ├── containPixel.js │ │ │ │ ├── converter.js │ │ │ │ └── getVisual.js │ │ │ ├── component │ │ │ │ ├── dataZoom │ │ │ │ │ └── helper.js │ │ │ │ ├── graphic │ │ │ │ │ └── setOption.js │ │ │ │ └── visualMap │ │ │ │ │ └── setOption.js │ │ │ ├── data │ │ │ │ └── List.js │ │ │ ├── model │ │ │ │ ├── Component.js │ │ │ │ ├── Global.js │ │ │ │ └── timelineOptions.js │ │ │ ├── scale │ │ │ │ └── interval.js │ │ │ ├── ui │ │ │ │ ├── config.js │ │ │ │ ├── legend.js │ │ │ │ ├── title.js │ │ │ │ ├── title.subtextStyle.js │ │ │ │ └── title.textStyle.js │ │ │ ├── util │ │ │ │ ├── graphic.js │ │ │ │ ├── model.js │ │ │ │ └── number.js │ │ │ └── zr │ │ │ │ └── core │ │ │ │ └── util.js │ │ ├── ui.html │ │ ├── ut.html │ │ └── ut.js │ ├── visualMap-categories.html │ ├── visualMap-continuous.html │ ├── visualMap-layout.html │ ├── visualMap-opacity.html │ ├── visualMap-pieces.html │ ├── visualMap-scatter-colorAndSymbol.html │ ├── visualMap-scatter-symbolSize.html │ ├── webkit-dep.html │ └── worldPopulationBubble.html ├── theme │ ├── dark.js │ ├── infographic.js │ ├── macarons.js │ ├── roma.js │ ├── shine.js │ ├── tool │ │ ├── option │ │ │ ├── area.js │ │ │ ├── bar.js │ │ │ ├── graph.js │ │ │ ├── map.js │ │ │ ├── pie.js │ │ │ └── scatter.js │ │ └── thumb.js │ └── vintage.js └── webpack.config.js └── zrender ├── README.md ├── demo ├── demo1 │ ├── demo1.html │ ├── demo2.html │ ├── demo3-chart.html │ ├── demo3-chart2.html │ ├── demo3-chartHasHover.html │ ├── readme.md │ └── test.html └── libs │ └── esl.js └── src ├── Element.js ├── Handler.js ├── Layer.js ├── Painter.js ├── Storage.js ├── animation ├── Animation.js ├── Animator.js ├── Clip.js ├── easing.js └── requestAnimationFrame.js ├── config.js ├── contain ├── arc.js ├── cubic.js ├── line.js ├── path.js ├── polygon.js ├── quadratic.js ├── text.js ├── util.js └── windingLine.js ├── container └── Group.js ├── core ├── BoundingRect.js ├── GestureMgr.js ├── LRU.js ├── PathProxy.js ├── arrayDiff.js ├── bbox.js ├── curve.js ├── env.js ├── event.js ├── guid.js ├── log.js ├── matrix.js ├── timsort.js ├── util.js └── vector.js ├── dom └── HandlerProxy.js ├── graphic ├── CompoundPath.js ├── Displayable.js ├── Gradient.js ├── Image.js ├── LinearGradient.js ├── Path.js ├── Pattern.js ├── RadialGradient.js ├── States.js ├── Style.js ├── Text.js ├── helper │ ├── poly.js │ ├── roundRect.js │ ├── smoothBezier.js │ └── smoothSpline.js ├── mixin │ ├── RectText.js │ └── Stateful.js └── shape │ ├── Arc.js │ ├── BezierCurve.js │ ├── Circle.js │ ├── Droplet.js │ ├── Ellipse.js │ ├── Heart.js │ ├── Isogon.js │ ├── Line.js │ ├── Polygon.js │ ├── Polyline.js │ ├── Rect.js │ ├── Ring.js │ ├── Rose.js │ ├── Sector.js │ ├── Star.js │ └── Trochoid.js ├── mixin ├── Animatable.js ├── Draggable.js ├── Eventful.js └── Transformable.js ├── readme.md ├── svg ├── Painter.js ├── core.js ├── graphic.js └── svg.js ├── tool ├── color.js ├── path.js └── transformPath.js ├── vml ├── Painter.js ├── core.js ├── graphic.js └── vml.js └── zrender.js /.gitignore: -------------------------------------------------------------------------------- 1 | /echarts/node_modules 2 | /echarts/lib 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 主要分为两个部分,第一个部分是echarts底层zrender源码,第二个部分是echarts源码。 2 | 3 | 均是基于3.x版本。 4 | 5 | **zrender博文地址** 6 | - [ECharts 3.0底层zrender 3.x源码分析1-总体架构](http://blog.csdn.net/future_todo/article/details/54341386) 7 | - [ECharts 3.0底层zrender 3.x源码分析2-Painter(V层)](http://blog.csdn.net/future_todo/article/details/54341426) 8 | - [ECharts 3.0底层zrender 3.x源码分析3-Handler(C层)](http://blog.csdn.net/future_todo/article/details/54341458) 9 | 10 | **echarts 博文地址** 11 | - [ECharts 3.0源码简要分析1-总体架构](http://blog.csdn.net/future_todo/article/details/60956942) 12 | 13 | 或者在[仓库](https://github.com/zrysmt/Blog)里面查看 14 | > https://github.com/zrysmt/Blog -------------------------------------------------------------------------------- /echarts/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | charset = utf-8 6 | trim_trailing_whitespace = true 7 | insert_final_newline = true 8 | 9 | [**.js] 10 | indent_style = space 11 | indent_size = 4 12 | 13 | [**.css] 14 | indent_style = space 15 | indent_size = 4 16 | 17 | [**.less] 18 | indent_style = space 19 | indent_size = 4 20 | 21 | [**.styl] 22 | indent_style = space 23 | indent_size = 4 24 | 25 | [**.html] 26 | indent_style = space 27 | indent_size = 4 28 | 29 | [**.tpl] 30 | indent_style = space 31 | indent_size = 4 32 | 33 | [**.json] 34 | indent_style = space 35 | indent_size = 4 36 | 37 | [*.md] 38 | trim_trailing_whitespace = false 39 | -------------------------------------------------------------------------------- /echarts/.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 如果你想帮助 **ECharts** 的话,请首先阅读指导原则: 2 | 3 | - 如果你希望提 bug: 4 | 5 | - 清楚地描述问题,注意:**别人是否能通过你的描述理解这是什么问题**。 6 | - 说明版本(ECharts 版本,浏览器版本,设备、操作系统版本等) 7 | - 最好提供完整的ECharts option,截图或线上实例(可以使用JSFiddle/JSBin/Codepen)。 8 | 9 | - 如果你想问问题: 10 | 11 | - 首先是否在这些文档中寻找过问题的答案:[option文档](http://echarts.baidu.com/option.html),[API文档](http://echarts.baidu.com/api.html),[教程](http://echarts.baidu.com/tutorial.html) 12 | - 简单的问题,可以在QQ群中求助(群号:465958031) 13 | 14 | - 如何取得能运行的 `ECharts option` 15 | 16 | 一个参考方式: 17 | 在你的程序的 18 | ```javascript 19 | chart.setOption(option); 20 | ``` 21 | 前加入这句话 22 | ```javascript 23 | console.log(JSON.stringify(option, null, 4)); 24 | ``` 25 | 26 | 然后打开浏览器的调试工具(如 `Chrome Deverloper Tool`)的 `控制台(console)`,可以得到option输出。 27 | 28 | -------------------------------------------------------------------------------- /echarts/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | ### One-line summary [问题简述] 7 | 8 | 9 | 10 | 11 | 12 | ### Version & Environment [版本及环境] 13 | + ECharts version [ECharts 版本]: 14 | + Browser version [浏览器类型和版本]: 15 | + OS Version [操作系统类型和版本]: 16 | 17 | 18 | 19 | 20 | 21 | ### Expected behaviour [期望结果] 22 | 23 | 24 | 25 | 26 | 27 | ### ECharts option [ECharts配置项] 28 | 29 | 30 | ```javascript 31 | option = { 32 | 33 | } 34 | 35 | ``` 36 | 37 | 38 | 39 | 40 | ### Other comments [其他信息] 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /echarts/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "bitwise": false, 3 | "camelcase": true, 4 | "curly": true, 5 | "es3": true, 6 | "eqeqeq": false, 7 | "forin": false, 8 | "immed": true, 9 | "latedef": false, 10 | "newcap": true, 11 | "noarg": false, 12 | "noempty": true, 13 | "nonew": true, 14 | "plusplus": false, 15 | "quotmark": "single", 16 | "regexp": false, 17 | "undef": true, 18 | "unused": "vars", 19 | "strict": false, 20 | "trailing": false, 21 | "maxparams": 20, 22 | "maxdepth": 6, 23 | "maxlen": 200, 24 | 25 | "asi": false, 26 | "boss": false, 27 | "debug": false, 28 | "eqnull": true, 29 | "esnext": false, 30 | "evil": true, 31 | "expr": true, 32 | "funcscope": false, 33 | "globalstrict": false, 34 | "iterator": false, 35 | "lastsemic": false, 36 | "laxbreak": true, 37 | "laxcomma": false, 38 | "loopfunc": false, 39 | "multistr": false, 40 | "onecase": false, 41 | "proto": false, 42 | "regexdash": false, 43 | "scripturl": false, 44 | "smarttabs": false, 45 | "shadow": true, 46 | "sub": true, 47 | "supernew": false, 48 | "validthis": true, 49 | 50 | "browser": true, 51 | "couch": false, 52 | "devel": true, 53 | "dojo": false, 54 | "jquery": true, 55 | "mootools": false, 56 | "node": false, 57 | "nonstandard": false, 58 | "prototypejs": false, 59 | "rhino": false, 60 | "wsh": false, 61 | 62 | "nomen": false, 63 | "onevar": false, 64 | "passfail": false, 65 | "white": false, 66 | 67 | "predef": [ 68 | "define", 69 | "require", 70 | "__DEV__", 71 | "global" 72 | ] 73 | } -------------------------------------------------------------------------------- /echarts/.npmignore: -------------------------------------------------------------------------------- 1 | /build 2 | /test 3 | /map/tool 4 | /theme/tool 5 | /theme/thumb 6 | todo 7 | npm-debug.log 8 | /benchmark 9 | -------------------------------------------------------------------------------- /echarts/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Baidu Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 17 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | 24 | The views and conclusions contained in the software and documentation are those 25 | of the authors and should not be interpreted as representing official policies, 26 | either expressed or implied, of the FreeBSD Project. -------------------------------------------------------------------------------- /echarts/asset/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrysmt/echarts3/2079e13fcbfb249b7d929732c8c6dbd7b47dfde1/echarts/asset/logo.png -------------------------------------------------------------------------------- /echarts/benchmark/gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var watch = require('gulp-watch'); 3 | var browserSync = require('browser-sync').create(); 4 | 5 | gulp.task('serve', function() { 6 | browserSync.init({ 7 | server: '../', 8 | startPath: 'benchmark' 9 | }); 10 | 11 | gulp.watch(['*.html', 'src/*.js']).on('change', browserSync.reload); 12 | }); 13 | 14 | gulp.task('default', ['serve']); 15 | -------------------------------------------------------------------------------- /echarts/benchmark/src/testCase.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file TestCase is the class for each test case of EChart 3 | * @author Wenli Zhang 4 | */ 5 | 6 | define(function (require) { 7 | 8 | /** 9 | * set up test case 10 | * 11 | * @param {string} name name of test case 12 | * @param {Object} option ECharts option 13 | */ 14 | function TestCase(name, option) { 15 | 16 | this.name = name; 17 | this.option = option; 18 | 19 | } 20 | 21 | /** 22 | * run test case and return elapsed time 23 | * 24 | * @param {iterations} iterations number of iterations 25 | * @return {number} elapsed time 26 | */ 27 | TestCase.prototype.runTime = function (iterations) { 28 | // run for multi times 29 | var total = 0; 30 | for (var i = 0; i < iterations; ++i) { 31 | total += runTime(this.option); 32 | } 33 | return total / iterations; 34 | }; 35 | 36 | function runTime(option) { 37 | var container = document.createElement('div'); 38 | container.style.width = '800px'; 39 | container.style.height = '600px'; 40 | 41 | var start = new Date(); 42 | 43 | var chart = echarts.init(container); 44 | chart.setOption(option); 45 | 46 | var end = new Date(); 47 | 48 | chart.dispose(); 49 | 50 | return end - start; 51 | } 52 | 53 | return TestCase; 54 | 55 | }); 56 | -------------------------------------------------------------------------------- /echarts/build/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | basePath=$(cd `dirname $0`; pwd) 5 | cd ${basePath}/../ 6 | rm -r dist 7 | 8 | npm run prepublish 9 | 10 | ./node_modules/.bin/webpack 11 | ./node_modules/.bin/webpack -p 12 | ./node_modules/.bin/webpack --config extension/webpack.config.js 13 | ./node_modules/.bin/webpack --config extension/webpack.config.js -p 14 | 15 | 16 | -------------------------------------------------------------------------------- /echarts/build/optimize.js: -------------------------------------------------------------------------------- 1 | var UglifyJS = require('uglify-js'); 2 | var fs = require('fs'); 3 | var etpl = require('etpl'); 4 | var argv = require('optimist').argv; 5 | 6 | etpl.config({ 7 | commandOpen: '/**', 8 | commandClose: '*/' 9 | }); 10 | 11 | var mode = argv.m || 'all'; 12 | var configPath = mode === 'all' ? 'config/echarts.js' : 'config/echarts.' + mode + '.js'; 13 | var outPath = mode === 'all' ? '../dist/echarts.js' : '../dist/echarts.' + mode + '.js'; 14 | 15 | var config = eval('(' + fs.readFileSync(configPath, 'utf-8') + ')'); 16 | var mainCode = fs.readFileSync(outPath, 'utf-8'); 17 | var startCode = fs.readFileSync('wrap/start.js', 'utf-8'); 18 | var nutCode = fs.readFileSync('wrap/nut.js', 'utf-8'); 19 | var endCode = fs.readFileSync('wrap/end.js', 'utf-8'); 20 | 21 | endCode = etpl.compile(endCode)({ 22 | parts: config.include 23 | }); 24 | 25 | // FIXME 26 | var sourceCode = [startCode, nutCode, require('./mangleString')(mainCode), endCode].join('\n'); 27 | 28 | var ast = UglifyJS.parse(sourceCode); 29 | /* jshint camelcase: false */ 30 | // compressor needs figure_out_scope too 31 | ast.figure_out_scope(); 32 | ast = ast.transform(UglifyJS.Compressor( {} )); 33 | 34 | // need to figure out scope again so mangler works optimally 35 | ast.figure_out_scope(); 36 | ast.compute_char_frequency(); 37 | ast.mangle_names(); 38 | 39 | fs.writeFileSync(outPath, [startCode, nutCode, mainCode, endCode].join('\n'), 'utf-8'); 40 | fs.writeFileSync(outPath.replace('.js', '.min.js'), ast.print_to_string(), 'utf-8'); -------------------------------------------------------------------------------- /echarts/extension/bmap/BMapModel.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | function v2Equal(a, b) { 4 | return a && b && a[0] === b[0] && a[1] === b[1]; 5 | } 6 | 7 | return require('echarts').extendComponentModel({ 8 | type: 'bmap', 9 | 10 | getBMap: function () { 11 | // __bmap is injected when creating BMapCoordSys 12 | return this.__bmap; 13 | }, 14 | 15 | setCenterAndZoom: function (center, zoom) { 16 | this.option.center = center; 17 | this.option.zoom = zoom; 18 | }, 19 | 20 | centerOrZoomChanged: function (center, zoom) { 21 | var option = this.option; 22 | return !(v2Equal(center, option.center) && zoom === option.zoom); 23 | }, 24 | 25 | defaultOption: { 26 | 27 | center: [104.114129, 37.550339], 28 | 29 | zoom: 5, 30 | 31 | mapStyle: {}, 32 | 33 | roam: false 34 | } 35 | }); 36 | }); -------------------------------------------------------------------------------- /echarts/extension/bmap/README.md: -------------------------------------------------------------------------------- 1 | ## 百度地图扩展 2 | 3 | ECharts 百度地图扩展,可以在百度地图上展现 [点图](http://echarts.baidu.com/option.html#series-scatter),[线图](http://echarts.baidu.com/option.html#series-line),[热力图](http://echarts.baidu.com/option.html#series-heatmap) 等可视化。 4 | 5 | 6 | ### 示例 7 | 8 | [全国主要城市空气质量](http://echarts.baidu.com/demo.html#effectScatter-bmap) 9 | 10 | [北京公交路线](http://echarts.baidu.com/demo.html#lines-bmap-bus) 11 | 12 | [北京公交路线特效](http://echarts.baidu.com/demo.html#lines-bmap-effect) 13 | 14 | [北京公交路线特效](http://echarts.baidu.com/demo.html#lines-bmap-effect) 15 | 16 | [杭州热门步行路线](http://echarts.baidu.com/demo.html#heatmap-bmap) 17 | 18 | 19 | ### 引入 20 | 21 | 可以直接引入打包好的扩展文件和百度地图的 jssdk 22 | 23 | ```html 24 | 25 | 26 | 27 | 28 | 29 | 30 | ``` 31 | 32 | 如果是 webpack 打包,也可以 require 引入 33 | 34 | ```js 35 | require('echarts'); 36 | require('echarts/extension/bmap/bmap'); 37 | ``` 38 | 39 | 插件会自动注册相应的组件。 40 | 41 | ### 使用 42 | 43 | 扩展主要提供了跟 geo 一样的坐标系和底图的绘制,因此配置方式非常简单,如下 44 | 45 | ```js 46 | option = { 47 | // 加载 bmap 组件 48 | bmap: { 49 | // 百度地图中心经纬度 50 | center: [120.13066322374, 30.240018034923], 51 | // 百度地图缩放 52 | zoom: 14, 53 | // 是否开启拖拽缩放,可以只设置 'scale' 或者 'move' 54 | roam: true, 55 | // 百度地图的自定义样式,见 http://developer.baidu.com/map/jsdevelop-11.htm 56 | mapStyle: {} 57 | }, 58 | series: [{ 59 | type: 'scatter', 60 | // 使用百度地图坐标系 61 | coordinateSystem: 'bmap', 62 | // 数据格式跟在 geo 坐标系上一样,每一项都是 [经度,纬度,数值大小,其它维度...] 63 | data: [ [120, 30, 1] ] 64 | }] 65 | } 66 | 67 | // 获取百度地图实例,使用百度地图自带的控件 68 | var bmap = chart.getModel().getComponent('bmap').getBMap(); 69 | bmap.addControl(new BMap.MapTypeControl()); 70 | ``` 71 | 72 | 73 | -------------------------------------------------------------------------------- /echarts/extension/bmap/bmap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * BMap component extension 3 | */ 4 | define(function (require) { 5 | 6 | require('echarts').registerCoordinateSystem( 7 | 'bmap', require('./BMapCoordSys') 8 | ); 9 | require('./BMapModel'); 10 | require('./BMapView'); 11 | 12 | // Action 13 | require('echarts').registerAction({ 14 | type: 'bmapRoam', 15 | event: 'bmapRoam', 16 | update: 'updateLayout' 17 | }, function (payload, ecModel) { 18 | ecModel.eachComponent('bmap', function (bMapModel) { 19 | var bmap = bMapModel.getBMap(); 20 | var center = bmap.getCenter(); 21 | bMapModel.setCenterAndZoom([center.lng, center.lat], bmap.getZoom()); 22 | }); 23 | }); 24 | 25 | return { 26 | version: '1.0.0' 27 | }; 28 | }); -------------------------------------------------------------------------------- /echarts/extension/dataTool/index.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | var echarts = require('echarts'); 3 | echarts.dataTool = { 4 | version: '1.0.0', 5 | gexf: require('./gexf'), 6 | prepareBoxplotData: require('./prepareBoxplotData') 7 | }; 8 | return echarts.dataTool; 9 | }); -------------------------------------------------------------------------------- /echarts/extension/echarts.js: -------------------------------------------------------------------------------- 1 | define('echarts', [], function () {return echarts;}); -------------------------------------------------------------------------------- /echarts/extension/webpack.config.js: -------------------------------------------------------------------------------- 1 | var PROD = process.argv.indexOf('-p') >= 0; 2 | 3 | module.exports = { 4 | entry: { 5 | 'bmap': __dirname + '/../extension/bmap/bmap.js', 6 | 'dataTool': __dirname + '/../extension/dataTool' 7 | }, 8 | output: { 9 | libraryTarget: 'umd', 10 | library: ['echarts', '[name]'], 11 | path: __dirname + '/../dist/extension', 12 | filename: PROD ? '[name].min.js' : '[name].js' 13 | }, 14 | externals: { 15 | 'echarts': 'echarts' 16 | } 17 | }; -------------------------------------------------------------------------------- /echarts/index.common.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Export echarts as CommonJS module 3 | */ 4 | module.exports = require('./lib/echarts'); 5 | 6 | require('./lib/chart/line'); 7 | require('./lib/chart/bar'); 8 | require('./lib/chart/pie'); 9 | require('./lib/chart/scatter'); 10 | require('./lib/component/graphic'); 11 | require('./lib/component/tooltip'); 12 | require('./lib/component/legend'); 13 | 14 | require('./lib/component/grid'); 15 | require('./lib/component/title'); 16 | 17 | require('./lib/component/markPoint'); 18 | require('./lib/component/markLine'); 19 | require('./lib/component/markArea'); 20 | require('./lib/component/dataZoom'); 21 | require('./lib/component/toolbox'); 22 | 23 | require('zrender/lib/vml/vml'); -------------------------------------------------------------------------------- /echarts/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Export echarts as CommonJS module 3 | */ 4 | module.exports = require('./lib/echarts'); 5 | 6 | // Import all charts and components 7 | require('./lib/chart/line'); 8 | require('./lib/chart/bar'); 9 | require('./lib/chart/pie'); 10 | require('./lib/chart/scatter'); 11 | require('./lib/chart/radar'); 12 | 13 | require('./lib/chart/map'); 14 | require('./lib/chart/treemap'); 15 | require('./lib/chart/graph'); 16 | require('./lib/chart/gauge'); 17 | require('./lib/chart/funnel'); 18 | require('./lib/chart/parallel'); 19 | require('./lib/chart/sankey'); 20 | require('./lib/chart/boxplot'); 21 | require('./lib/chart/candlestick'); 22 | require('./lib/chart/effectScatter'); 23 | require('./lib/chart/lines'); 24 | require('./lib/chart/heatmap'); 25 | require('./lib/chart/pictorialBar'); 26 | 27 | require('./lib/component/graphic'); 28 | require('./lib/component/grid'); 29 | require('./lib/component/legend'); 30 | require('./lib/component/tooltip'); 31 | require('./lib/component/polar'); 32 | require('./lib/component/geo'); 33 | require('./lib/component/parallel'); 34 | require('./lib/component/singleAxis'); 35 | require('./lib/component/brush'); 36 | 37 | require('./lib/component/title'); 38 | 39 | require('./lib/component/dataZoom'); 40 | require('./lib/component/visualMap'); 41 | 42 | require('./lib/component/markPoint'); 43 | require('./lib/component/markLine'); 44 | require('./lib/component/markArea'); 45 | 46 | require('./lib/component/timeline'); 47 | require('./lib/component/toolbox'); 48 | 49 | require('zrender/lib/vml/vml'); 50 | -------------------------------------------------------------------------------- /echarts/index.simple.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Export echarts as CommonJS module 3 | */ 4 | module.exports = require('./lib/echarts'); 5 | 6 | require('./lib/chart/line'); 7 | require('./lib/chart/bar'); 8 | require('./lib/chart/pie'); 9 | require('./lib/component/grid'); -------------------------------------------------------------------------------- /echarts/map/json/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} -------------------------------------------------------------------------------- /echarts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "echarts", 3 | "version": "3.3.2", 4 | "description": "A powerful charting and visualization library for browser", 5 | "keywords": [ 6 | "visualization", 7 | "canvas" 8 | ], 9 | "homepage": "http://echarts.baidu.com/", 10 | "author": [ 11 | { 12 | "name": "Kenner", 13 | "email": "kener.linfeng@gmail.com" 14 | }, 15 | { 16 | "name": "Yi Shen", 17 | "url": "https://github.com/pissang" 18 | }, 19 | { 20 | "name": "Shuang Su", 21 | "url": "https://github.com/100pah" 22 | } 23 | ], 24 | "contributors": [ 25 | { 26 | "name": "erik", 27 | "email": "errorrik@gmail.com" 28 | } 29 | ], 30 | "repository": { 31 | "type": "git", 32 | "url": "https://github.com/ecomfe/echarts.git" 33 | }, 34 | "scripts": { 35 | "prepublish": "node build/amd2common.js" 36 | }, 37 | "dependencies": { 38 | "zrender": "^3.2.1" 39 | }, 40 | "devDependencies": { 41 | "coordtransform": "^2.0.2", 42 | "escodegen": "^1.8.0", 43 | "esprima": "^2.7.2", 44 | "estraverse": "^4.1.1", 45 | "fs-extra": "^0.26.5", 46 | "glob": "^7.0.0", 47 | "webpack": "^1.12.13", 48 | "zrender": "^3.2.2" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /echarts/src/ExtensionAPI.js: -------------------------------------------------------------------------------- 1 | define(function(require) { 2 | 3 | 'use strict'; 4 | 5 | var zrUtil = require('zrender/core/util'); 6 | 7 | var echartsAPIList = [ 8 | 'getDom', 'getZr', 'getWidth', 'getHeight', 'dispatchAction', 'isDisposed', 9 | 'on', 'off', 'getDataURL', 'getConnectedDataURL', 'getModel', 'getOption' 10 | ]; 11 | 12 | function ExtensionAPI(chartInstance) { 13 | zrUtil.each(echartsAPIList, function (name) { 14 | this[name] = zrUtil.bind(chartInstance[name], chartInstance); 15 | }, this); 16 | } 17 | 18 | return ExtensionAPI; 19 | }); -------------------------------------------------------------------------------- /echarts/src/action/createDataSelectAction.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | var echarts = require('../echarts'); 3 | var zrUtil = require('zrender/core/util'); 4 | return function (seriesType, actionInfos) { 5 | zrUtil.each(actionInfos, function (actionInfo) { 6 | actionInfo.update = 'updateView'; 7 | /** 8 | * @payload 9 | * @property {string} seriesName 10 | * @property {string} name 11 | */ 12 | echarts.registerAction(actionInfo, function (payload, ecModel) { 13 | var selected = {}; 14 | ecModel.eachComponent( 15 | {mainType: 'series', subType: seriesType, query: payload}, 16 | function (seriesModel) { 17 | if (seriesModel[actionInfo.method]) { 18 | seriesModel[actionInfo.method](payload.name); 19 | } 20 | var data = seriesModel.getData(); 21 | // Create selected map 22 | data.each(function (idx) { 23 | var name = data.getName(idx); 24 | selected[name] = seriesModel.isSelected(name) || false; 25 | }); 26 | } 27 | ); 28 | return { 29 | name: payload.name, 30 | selected: selected 31 | }; 32 | }); 33 | }); 34 | }; 35 | }); -------------------------------------------------------------------------------- /echarts/src/action/geoRoam.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var zrUtil = require('zrender/core/util'); 4 | var roamHelper = require('./roamHelper'); 5 | 6 | var echarts = require('../echarts'); 7 | 8 | /** 9 | * @payload 10 | * @property {string} [componentType=series] 11 | * @property {number} [dx] 12 | * @property {number} [dy] 13 | * @property {number} [zoom] 14 | * @property {number} [originX] 15 | * @property {number} [originY] 16 | */ 17 | echarts.registerAction({ 18 | type: 'geoRoam', 19 | event: 'geoRoam', 20 | update: 'updateLayout' 21 | }, function (payload, ecModel) { 22 | var componentType = payload.componentType || 'series'; 23 | 24 | ecModel.eachComponent( 25 | { mainType: componentType, query: payload }, 26 | function (componentModel) { 27 | var geo = componentModel.coordinateSystem; 28 | if (geo.type !== 'geo') { 29 | return; 30 | } 31 | 32 | var res = roamHelper.updateCenterAndZoom( 33 | geo, payload, componentModel.get('scaleLimit') 34 | ); 35 | 36 | componentModel.setCenter 37 | && componentModel.setCenter(res.center); 38 | 39 | componentModel.setZoom 40 | && componentModel.setZoom(res.zoom); 41 | 42 | // All map series with same `map` use the same geo coordinate system 43 | // So the center and zoom must be in sync. Include the series not selected by legend 44 | if (componentType === 'series') { 45 | zrUtil.each(componentModel.seriesGroup, function (seriesModel) { 46 | seriesModel.setCenter(res.center); 47 | seriesModel.setZoom(res.zoom); 48 | }); 49 | } 50 | } 51 | ); 52 | }); 53 | }); -------------------------------------------------------------------------------- /echarts/src/action/roamHelper.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var roamHelper = {}; 4 | 5 | /** 6 | * @param {module:echarts/coord/View} view 7 | * @param {Object} payload 8 | * @param {Object} [zoomLimit] 9 | */ 10 | roamHelper.updateCenterAndZoom = function ( 11 | view, payload, zoomLimit 12 | ) { 13 | var previousZoom = view.getZoom(); 14 | var center = view.getCenter(); 15 | var zoom = payload.zoom; 16 | 17 | var point = view.dataToPoint(center); 18 | 19 | if (payload.dx != null && payload.dy != null) { 20 | point[0] -= payload.dx; 21 | point[1] -= payload.dy; 22 | 23 | var center = view.pointToData(point); 24 | view.setCenter(center); 25 | } 26 | if (zoom != null) { 27 | if (zoomLimit) { 28 | var zoomMin = zoomLimit.min || 0; 29 | var zoomMax = zoomLimit.max || Infinity; 30 | zoom = Math.max( 31 | Math.min(previousZoom * zoom, zoomMax), 32 | zoomMin 33 | ) / previousZoom; 34 | } 35 | 36 | // Zoom on given point(originX, originY) 37 | view.scale[0] *= zoom; 38 | view.scale[1] *= zoom; 39 | var position = view.position; 40 | var fixX = (payload.originX - position[0]) * (zoom - 1); 41 | var fixY = (payload.originY - position[1]) * (zoom - 1); 42 | 43 | position[0] -= fixX; 44 | position[1] -= fixY; 45 | 46 | view.updateTransform(); 47 | // Get the new center 48 | var center = view.pointToData(point); 49 | view.setCenter(center); 50 | view.setZoom(zoom * previousZoom); 51 | } 52 | 53 | return { 54 | center: view.getCenter(), 55 | zoom: view.getZoom() 56 | }; 57 | }; 58 | 59 | return roamHelper; 60 | }); -------------------------------------------------------------------------------- /echarts/src/chart/bar.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var zrUtil = require('zrender/core/util'); 4 | 5 | require('../coord/cartesian/Grid'); 6 | 7 | require('./bar/BarSeries'); 8 | require('./bar/BarView'); 9 | 10 | var barLayoutGrid = require('../layout/barGrid'); 11 | var echarts = require('../echarts'); 12 | 13 | echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'bar')); 14 | // Visual coding for legend 15 | echarts.registerVisual(function (ecModel) { 16 | ecModel.eachSeriesByType('bar', function (seriesModel) { 17 | var data = seriesModel.getData(); 18 | data.setVisual('legendSymbol', 'roundRect'); 19 | }); 20 | }); 21 | 22 | // In case developer forget to include grid component 23 | require('../component/grid'); 24 | }); -------------------------------------------------------------------------------- /echarts/src/chart/bar/BarSeries.js: -------------------------------------------------------------------------------- 1 | define(function(require) { 2 | 3 | return require('./BaseBarSeries').extend({ 4 | 5 | type: 'series.bar', 6 | 7 | dependencies: ['grid', 'polar'], 8 | 9 | brushSelector: 'rect' 10 | }); 11 | }); -------------------------------------------------------------------------------- /echarts/src/chart/bar/PictorialBarSeries.js: -------------------------------------------------------------------------------- 1 | define(function(require) { 2 | 3 | return require('./BaseBarSeries').extend({ 4 | 5 | type: 'series.pictorialBar', 6 | 7 | dependencies: ['grid'], 8 | 9 | defaultOption: { 10 | symbol: 'circle', // Customized bar shape 11 | symbolSize: null, // Can be ['100%', '100%'], null means auto. 12 | symbolRotate: null, 13 | 14 | symbolPosition: null, // 'start' or 'end' or 'center', null means auto. 15 | symbolOffset: null, 16 | symbolMargin: null, // start margin and end margin. Can be a number or a percent string. 17 | // Auto margin by defualt. 18 | symbolRepeat: false, // false/null/undefined, means no repeat. 19 | // Can be a number, specifies repeat times. 20 | symbolRepeatDirection: 'end', // 'end' means from 'start' to 'end'. 21 | 22 | symbolClip: false, 23 | symbolBoundingData: null, 24 | 25 | // Disable progressive 26 | progressive: 0, 27 | hoverAnimation: true 28 | 29 | // cases: 30 | // repeat: bg:Y, clip:Y, ani:cliprect, size:symbolSize and calc by gridSize. 31 | // fixed size: bg:Y, clip:Y, ani:cliprect, size:symbolSize. 32 | // stretch: bg:N, clip:Y, ani:position(by layout), size:byRect 33 | // img: bg:N, clip:Y, ani:position(include clip), size:byRect or bySymbolSize. 34 | } 35 | }); 36 | }); -------------------------------------------------------------------------------- /echarts/src/chart/bar/barItemStyle.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | 4 | var getBarItemStyle = require('../../model/mixin/makeStyleMapper')( 5 | [ 6 | ['fill', 'color'], 7 | ['stroke', 'borderColor'], 8 | ['lineWidth', 'borderWidth'], 9 | // Compatitable with 2 10 | ['stroke', 'barBorderColor'], 11 | ['lineWidth', 'barBorderWidth'], 12 | ['opacity'], 13 | ['shadowBlur'], 14 | ['shadowOffsetX'], 15 | ['shadowOffsetY'], 16 | ['shadowColor'] 17 | ] 18 | ); 19 | return { 20 | getBarItemStyle: function (excludes) { 21 | var style = getBarItemStyle.call(this, excludes); 22 | if (this.getBorderLineDash) { 23 | var lineDash = this.getBorderLineDash(); 24 | lineDash && (style.lineDash = lineDash); 25 | } 26 | return style; 27 | } 28 | }; 29 | }); -------------------------------------------------------------------------------- /echarts/src/chart/bar/helper.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var zrUtil = require('zrender/core/util'); 4 | var graphic = require('../../util/graphic'); 5 | 6 | var helper = {}; 7 | 8 | helper.setLabel = function ( 9 | normalStyle, hoverStyle, itemModel, color, seriesModel, dataIndex, labelPositionOutside 10 | ) { 11 | var labelModel = itemModel.getModel('label.normal'); 12 | var hoverLabelModel = itemModel.getModel('label.emphasis'); 13 | 14 | if (labelModel.get('show')) { 15 | setLabel( 16 | normalStyle, labelModel, color, 17 | zrUtil.retrieve( 18 | seriesModel.getFormattedLabel(dataIndex, 'normal'), 19 | seriesModel.getRawValue(dataIndex) 20 | ), 21 | labelPositionOutside 22 | ); 23 | } 24 | else { 25 | normalStyle.text = ''; 26 | } 27 | 28 | if (hoverLabelModel.get('show')) { 29 | setLabel( 30 | hoverStyle, hoverLabelModel, color, 31 | zrUtil.retrieve( 32 | seriesModel.getFormattedLabel(dataIndex, 'emphasis'), 33 | seriesModel.getRawValue(dataIndex) 34 | ), 35 | labelPositionOutside 36 | ); 37 | } 38 | else { 39 | hoverStyle.text = ''; 40 | } 41 | }; 42 | 43 | function setLabel(style, model, color, labelText, labelPositionOutside) { 44 | graphic.setText(style, model, color); 45 | style.text = labelText; 46 | if (style.textPosition === 'outside') { 47 | style.textPosition = labelPositionOutside; 48 | } 49 | } 50 | 51 | return helper; 52 | }); -------------------------------------------------------------------------------- /echarts/src/chart/boxplot.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var echarts = require('../echarts'); 4 | 5 | require('./boxplot/BoxplotSeries'); 6 | require('./boxplot/BoxplotView'); 7 | 8 | echarts.registerVisual(require('./boxplot/boxplotVisual')); 9 | echarts.registerLayout(require('./boxplot/boxplotLayout')); 10 | 11 | }); -------------------------------------------------------------------------------- /echarts/src/chart/boxplot/BoxplotView.js: -------------------------------------------------------------------------------- 1 | define(function(require) { 2 | 3 | 'use strict'; 4 | 5 | var zrUtil = require('zrender/core/util'); 6 | var ChartView = require('../../view/Chart'); 7 | var graphic = require('../../util/graphic'); 8 | var whiskerBoxCommon = require('../helper/whiskerBoxCommon'); 9 | 10 | var BoxplotView = ChartView.extend({ 11 | 12 | type: 'boxplot', 13 | 14 | getStyleUpdater: function () { 15 | return updateStyle; 16 | }, 17 | 18 | dispose: zrUtil.noop 19 | }); 20 | 21 | zrUtil.mixin(BoxplotView, whiskerBoxCommon.viewMixin, true); 22 | 23 | // Update common properties 24 | var normalStyleAccessPath = ['itemStyle', 'normal']; 25 | var emphasisStyleAccessPath = ['itemStyle', 'emphasis']; 26 | 27 | function updateStyle(itemGroup, data, idx) { 28 | var itemModel = data.getItemModel(idx); 29 | var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath); 30 | var borderColor = data.getItemVisual(idx, 'color'); 31 | 32 | // Exclude borderColor. 33 | var itemStyle = normalItemStyleModel.getItemStyle(['borderColor']); 34 | 35 | var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex); 36 | whiskerEl.style.set(itemStyle); 37 | whiskerEl.style.stroke = borderColor; 38 | whiskerEl.dirty(); 39 | 40 | var bodyEl = itemGroup.childAt(itemGroup.bodyIndex); 41 | bodyEl.style.set(itemStyle); 42 | bodyEl.style.stroke = borderColor; 43 | bodyEl.dirty(); 44 | 45 | var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle(); 46 | graphic.setHoverStyle(itemGroup, hoverStyle); 47 | } 48 | 49 | return BoxplotView; 50 | 51 | }); -------------------------------------------------------------------------------- /echarts/src/chart/boxplot/boxplotVisual.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var borderColorQuery = ['itemStyle', 'normal', 'borderColor']; 4 | 5 | return function (ecModel, api) { 6 | 7 | var globalColors = ecModel.get('color'); 8 | 9 | ecModel.eachRawSeriesByType('boxplot', function (seriesModel) { 10 | 11 | var defaulColor = globalColors[seriesModel.seriesIndex % globalColors.length]; 12 | var data = seriesModel.getData(); 13 | 14 | data.setVisual({ 15 | legendSymbol: 'roundRect', 16 | // Use name 'color' but not 'borderColor' for legend usage and 17 | // visual coding from other component like dataRange. 18 | color: seriesModel.get(borderColorQuery) || defaulColor 19 | }); 20 | 21 | // Only visible series has each data be visual encoded 22 | if (!ecModel.isSeriesFiltered(seriesModel)) { 23 | data.each(function (idx) { 24 | var itemModel = data.getItemModel(idx); 25 | data.setItemVisual( 26 | idx, 27 | {color: itemModel.get(borderColorQuery, true)} 28 | ); 29 | }); 30 | } 31 | }); 32 | 33 | }; 34 | }); -------------------------------------------------------------------------------- /echarts/src/chart/candlestick.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var echarts = require('../echarts'); 4 | 5 | require('./candlestick/CandlestickSeries'); 6 | require('./candlestick/CandlestickView'); 7 | 8 | echarts.registerPreprocessor( 9 | require('./candlestick/preprocessor') 10 | ); 11 | 12 | echarts.registerVisual(require('./candlestick/candlestickVisual')); 13 | echarts.registerLayout(require('./candlestick/candlestickLayout')); 14 | 15 | }); -------------------------------------------------------------------------------- /echarts/src/chart/candlestick/CandlestickView.js: -------------------------------------------------------------------------------- 1 | define(function(require) { 2 | 3 | 'use strict'; 4 | 5 | var zrUtil = require('zrender/core/util'); 6 | var ChartView = require('../../view/Chart'); 7 | var graphic = require('../../util/graphic'); 8 | var whiskerBoxCommon = require('../helper/whiskerBoxCommon'); 9 | 10 | var CandlestickView = ChartView.extend({ 11 | 12 | type: 'candlestick', 13 | 14 | getStyleUpdater: function () { 15 | return updateStyle; 16 | }, 17 | 18 | dispose: zrUtil.noop 19 | }); 20 | 21 | zrUtil.mixin(CandlestickView, whiskerBoxCommon.viewMixin, true); 22 | 23 | // Update common properties 24 | var normalStyleAccessPath = ['itemStyle', 'normal']; 25 | var emphasisStyleAccessPath = ['itemStyle', 'emphasis']; 26 | 27 | function updateStyle(itemGroup, data, idx) { 28 | var itemModel = data.getItemModel(idx); 29 | var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath); 30 | var color = data.getItemVisual(idx, 'color'); 31 | var borderColor = data.getItemVisual(idx, 'borderColor') || color; 32 | 33 | // Color must be excluded. 34 | // Because symbol provide setColor individually to set fill and stroke 35 | var itemStyle = normalItemStyleModel.getItemStyle( 36 | ['color', 'color0', 'borderColor', 'borderColor0'] 37 | ); 38 | 39 | var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex); 40 | whiskerEl.useStyle(itemStyle); 41 | whiskerEl.style.stroke = borderColor; 42 | 43 | var bodyEl = itemGroup.childAt(itemGroup.bodyIndex); 44 | bodyEl.useStyle(itemStyle); 45 | bodyEl.style.fill = color; 46 | bodyEl.style.stroke = borderColor; 47 | 48 | var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle(); 49 | graphic.setHoverStyle(itemGroup, hoverStyle); 50 | } 51 | 52 | 53 | return CandlestickView; 54 | 55 | }); -------------------------------------------------------------------------------- /echarts/src/chart/candlestick/candlestickVisual.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var positiveBorderColorQuery = ['itemStyle', 'normal', 'borderColor']; 4 | var negativeBorderColorQuery = ['itemStyle', 'normal', 'borderColor0']; 5 | var positiveColorQuery = ['itemStyle', 'normal', 'color']; 6 | var negativeColorQuery = ['itemStyle', 'normal', 'color0']; 7 | 8 | return function (ecModel, api) { 9 | 10 | ecModel.eachRawSeriesByType('candlestick', function (seriesModel) { 11 | 12 | var data = seriesModel.getData(); 13 | 14 | data.setVisual({ 15 | legendSymbol: 'roundRect' 16 | }); 17 | 18 | // Only visible series has each data be visual encoded 19 | if (!ecModel.isSeriesFiltered(seriesModel)) { 20 | data.each(function (idx) { 21 | var itemModel = data.getItemModel(idx); 22 | var sign = data.getItemLayout(idx).sign; 23 | 24 | data.setItemVisual( 25 | idx, 26 | { 27 | color: itemModel.get( 28 | sign > 0 ? positiveColorQuery : negativeColorQuery 29 | ), 30 | borderColor: itemModel.get( 31 | sign > 0 ? positiveBorderColorQuery : negativeBorderColorQuery 32 | ) 33 | } 34 | ); 35 | }); 36 | } 37 | }); 38 | 39 | }; 40 | }); -------------------------------------------------------------------------------- /echarts/src/chart/candlestick/preprocessor.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var zrUtil = require('zrender/core/util'); 4 | 5 | return function (option) { 6 | if (!option || !zrUtil.isArray(option.series)) { 7 | return; 8 | } 9 | 10 | // Translate 'k' to 'candlestick'. 11 | zrUtil.each(option.series, function (seriesItem) { 12 | if (zrUtil.isObject(seriesItem) && seriesItem.type === 'k') { 13 | seriesItem.type = 'candlestick'; 14 | } 15 | }); 16 | }; 17 | 18 | }); -------------------------------------------------------------------------------- /echarts/src/chart/chord.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | require('./chord/ChordSeries'); 4 | require('./chord/ChordView'); 5 | 6 | var echarts = require('../echarts'); 7 | var zrUtil = require('zrender/core/util'); 8 | echarts.registerLayout(require('./chord/chordCircularLayout')); 9 | 10 | echarts.registerVisual(zrUtil.curry(require('../visual/dataColor'), 'chord')); 11 | 12 | echarts.registerProcessor(zrUtil.curry(require('../processor/dataFilter'), 'pie')); 13 | }); -------------------------------------------------------------------------------- /echarts/src/chart/chord/ChordSeries.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var SeriesModel = require('../../model/Series'); 4 | var createGraphFromNodeEdge = require('../helper/createGraphFromNodeEdge'); 5 | var createGraphFromNodeMatrix = require('../helper/createGraphFromNodeMatrix'); 6 | 7 | var ChordSeries = SeriesModel.extend({ 8 | 9 | type: 'series.chord', 10 | 11 | getInitialData: function (option) { 12 | var edges = option.edges || option.links; 13 | var nodes = option.data || option.nodes; 14 | var matrix = option.matrix; 15 | if (nodes && edges) { 16 | var graph = createGraphFromNodeEdge(nodes, edges, this, true); 17 | return graph.data; 18 | } 19 | else if (nodes && matrix) { 20 | var graph = createGraphFromNodeMatrix(nodes, matrix, this, true); 21 | return graph.data; 22 | } 23 | }, 24 | 25 | /** 26 | * @return {module:echarts/data/Graph} 27 | */ 28 | getGraph: function () { 29 | return this.getData().graph; 30 | }, 31 | 32 | /** 33 | * @return {module:echarts/data/List} 34 | */ 35 | getEdgeData: function () { 36 | return this.getGraph().edgeData; 37 | }, 38 | 39 | defaultOption: { 40 | center: ['50%', '50%'], 41 | radius: ['65%', '75%'], 42 | // 43 | // layout: 'circular', 44 | 45 | sort: 'none', 46 | sortSub: 'none', 47 | padding: 0.02, 48 | startAngle: 90, 49 | clockwise: true, 50 | 51 | itemStyle: { 52 | normal: {}, 53 | emphasis: {} 54 | }, 55 | 56 | chordStyle: { 57 | normal: {}, 58 | emphasis: {} 59 | } 60 | } 61 | }); 62 | 63 | return ChordSeries; 64 | }); -------------------------------------------------------------------------------- /echarts/src/chart/effectScatter.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var zrUtil = require('zrender/core/util'); 4 | var echarts = require('../echarts'); 5 | 6 | require('./effectScatter/EffectScatterSeries'); 7 | require('./effectScatter/EffectScatterView'); 8 | 9 | echarts.registerVisual(zrUtil.curry( 10 | require('../visual/symbol'), 'effectScatter', 'circle', null 11 | )); 12 | echarts.registerLayout(zrUtil.curry( 13 | require('../layout/points'), 'effectScatter' 14 | )); 15 | }); -------------------------------------------------------------------------------- /echarts/src/chart/effectScatter/EffectScatterView.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var SymbolDraw = require('../helper/SymbolDraw'); 4 | var EffectSymbol = require('../helper/EffectSymbol'); 5 | 6 | require('../../echarts').extendChartView({ 7 | 8 | type: 'effectScatter', 9 | 10 | init: function () { 11 | this._symbolDraw = new SymbolDraw(EffectSymbol); 12 | }, 13 | 14 | render: function (seriesModel, ecModel, api) { 15 | var data = seriesModel.getData(); 16 | var effectSymbolDraw = this._symbolDraw; 17 | effectSymbolDraw.updateData(data); 18 | this.group.add(effectSymbolDraw.group); 19 | }, 20 | 21 | updateLayout: function () { 22 | this._symbolDraw.updateLayout(); 23 | }, 24 | 25 | remove: function (ecModel, api) { 26 | this._symbolDraw && this._symbolDraw.remove(api); 27 | }, 28 | 29 | dispose: function () {} 30 | }); 31 | }); -------------------------------------------------------------------------------- /echarts/src/chart/funnel.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var zrUtil = require('zrender/core/util'); 4 | var echarts = require('../echarts'); 5 | 6 | require('./funnel/FunnelSeries'); 7 | require('./funnel/FunnelView'); 8 | 9 | echarts.registerVisual(zrUtil.curry(require('../visual/dataColor'), 'funnel')); 10 | echarts.registerLayout(require('./funnel/funnelLayout')); 11 | 12 | echarts.registerProcessor(zrUtil.curry(require('../processor/dataFilter'), 'funnel')); 13 | }); -------------------------------------------------------------------------------- /echarts/src/chart/gauge.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | require('./gauge/GaugeSeries'); 3 | require('./gauge/GaugeView'); 4 | }); -------------------------------------------------------------------------------- /echarts/src/chart/gauge/PointerPath.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | return require('zrender/graphic/Path').extend({ 4 | 5 | type: 'echartsGaugePointer', 6 | 7 | shape: { 8 | angle: 0, 9 | 10 | width: 10, 11 | 12 | r: 10, 13 | 14 | x: 0, 15 | 16 | y: 0 17 | }, 18 | 19 | buildPath: function (ctx, shape) { 20 | var mathCos = Math.cos; 21 | var mathSin = Math.sin; 22 | 23 | var r = shape.r; 24 | var width = shape.width; 25 | var angle = shape.angle; 26 | var x = shape.x - mathCos(angle) * width * (width >= r / 3 ? 1 : 2); 27 | var y = shape.y - mathSin(angle) * width * (width >= r / 3 ? 1 : 2); 28 | 29 | angle = shape.angle - Math.PI / 2; 30 | ctx.moveTo(x, y); 31 | ctx.lineTo( 32 | shape.x + mathCos(angle) * width, 33 | shape.y + mathSin(angle) * width 34 | ); 35 | ctx.lineTo( 36 | shape.x + mathCos(shape.angle) * r, 37 | shape.y + mathSin(shape.angle) * r 38 | ); 39 | ctx.lineTo( 40 | shape.x - mathCos(angle) * width, 41 | shape.y - mathSin(angle) * width 42 | ); 43 | ctx.lineTo(x, y); 44 | return; 45 | } 46 | }); 47 | }); -------------------------------------------------------------------------------- /echarts/src/chart/graph.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var echarts = require('../echarts'); 4 | var zrUtil = require('zrender/core/util'); 5 | 6 | require('./graph/GraphSeries'); 7 | require('./graph/GraphView'); 8 | 9 | require('./graph/graphAction'); 10 | 11 | echarts.registerProcessor(require('./graph/categoryFilter')); 12 | 13 | echarts.registerVisual(zrUtil.curry( 14 | require('../visual/symbol'), 'graph', 'circle', null 15 | )); 16 | echarts.registerVisual(require('./graph/categoryVisual')); 17 | echarts.registerVisual(require('./graph/edgeVisual')); 18 | 19 | echarts.registerLayout(require('./graph/simpleLayout')); 20 | echarts.registerLayout(require('./graph/circularLayout')); 21 | echarts.registerLayout(require('./graph/forceLayout')); 22 | 23 | // Graph view coordinate system 24 | echarts.registerCoordinateSystem('graphView', { 25 | create: require('./graph/createView') 26 | }); 27 | }); -------------------------------------------------------------------------------- /echarts/src/chart/graph/backwardCompat.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | }); -------------------------------------------------------------------------------- /echarts/src/chart/graph/categoryFilter.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | return function (ecModel) { 4 | var legendModels = ecModel.findComponents({ 5 | mainType: 'legend' 6 | }); 7 | if (!legendModels || !legendModels.length) { 8 | return; 9 | } 10 | ecModel.eachSeriesByType('graph', function (graphSeries) { 11 | var categoriesData = graphSeries.getCategoriesData(); 12 | var graph = graphSeries.getGraph(); 13 | var data = graph.data; 14 | 15 | var categoryNames = categoriesData.mapArray(categoriesData.getName); 16 | 17 | data.filterSelf(function (idx) { 18 | var model = data.getItemModel(idx); 19 | var category = model.getShallow('category'); 20 | if (category != null) { 21 | if (typeof category === 'number') { 22 | category = categoryNames[category]; 23 | } 24 | // If in any legend component the status is not selected. 25 | for (var i = 0; i < legendModels.length; i++) { 26 | if (!legendModels[i].isSelected(category)) { 27 | return false; 28 | } 29 | } 30 | } 31 | return true; 32 | }); 33 | }, this); 34 | }; 35 | }); -------------------------------------------------------------------------------- /echarts/src/chart/graph/categoryVisual.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | return function (ecModel) { 4 | 5 | var paletteScope = {}; 6 | ecModel.eachSeriesByType('graph', function (seriesModel) { 7 | var categoriesData = seriesModel.getCategoriesData(); 8 | var data = seriesModel.getData(); 9 | 10 | var categoryNameIdxMap = {}; 11 | 12 | categoriesData.each(function (idx) { 13 | var name = categoriesData.getName(idx); 14 | categoryNameIdxMap[name] = idx; 15 | 16 | var itemModel = categoriesData.getItemModel(idx); 17 | var color = itemModel.get('itemStyle.normal.color') 18 | || seriesModel.getColorFromPalette(name, paletteScope); 19 | categoriesData.setItemVisual(idx, 'color', color); 20 | }); 21 | 22 | // Assign category color to visual 23 | if (categoriesData.count()) { 24 | data.each(function (idx) { 25 | var model = data.getItemModel(idx); 26 | var category = model.getShallow('category'); 27 | if (category != null) { 28 | if (typeof category === 'string') { 29 | category = categoryNameIdxMap[category]; 30 | } 31 | if (!data.getItemVisual(idx, 'color', true)) { 32 | data.setItemVisual( 33 | idx, 'color', 34 | categoriesData.getItemVisual(category, 'color') 35 | ); 36 | } 37 | } 38 | }); 39 | } 40 | }); 41 | }; 42 | }); -------------------------------------------------------------------------------- /echarts/src/chart/graph/circularLayout.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | var circularLayoutHelper = require('./circularLayoutHelper'); 3 | return function (ecModel) { 4 | ecModel.eachSeriesByType('graph', function (seriesModel) { 5 | if (seriesModel.get('layout') === 'circular') { 6 | circularLayoutHelper(seriesModel); 7 | } 8 | }); 9 | }; 10 | }); -------------------------------------------------------------------------------- /echarts/src/chart/graph/circularLayoutHelper.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | var vec2 = require('zrender/core/vector'); 3 | return function (seriesModel) { 4 | var coordSys = seriesModel.coordinateSystem; 5 | if (coordSys && coordSys.type !== 'view') { 6 | return; 7 | } 8 | 9 | var rect = coordSys.getBoundingRect(); 10 | 11 | var nodeData = seriesModel.getData(); 12 | var graph = nodeData.graph; 13 | 14 | var angle = 0; 15 | var sum = nodeData.getSum('value'); 16 | var unitAngle = Math.PI * 2 / (sum || nodeData.count()); 17 | 18 | var cx = rect.width / 2 + rect.x; 19 | var cy = rect.height / 2 + rect.y; 20 | 21 | var r = Math.min(rect.width, rect.height) / 2; 22 | 23 | graph.eachNode(function (node) { 24 | var value = node.getValue('value'); 25 | 26 | angle += unitAngle * (sum ? value : 1) / 2; 27 | 28 | node.setLayout([ 29 | r * Math.cos(angle) + cx, 30 | r * Math.sin(angle) + cy 31 | ]); 32 | 33 | angle += unitAngle * (sum ? value : 1) / 2; 34 | }); 35 | 36 | nodeData.setLayout({ 37 | cx: cx, 38 | cy: cy 39 | }); 40 | 41 | graph.eachEdge(function (edge) { 42 | var curveness = edge.getModel().get('lineStyle.normal.curveness') || 0; 43 | var p1 = vec2.clone(edge.node1.getLayout()); 44 | var p2 = vec2.clone(edge.node2.getLayout()); 45 | var cp1; 46 | var x12 = (p1[0] + p2[0]) / 2; 47 | var y12 = (p1[1] + p2[1]) / 2; 48 | if (+curveness) { 49 | curveness *= 3; 50 | cp1 = [ 51 | cx * curveness + x12 * (1 - curveness), 52 | cy * curveness + y12 * (1 - curveness) 53 | ]; 54 | } 55 | edge.setLayout([p1, p2, cp1]); 56 | }); 57 | }; 58 | }); -------------------------------------------------------------------------------- /echarts/src/chart/graph/graphAction.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var echarts = require('../../echarts'); 4 | var roamHelper = require('../../action/roamHelper'); 5 | 6 | var actionInfo = { 7 | type: 'graphRoam', 8 | event: 'graphRoam', 9 | update: 'none' 10 | }; 11 | 12 | /** 13 | * @payload 14 | * @property {string} name Series name 15 | * @property {number} [dx] 16 | * @property {number} [dy] 17 | * @property {number} [zoom] 18 | * @property {number} [originX] 19 | * @property {number} [originY] 20 | */ 21 | echarts.registerAction(actionInfo, function (payload, ecModel) { 22 | ecModel.eachComponent({mainType: 'series', query: payload}, function (seriesModel) { 23 | var coordSys = seriesModel.coordinateSystem; 24 | 25 | var res = roamHelper.updateCenterAndZoom(coordSys, payload); 26 | 27 | seriesModel.setCenter 28 | && seriesModel.setCenter(res.center); 29 | 30 | seriesModel.setZoom 31 | && seriesModel.setZoom(res.zoom); 32 | }); 33 | }); 34 | 35 | 36 | /** 37 | * @payload 38 | * @property {number} [seriesIndex] 39 | * @property {string} [seriesId] 40 | * @property {string} [seriesName] 41 | * @property {number} [dataIndex] 42 | */ 43 | echarts.registerAction({ 44 | type: 'focusNodeAdjacency', 45 | event: 'focusNodeAdjacency', 46 | update: 'series.graph:focusNodeAdjacency' 47 | }, function () {}); 48 | 49 | /** 50 | * @payload 51 | * @property {number} [seriesIndex] 52 | * @property {string} [seriesId] 53 | * @property {string} [seriesName] 54 | */ 55 | echarts.registerAction({ 56 | type: 'unfocusNodeAdjacency', 57 | event: 'unfocusNodeAdjacency', 58 | update: 'series.graph:unfocusNodeAdjacency' 59 | }, function () {}); 60 | 61 | }); -------------------------------------------------------------------------------- /echarts/src/chart/graph/simpleLayout.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var simpleLayoutHelper = require('./simpleLayoutHelper'); 4 | var simpleLayoutEdge = require('./simpleLayoutEdge'); 5 | return function (ecModel, api) { 6 | ecModel.eachSeriesByType('graph', function (seriesModel) { 7 | var layout = seriesModel.get('layout'); 8 | var coordSys = seriesModel.coordinateSystem; 9 | if (coordSys && coordSys.type !== 'view') { 10 | var data = seriesModel.getData(); 11 | data.each(coordSys.dimensions, function (x, y, idx) { 12 | if (!isNaN(x) && !isNaN(y)) { 13 | data.setItemLayout(idx, coordSys.dataToPoint([x, y])); 14 | } 15 | else { 16 | // Also {Array.}, not undefined to avoid if...else... statement 17 | data.setItemLayout(idx, [NaN, NaN]); 18 | } 19 | }); 20 | 21 | simpleLayoutEdge(data.graph); 22 | } 23 | else if (!layout || layout === 'none') { 24 | simpleLayoutHelper(seriesModel); 25 | } 26 | }); 27 | }; 28 | }); -------------------------------------------------------------------------------- /echarts/src/chart/graph/simpleLayoutEdge.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | var vec2 = require('zrender/core/vector'); 3 | return function (graph) { 4 | graph.eachEdge(function (edge) { 5 | var curveness = edge.getModel().get('lineStyle.normal.curveness') || 0; 6 | var p1 = vec2.clone(edge.node1.getLayout()); 7 | var p2 = vec2.clone(edge.node2.getLayout()); 8 | var points = [p1, p2]; 9 | if (+curveness) { 10 | points.push([ 11 | (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * curveness, 12 | (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * curveness 13 | ]); 14 | } 15 | edge.setLayout(points); 16 | }); 17 | }; 18 | }); -------------------------------------------------------------------------------- /echarts/src/chart/graph/simpleLayoutHelper.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var simpleLayoutEdge = require('./simpleLayoutEdge'); 4 | 5 | return function (seriesModel) { 6 | var coordSys = seriesModel.coordinateSystem; 7 | if (coordSys && coordSys.type !== 'view') { 8 | return; 9 | } 10 | var graph = seriesModel.getGraph(); 11 | 12 | graph.eachNode(function (node) { 13 | var model = node.getModel(); 14 | node.setLayout([+model.get('x'), +model.get('y')]); 15 | }); 16 | 17 | simpleLayoutEdge(graph); 18 | }; 19 | }); -------------------------------------------------------------------------------- /echarts/src/chart/heatmap.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | require('./heatmap/HeatmapSeries'); 4 | require('./heatmap/HeatmapView'); 5 | }); -------------------------------------------------------------------------------- /echarts/src/chart/heatmap/HeatmapSeries.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var SeriesModel = require('../../model/Series'); 4 | var createListFromArray = require('../helper/createListFromArray'); 5 | 6 | return SeriesModel.extend({ 7 | type: 'series.heatmap', 8 | 9 | getInitialData: function (option, ecModel) { 10 | return createListFromArray(option.data, this, ecModel); 11 | }, 12 | 13 | defaultOption: { 14 | 15 | // Cartesian2D or geo 16 | coordinateSystem: 'cartesian2d', 17 | 18 | zlevel: 0, 19 | 20 | z: 2, 21 | 22 | // Cartesian coordinate system 23 | // xAxisIndex: 0, 24 | // yAxisIndex: 0, 25 | 26 | // Geo coordinate system 27 | geoIndex: 0, 28 | 29 | blurSize: 30, 30 | 31 | pointSize: 20, 32 | 33 | maxOpacity: 1, 34 | 35 | minOpacity: 0 36 | } 37 | }); 38 | }); -------------------------------------------------------------------------------- /echarts/src/chart/helper/LinePath.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Line path for bezier and straight line draw 3 | */ 4 | define(function (require) { 5 | var graphic = require('../../util/graphic'); 6 | var vec2 = require('zrender/core/vector'); 7 | 8 | var straightLineProto = graphic.Line.prototype; 9 | var bezierCurveProto = graphic.BezierCurve.prototype; 10 | 11 | function isLine(shape) { 12 | return isNaN(+shape.cpx1) || isNaN(+shape.cpy1); 13 | } 14 | 15 | return graphic.extendShape({ 16 | 17 | type: 'ec-line', 18 | 19 | style: { 20 | stroke: '#000', 21 | fill: null 22 | }, 23 | 24 | shape: { 25 | x1: 0, 26 | y1: 0, 27 | x2: 0, 28 | y2: 0, 29 | percent: 1, 30 | cpx1: null, 31 | cpy1: null 32 | }, 33 | 34 | buildPath: function (ctx, shape) { 35 | (isLine(shape) ? straightLineProto : bezierCurveProto).buildPath(ctx, shape); 36 | }, 37 | 38 | pointAt: function (t) { 39 | return isLine(this.shape) 40 | ? straightLineProto.pointAt.call(this, t) 41 | : bezierCurveProto.pointAt.call(this, t); 42 | }, 43 | 44 | tangentAt: function (t) { 45 | var shape = this.shape; 46 | var p = isLine(shape) 47 | ? [shape.x2 - shape.x1, shape.y2 - shape.y1] 48 | : bezierCurveProto.tangentAt.call(this, t); 49 | return vec2.normalize(p, p); 50 | } 51 | }); 52 | }); -------------------------------------------------------------------------------- /echarts/src/chart/line.js: -------------------------------------------------------------------------------- 1 | //line 2 | define(function (require) { 3 | 4 | var zrUtil = require('zrender/core/util'); 5 | var echarts = require('../echarts'); 6 | var PRIORITY = echarts.PRIORITY; 7 | 8 | require('./line/LineSeries'); 9 | require('./line/LineView'); 10 | 11 | echarts.registerVisual(zrUtil.curry( 12 | require('../visual/symbol'), 'line', 'circle', 'line' 13 | )); 14 | echarts.registerLayout(zrUtil.curry( 15 | require('../layout/points'), 'line' 16 | )); 17 | 18 | // Down sample after filter 19 | echarts.registerProcessor(PRIORITY.PROCESSOR.STATISTIC, zrUtil.curry( 20 | require('../processor/dataSample'), 'line' 21 | )); 22 | 23 | // In case developer forget to include grid component 24 | require('../component/grid'); 25 | }); 26 | 27 | -------------------------------------------------------------------------------- /echarts/src/chart/lines.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | require('./lines/LinesSeries'); 4 | require('./lines/LinesView'); 5 | 6 | var echarts = require('../echarts'); 7 | echarts.registerLayout( 8 | require('./lines/linesLayout') 9 | ); 10 | }); -------------------------------------------------------------------------------- /echarts/src/chart/lines/linesLayout.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | return function (ecModel) { 4 | ecModel.eachSeriesByType('lines', function (seriesModel) { 5 | var coordSys = seriesModel.coordinateSystem; 6 | var lineData = seriesModel.getData(); 7 | 8 | // FIXME Use data dimensions ? 9 | lineData.each(function (idx) { 10 | var itemModel = lineData.getItemModel(idx); 11 | // TODO Support pure array 12 | var coords = (itemModel.option instanceof Array) ? 13 | itemModel.option : itemModel.get('coords'); 14 | 15 | if (__DEV__) { 16 | if (!(coords instanceof Array && coords.length > 0 && coords[0] instanceof Array)) { 17 | throw new Error('Invalid coords ' + JSON.stringify(coords) + '. Lines must have 2d coords array in data item.'); 18 | } 19 | } 20 | var pts = []; 21 | 22 | if (seriesModel.get('polyline')) { 23 | for (var i = 0; i < coords.length; i++) { 24 | pts.push(coordSys.dataToPoint(coords[i])); 25 | } 26 | } 27 | else { 28 | pts[0] = coordSys.dataToPoint(coords[0]); 29 | pts[1] = coordSys.dataToPoint(coords[1]); 30 | 31 | var curveness = itemModel.get('lineStyle.normal.curveness'); 32 | if (+curveness) { 33 | pts[2] = [ 34 | (pts[0][0] + pts[1][0]) / 2 - (pts[0][1] - pts[1][1]) * curveness, 35 | (pts[0][1] + pts[1][1]) / 2 - (pts[1][0] - pts[0][0]) * curveness 36 | ]; 37 | } 38 | } 39 | lineData.setItemLayout(idx, pts); 40 | }); 41 | }); 42 | }; 43 | }); -------------------------------------------------------------------------------- /echarts/src/chart/map.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var echarts = require('../echarts'); 4 | var PRIORITY = echarts.PRIORITY; 5 | 6 | require('./map/MapSeries'); 7 | 8 | require('./map/MapView'); 9 | 10 | require('../action/geoRoam'); 11 | 12 | require('../coord/geo/geoCreator'); 13 | 14 | echarts.registerLayout(require('./map/mapSymbolLayout')); 15 | 16 | echarts.registerVisual(require('./map/mapVisual')); 17 | 18 | echarts.registerProcessor(PRIORITY.PROCESSOR.STATISTIC, require('./map/mapDataStatistic')); 19 | 20 | echarts.registerPreprocessor(require('./map/backwardCompat')); 21 | 22 | require('../action/createDataSelectAction')('map', [{ 23 | type: 'mapToggleSelect', 24 | event: 'mapselectchanged', 25 | method: 'toggleSelected' 26 | }, { 27 | type: 'mapSelect', 28 | event: 'mapselected', 29 | method: 'select' 30 | }, { 31 | type: 'mapUnSelect', 32 | event: 'mapunselected', 33 | method: 'unSelect' 34 | }]); 35 | }); -------------------------------------------------------------------------------- /echarts/src/chart/map/backwardCompat.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var zrUtil = require('zrender/core/util'); 4 | 5 | return function (option) { 6 | // Save geoCoord 7 | var mapSeries = []; 8 | zrUtil.each(option.series, function (seriesOpt) { 9 | if (seriesOpt.type === 'map') { 10 | mapSeries.push(seriesOpt); 11 | } 12 | }); 13 | 14 | zrUtil.each(mapSeries, function (seriesOpt) { 15 | seriesOpt.map = seriesOpt.map || seriesOpt.mapType; 16 | // Put x, y, width, height, x2, y2 in the top level 17 | zrUtil.defaults(seriesOpt, seriesOpt.mapLocation); 18 | }); 19 | }; 20 | }); -------------------------------------------------------------------------------- /echarts/src/chart/map/mapVisual.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | return function (ecModel) { 3 | ecModel.eachSeriesByType('map', function (seriesModel) { 4 | var colorList = seriesModel.get('color'); 5 | var itemStyleModel = seriesModel.getModel('itemStyle.normal'); 6 | 7 | var areaColor = itemStyleModel.get('areaColor'); 8 | var color = itemStyleModel.get('color') 9 | || colorList[seriesModel.seriesIndex % colorList.length]; 10 | 11 | seriesModel.getData().setVisual({ 12 | 'areaColor': areaColor, 13 | 'color': color 14 | }); 15 | }); 16 | }; 17 | }); -------------------------------------------------------------------------------- /echarts/src/chart/parallel.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var echarts = require('../echarts'); 4 | 5 | require('../component/parallel'); 6 | 7 | require('./parallel/ParallelSeries'); 8 | require('./parallel/ParallelView'); 9 | 10 | echarts.registerVisual(require('./parallel/parallelVisual')); 11 | 12 | }); -------------------------------------------------------------------------------- /echarts/src/chart/parallel/parallelVisual.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | return function (ecModel) { 4 | 5 | ecModel.eachSeriesByType('parallel', function (seriesModel) { 6 | 7 | var itemStyleModel = seriesModel.getModel('itemStyle.normal'); 8 | var lineStyleModel = seriesModel.getModel('lineStyle.normal'); 9 | var globalColors = ecModel.get('color'); 10 | 11 | var color = lineStyleModel.get('color') 12 | || itemStyleModel.get('color') 13 | || globalColors[seriesModel.seriesIndex % globalColors.length]; 14 | var inactiveOpacity = seriesModel.get('inactiveOpacity'); 15 | var activeOpacity = seriesModel.get('activeOpacity'); 16 | var lineStyle = seriesModel.getModel('lineStyle.normal').getLineStyle(); 17 | 18 | var coordSys = seriesModel.coordinateSystem; 19 | var data = seriesModel.getData(); 20 | 21 | var opacityMap = { 22 | normal: lineStyle.opacity, 23 | active: activeOpacity, 24 | inactive: inactiveOpacity 25 | }; 26 | 27 | coordSys.eachActiveState(data, function (activeState, dataIndex) { 28 | data.setItemVisual(dataIndex, 'opacity', opacityMap[activeState]); 29 | }); 30 | 31 | data.setVisual('color', color); 32 | }); 33 | }; 34 | }); -------------------------------------------------------------------------------- /echarts/src/chart/pictorialBar.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var zrUtil = require('zrender/core/util'); 4 | 5 | require('../coord/cartesian/Grid'); 6 | 7 | require('./bar/PictorialBarSeries'); 8 | require('./bar/PictorialBarView'); 9 | 10 | var barLayoutGrid = require('../layout/barGrid'); 11 | var echarts = require('../echarts'); 12 | 13 | echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'pictorialBar')); 14 | 15 | echarts.registerVisual(zrUtil.curry( 16 | require('../visual/symbol'), 'pictorialBar', 'roundRect', null 17 | )); 18 | 19 | // In case developer forget to include grid component 20 | require('../component/grid'); 21 | }); -------------------------------------------------------------------------------- /echarts/src/chart/pie.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var zrUtil = require('zrender/core/util'); 4 | var echarts = require('../echarts'); 5 | 6 | require('./pie/PieSeries'); 7 | require('./pie/PieView'); 8 | 9 | require('../action/createDataSelectAction')('pie', [{ 10 | type: 'pieToggleSelect', 11 | event: 'pieselectchanged', 12 | method: 'toggleSelected' 13 | }, { 14 | type: 'pieSelect', 15 | event: 'pieselected', 16 | method: 'select' 17 | }, { 18 | type: 'pieUnSelect', 19 | event: 'pieunselected', 20 | method: 'unSelect' 21 | }]); 22 | 23 | echarts.registerVisual(zrUtil.curry(require('../visual/dataColor'), 'pie')); 24 | 25 | echarts.registerLayout(zrUtil.curry( 26 | require('./pie/pieLayout'), 'pie' 27 | )); 28 | 29 | echarts.registerProcessor(zrUtil.curry(require('../processor/dataFilter'), 'pie')); 30 | }); -------------------------------------------------------------------------------- /echarts/src/chart/radar.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var zrUtil = require('zrender/core/util'); 4 | var echarts = require('../echarts'); 5 | 6 | // Must use radar component 7 | require('../component/radar'); 8 | 9 | require('./radar/RadarSeries'); 10 | require('./radar/RadarView'); 11 | 12 | echarts.registerVisual(zrUtil.curry(require('../visual/dataColor'), 'radar')); 13 | echarts.registerVisual(zrUtil.curry( 14 | require('../visual/symbol'), 'radar', 'circle', null 15 | )); 16 | echarts.registerLayout(require('./radar/radarLayout')); 17 | 18 | echarts.registerProcessor( 19 | zrUtil.curry(require('../processor/dataFilter'), 'radar') 20 | ); 21 | 22 | echarts.registerPreprocessor(require('./radar/backwardCompat')); 23 | }); -------------------------------------------------------------------------------- /echarts/src/chart/radar/backwardCompat.js: -------------------------------------------------------------------------------- 1 | // Backward compat for radar chart in 2 2 | define(function (require) { 3 | 4 | var zrUtil = require('zrender/core/util'); 5 | 6 | return function (option) { 7 | var polarOptArr = option.polar; 8 | if (polarOptArr) { 9 | if (!zrUtil.isArray(polarOptArr)) { 10 | polarOptArr = [polarOptArr]; 11 | } 12 | var polarNotRadar = []; 13 | zrUtil.each(polarOptArr, function (polarOpt, idx) { 14 | if (polarOpt.indicator) { 15 | if (polarOpt.type && !polarOpt.shape) { 16 | polarOpt.shape = polarOpt.type; 17 | } 18 | option.radar = option.radar || []; 19 | if (!zrUtil.isArray(option.radar)) { 20 | option.radar = [option.radar]; 21 | } 22 | option.radar.push(polarOpt); 23 | } 24 | else { 25 | polarNotRadar.push(polarOpt); 26 | } 27 | }); 28 | option.polar = polarNotRadar; 29 | } 30 | zrUtil.each(option.series, function (seriesOpt) { 31 | if (seriesOpt.type === 'radar' && seriesOpt.polarIndex) { 32 | seriesOpt.radarIndex = seriesOpt.polarIndex; 33 | } 34 | }); 35 | }; 36 | }); -------------------------------------------------------------------------------- /echarts/src/chart/radar/radarLayout.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | return function (ecModel) { 4 | ecModel.eachSeriesByType('radar', function (seriesModel) { 5 | var data = seriesModel.getData(); 6 | var points = []; 7 | var coordSys = seriesModel.coordinateSystem; 8 | if (!coordSys) { 9 | return; 10 | } 11 | 12 | function pointsConverter(val, idx) { 13 | points[idx] = points[idx] || []; 14 | points[idx][i] = coordSys.dataToPoint(val, i); 15 | } 16 | for (var i = 0; i < coordSys.getIndicatorAxes().length; i++) { 17 | var dim = data.dimensions[i]; 18 | data.each(dim, pointsConverter); 19 | } 20 | 21 | data.each(function (idx) { 22 | // Close polygon 23 | points[idx][0] && points[idx].push(points[idx][0].slice()); 24 | data.setItemLayout(idx, points[idx]); 25 | }); 26 | }); 27 | }; 28 | }); -------------------------------------------------------------------------------- /echarts/src/chart/sankey.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var echarts = require('../echarts'); 4 | 5 | require('./sankey/SankeySeries'); 6 | require('./sankey/SankeyView'); 7 | echarts.registerLayout(require('./sankey/sankeyLayout')); 8 | echarts.registerVisual(require('./sankey/sankeyVisual')); 9 | }); -------------------------------------------------------------------------------- /echarts/src/chart/sankey/sankeyVisual.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Visual encoding for sankey view 3 | * @author Deqing Li(annong035@gmail.com) 4 | */ 5 | define(function (require) { 6 | 7 | var VisualMapping = require('../../visual/VisualMapping'); 8 | var zrUtil = require('zrender/core/util'); 9 | 10 | return function (ecModel, payload) { 11 | ecModel.eachSeriesByType('sankey', function (seriesModel) { 12 | var graph = seriesModel.getGraph(); 13 | var nodes = graph.nodes; 14 | 15 | nodes.sort(function (a, b) { 16 | return a.getLayout().value - b.getLayout().value; 17 | }); 18 | 19 | var minValue = nodes[0].getLayout().value; 20 | var maxValue = nodes[nodes.length - 1].getLayout().value; 21 | 22 | zrUtil.each(nodes, function (node) { 23 | var mapping = new VisualMapping({ 24 | type: 'color', 25 | mappingMethod: 'linear', 26 | dataExtent: [minValue, maxValue], 27 | visual: seriesModel.get('color') 28 | }); 29 | 30 | var mapValueToColor = mapping.mapValueToVisual(node.getLayout().value); 31 | node.setVisual('color', mapValueToColor); 32 | // If set itemStyle.normal.color 33 | var itemModel = node.getModel(); 34 | var customColor = itemModel.get('itemStyle.normal.color'); 35 | if (customColor != null) { 36 | node.setVisual('color', customColor); 37 | } 38 | }); 39 | 40 | }); 41 | }; 42 | }); 43 | -------------------------------------------------------------------------------- /echarts/src/chart/scatter.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var zrUtil = require('zrender/core/util'); 4 | var echarts = require('../echarts'); 5 | 6 | require('./scatter/ScatterSeries'); 7 | require('./scatter/ScatterView'); 8 | 9 | echarts.registerVisual(zrUtil.curry( 10 | require('../visual/symbol'), 'scatter', 'circle', null 11 | )); 12 | echarts.registerLayout(zrUtil.curry( 13 | require('../layout/points'), 'scatter' 14 | )); 15 | 16 | // In case developer forget to include grid component 17 | require('../component/grid'); 18 | }); -------------------------------------------------------------------------------- /echarts/src/chart/scatter/ScatterView.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var SymbolDraw = require('../helper/SymbolDraw'); 4 | var LargeSymbolDraw = require('../helper/LargeSymbolDraw'); 5 | 6 | require('../../echarts').extendChartView({ 7 | 8 | type: 'scatter', 9 | 10 | init: function () { 11 | this._normalSymbolDraw = new SymbolDraw(); 12 | this._largeSymbolDraw = new LargeSymbolDraw(); 13 | }, 14 | 15 | render: function (seriesModel, ecModel, api) { 16 | var data = seriesModel.getData(); 17 | var largeSymbolDraw = this._largeSymbolDraw; 18 | var normalSymbolDraw = this._normalSymbolDraw; 19 | var group = this.group; 20 | 21 | var symbolDraw = seriesModel.get('large') && data.count() > seriesModel.get('largeThreshold') 22 | ? largeSymbolDraw : normalSymbolDraw; 23 | 24 | this._symbolDraw = symbolDraw; 25 | symbolDraw.updateData(data); 26 | group.add(symbolDraw.group); 27 | 28 | group.remove( 29 | symbolDraw === largeSymbolDraw 30 | ? normalSymbolDraw.group : largeSymbolDraw.group 31 | ); 32 | }, 33 | 34 | updateLayout: function (seriesModel) { 35 | this._symbolDraw.updateLayout(seriesModel); 36 | }, 37 | 38 | remove: function (ecModel, api) { 39 | this._symbolDraw && this._symbolDraw.remove(api, true); 40 | }, 41 | 42 | dispose: function () {} 43 | }); 44 | }); -------------------------------------------------------------------------------- /echarts/src/chart/themeRiver.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var echarts = require('../echarts'); 4 | var zrUtil = require('zrender/core/util'); 5 | 6 | require('../component/singleAxis'); 7 | 8 | require('./themeRiver/ThemeRiverSeries'); 9 | 10 | require('./themeRiver/ThemeRiverView'); 11 | 12 | echarts.registerLayout(require('./themeRiver/themeRiverLayout')); 13 | 14 | echarts.registerVisual(require('./themeRiver/themeRiverVisual')); 15 | 16 | echarts.registerProcessor( 17 | zrUtil.curry(require('../processor/dataFilter'), 'themeRiver') 18 | ); 19 | }); -------------------------------------------------------------------------------- /echarts/src/chart/themeRiver/themeRiverVisual.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Visual encoding for themeRiver view 3 | * @author Deqing Li(annong035@gmail.com) 4 | */ 5 | define(function (require) { 6 | 7 | return function (ecModel) { 8 | ecModel.eachSeriesByType('themeRiver', function (seriesModel) { 9 | var data = seriesModel.getData(); 10 | var rawData = seriesModel.getRawData(); 11 | var colorList = seriesModel.get('color'); 12 | 13 | data.each(function (index) { 14 | var name = data.getName(index); 15 | var color = colorList[(seriesModel.nameMap[name] - 1) % colorList.length]; 16 | rawData.setItemVisual(index, 'color', color); 17 | }); 18 | }); 19 | }; 20 | }); 21 | -------------------------------------------------------------------------------- /echarts/src/chart/treemap.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var echarts = require('../echarts'); 4 | 5 | require('./treemap/TreemapSeries'); 6 | require('./treemap/TreemapView'); 7 | require('./treemap/treemapAction'); 8 | 9 | echarts.registerVisual(require('./treemap/treemapVisual')); 10 | 11 | echarts.registerLayout(require('./treemap/treemapLayout')); 12 | }); -------------------------------------------------------------------------------- /echarts/src/chart/treemap/treemapAction.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Treemap action 3 | */ 4 | define(function(require) { 5 | 6 | var echarts = require('../../echarts'); 7 | var helper = require('./helper'); 8 | 9 | var noop = function () {}; 10 | 11 | var actionTypes = [ 12 | 'treemapZoomToNode', 13 | 'treemapRender', 14 | 'treemapMove' 15 | ]; 16 | 17 | for (var i = 0; i < actionTypes.length; i++) { 18 | echarts.registerAction({type: actionTypes[i], update: 'updateView'}, noop); 19 | } 20 | 21 | echarts.registerAction( 22 | {type: 'treemapRootToNode', update: 'updateView'}, 23 | function (payload, ecModel) { 24 | 25 | ecModel.eachComponent( 26 | {mainType: 'series', subType: 'treemap', query: payload}, 27 | handleRootToNode 28 | ); 29 | 30 | function handleRootToNode(model, index) { 31 | var targetInfo = helper.retrieveTargetInfo(payload, model); 32 | 33 | if (targetInfo) { 34 | var originViewRoot = model.getViewRoot(); 35 | if (originViewRoot) { 36 | payload.direction = helper.aboveViewRoot(originViewRoot, targetInfo.node) 37 | ? 'rollUp' : 'drillDown'; 38 | } 39 | model.resetViewRoot(targetInfo.node); 40 | } 41 | } 42 | } 43 | ); 44 | 45 | }); -------------------------------------------------------------------------------- /echarts/src/component/angleAxis.js: -------------------------------------------------------------------------------- 1 | define(function(require) { 2 | 'use strict'; 3 | 4 | require('../coord/polar/polarCreator'); 5 | 6 | require('./axis/AngleAxisView'); 7 | }); -------------------------------------------------------------------------------- /echarts/src/component/axis.js: -------------------------------------------------------------------------------- 1 | // TODO boundaryGap 2 | define(function(require) { 3 | 'use strict'; 4 | 5 | require('../coord/cartesian/AxisModel'); 6 | 7 | require('./axis/AxisView'); 8 | }); -------------------------------------------------------------------------------- /echarts/src/component/axis/parallelAxisAction.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var echarts = require('../../echarts'); 4 | 5 | /** 6 | * @payload 7 | * @property {string} parallelAxisId 8 | * @property {Array.>} intervals 9 | */ 10 | var actionInfo = { 11 | type: 'axisAreaSelect', 12 | event: 'axisAreaSelected', 13 | update: 'updateVisual' 14 | }; 15 | echarts.registerAction(actionInfo, function (payload, ecModel) { 16 | ecModel.eachComponent( 17 | {mainType: 'parallelAxis', query: payload}, 18 | function (parallelAxisModel) { 19 | parallelAxisModel.axis.model.setActiveIntervals(payload.intervals); 20 | } 21 | ); 22 | }); 23 | 24 | /** 25 | * @payload 26 | */ 27 | echarts.registerAction('parallelAxisExpand', function (payload, ecModel) { 28 | ecModel.eachComponent( 29 | {mainType: 'parallel', query: payload}, 30 | function (parallelModel) { 31 | parallelModel.setAxisExpand(payload); 32 | } 33 | ); 34 | 35 | }); 36 | }); -------------------------------------------------------------------------------- /echarts/src/component/brush.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Brush component entry 3 | */ 4 | define(function (require) { 5 | 6 | require('../echarts').registerPreprocessor( 7 | require('./brush/preprocessor') 8 | ); 9 | 10 | require('./brush/visualEncoding'); 11 | require('./brush/BrushModel'); 12 | require('./brush/BrushView'); 13 | require('./brush/brushAction'); 14 | 15 | require('./toolbox/feature/Brush'); 16 | 17 | }); -------------------------------------------------------------------------------- /echarts/src/component/brush/brushAction.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Brush action 3 | */ 4 | define(function(require) { 5 | 6 | var echarts = require('../../echarts'); 7 | 8 | /** 9 | * payload: { 10 | * brushIndex: number, or, 11 | * brushId: string, or, 12 | * brushName: string, 13 | * globalRanges: Array 14 | * } 15 | */ 16 | echarts.registerAction( 17 | {type: 'brush', event: 'brush', update: 'updateView'}, 18 | function (payload, ecModel) { 19 | ecModel.eachComponent({mainType: 'brush', query: payload}, function (brushModel) { 20 | brushModel.setAreas(payload.areas); 21 | }); 22 | } 23 | ); 24 | 25 | /** 26 | * payload: { 27 | * brushComponents: [ 28 | * { 29 | * brushId, 30 | * brushIndex, 31 | * brushName, 32 | * series: [ 33 | * { 34 | * seriesId, 35 | * seriesIndex, 36 | * seriesName, 37 | * rawIndices: [21, 34, ...] 38 | * }, 39 | * ... 40 | * ] 41 | * }, 42 | * ... 43 | * ] 44 | * } 45 | */ 46 | echarts.registerAction( 47 | {type: 'brushSelect', event: 'brushSelected', update: 'none'}, 48 | function () {} 49 | ); 50 | }); -------------------------------------------------------------------------------- /echarts/src/component/dataZoom.js: -------------------------------------------------------------------------------- 1 | /** 2 | * DataZoom component entry 3 | */ 4 | define(function (require) { 5 | 6 | require('./dataZoom/typeDefaulter'); 7 | 8 | require('./dataZoom/DataZoomModel'); 9 | require('./dataZoom/DataZoomView'); 10 | 11 | require('./dataZoom/SliderZoomModel'); 12 | require('./dataZoom/SliderZoomView'); 13 | 14 | require('./dataZoom/InsideZoomModel'); 15 | require('./dataZoom/InsideZoomView'); 16 | 17 | require('./dataZoom/dataZoomProcessor'); 18 | require('./dataZoom/dataZoomAction'); 19 | 20 | }); -------------------------------------------------------------------------------- /echarts/src/component/dataZoom/InsideZoomModel.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Data zoom model 3 | */ 4 | define(function(require) { 5 | 6 | return require('./DataZoomModel').extend({ 7 | 8 | type: 'dataZoom.inside', 9 | 10 | /** 11 | * @protected 12 | */ 13 | defaultOption: { 14 | disabled: false, // Whether disable this inside zoom. 15 | zoomLock: false // Whether disable zoom but only pan. 16 | } 17 | }); 18 | }); -------------------------------------------------------------------------------- /echarts/src/component/dataZoom/SelectZoomModel.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Data zoom model 3 | */ 4 | define(function(require) { 5 | 6 | var DataZoomModel = require('./DataZoomModel'); 7 | 8 | return DataZoomModel.extend({ 9 | 10 | type: 'dataZoom.select' 11 | 12 | }); 13 | 14 | }); -------------------------------------------------------------------------------- /echarts/src/component/dataZoom/SelectZoomView.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | return require('./DataZoomView').extend({ 4 | 5 | type: 'dataZoom.select' 6 | 7 | }); 8 | 9 | }); -------------------------------------------------------------------------------- /echarts/src/component/dataZoom/dataZoomAction.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Data zoom action 3 | */ 4 | define(function(require) { 5 | 6 | var zrUtil = require('zrender/core/util'); 7 | var helper = require('./helper'); 8 | var echarts = require('../../echarts'); 9 | 10 | 11 | echarts.registerAction('dataZoom', function (payload, ecModel) { 12 | 13 | var linkedNodesFinder = helper.createLinkedNodesFinder( 14 | zrUtil.bind(ecModel.eachComponent, ecModel, 'dataZoom'), 15 | helper.eachAxisDim, 16 | function (model, dimNames) { 17 | return model.get(dimNames.axisIndex); 18 | } 19 | ); 20 | 21 | var effectedModels = []; 22 | 23 | ecModel.eachComponent( 24 | {mainType: 'dataZoom', query: payload}, 25 | function (model, index) { 26 | effectedModels.push.apply( 27 | effectedModels, linkedNodesFinder(model).nodes 28 | ); 29 | } 30 | ); 31 | 32 | zrUtil.each(effectedModels, function (dataZoomModel, index) { 33 | dataZoomModel.setRawRange({ 34 | start: payload.start, 35 | end: payload.end, 36 | startValue: payload.startValue, 37 | endValue: payload.endValue 38 | }); 39 | }); 40 | 41 | }); 42 | 43 | }); -------------------------------------------------------------------------------- /echarts/src/component/dataZoom/typeDefaulter.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | require('../../model/Component').registerSubTypeDefaulter('dataZoom', function (option) { 4 | // Default 'slider' when no type specified. 5 | return 'slider'; 6 | }); 7 | 8 | }); -------------------------------------------------------------------------------- /echarts/src/component/dataZoomInside.js: -------------------------------------------------------------------------------- 1 | /** 2 | * DataZoom component entry 3 | */ 4 | define(function (require) { 5 | 6 | require('./dataZoom/typeDefaulter'); 7 | 8 | require('./dataZoom/DataZoomModel'); 9 | require('./dataZoom/DataZoomView'); 10 | 11 | require('./dataZoom/InsideZoomModel'); 12 | require('./dataZoom/InsideZoomView'); 13 | 14 | require('./dataZoom/dataZoomProcessor'); 15 | require('./dataZoom/dataZoomAction'); 16 | 17 | }); -------------------------------------------------------------------------------- /echarts/src/component/dataZoomSelect.js: -------------------------------------------------------------------------------- 1 | /** 2 | * DataZoom component entry 3 | */ 4 | define(function (require) { 5 | 6 | require('./dataZoom/typeDefaulter'); 7 | 8 | require('./dataZoom/DataZoomModel'); 9 | require('./dataZoom/DataZoomView'); 10 | 11 | require('./dataZoom/SelectZoomModel'); 12 | require('./dataZoom/SelectZoomView'); 13 | 14 | require('./dataZoom/dataZoomProcessor'); 15 | require('./dataZoom/dataZoomAction'); 16 | 17 | }); -------------------------------------------------------------------------------- /echarts/src/component/geo.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | require('../coord/geo/GeoModel'); 4 | 5 | require('../coord/geo/geoCreator'); 6 | 7 | require('./geo/GeoView'); 8 | 9 | require('../action/geoRoam'); 10 | 11 | var echarts = require('../echarts'); 12 | var zrUtil = require('zrender/core/util'); 13 | 14 | function makeAction(method, actionInfo) { 15 | actionInfo.update = 'updateView'; 16 | echarts.registerAction(actionInfo, function (payload, ecModel) { 17 | var selected = {}; 18 | 19 | ecModel.eachComponent( 20 | { mainType: 'geo', query: payload}, 21 | function (geoModel) { 22 | geoModel[method](payload.name); 23 | var geo = geoModel.coordinateSystem; 24 | zrUtil.each(geo.regions, function (region) { 25 | selected[region.name] = geoModel.isSelected(region.name) || false; 26 | }); 27 | } 28 | ); 29 | 30 | return { 31 | selected: selected, 32 | name: payload.name 33 | } 34 | }); 35 | } 36 | 37 | makeAction('toggleSelected', { 38 | type: 'geoToggleSelect', 39 | event: 'geoselectchanged' 40 | }); 41 | makeAction('select', { 42 | type: 'geoSelect', 43 | event: 'geoselected' 44 | }); 45 | makeAction('unSelect', { 46 | type: 'geoUnSelect', 47 | event: 'geounselected' 48 | }); 49 | }); -------------------------------------------------------------------------------- /echarts/src/component/geo/GeoView.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | 'use strict'; 4 | 5 | var MapDraw = require('../helper/MapDraw'); 6 | 7 | return require('../../echarts').extendComponentView({ 8 | 9 | type: 'geo', 10 | 11 | init: function (ecModel, api) { 12 | var mapDraw = new MapDraw(api, true); 13 | this._mapDraw = mapDraw; 14 | 15 | this.group.add(mapDraw.group); 16 | }, 17 | 18 | render: function (geoModel, ecModel, api, payload) { 19 | // Not render if it is an toggleSelect action from self 20 | if (payload && payload.type === 'geoToggleSelect' 21 | && payload.from === this.uid 22 | ) { 23 | return; 24 | } 25 | 26 | var mapDraw = this._mapDraw; 27 | if (geoModel.get('show')) { 28 | mapDraw.draw(geoModel, ecModel, api, this, payload); 29 | } 30 | else { 31 | this._mapDraw.group.removeAll(); 32 | } 33 | 34 | this.group.silent = geoModel.get('silent'); 35 | }, 36 | 37 | dispose: function () { 38 | this._mapDraw && this._mapDraw.remove(); 39 | } 40 | 41 | }); 42 | }); -------------------------------------------------------------------------------- /echarts/src/component/grid.js: -------------------------------------------------------------------------------- 1 | define(function(require) { 2 | 'use strict'; 3 | 4 | var graphic = require('../util/graphic'); 5 | var zrUtil = require('zrender/core/util'); 6 | var echarts = require('../echarts'); 7 | 8 | require('../coord/cartesian/Grid'); 9 | 10 | require('./axis'); 11 | 12 | // Grid view 13 | echarts.extendComponentView({ 14 | 15 | type: 'grid', 16 | 17 | render: function (gridModel, ecModel) { 18 | this.group.removeAll(); 19 | if (gridModel.get('show')) { 20 | this.group.add(new graphic.Rect({ 21 | shape: gridModel.coordinateSystem.getRect(), 22 | style: zrUtil.defaults({ 23 | fill: gridModel.get('backgroundColor') 24 | }, gridModel.getItemStyle()), 25 | silent: true, 26 | z2: -1 27 | })); 28 | } 29 | } 30 | 31 | }); 32 | 33 | echarts.registerPreprocessor(function (option) { 34 | // Only create grid when need 35 | if (option.xAxis && option.yAxis && !option.grid) { 36 | option.grid = {}; 37 | } 38 | }); 39 | }); -------------------------------------------------------------------------------- /echarts/src/component/helper/interactionMutex.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var ATTR = '\0_ec_interaction_mutex'; 4 | 5 | var interactionMutex = { 6 | 7 | take: function (zr, resourceKey, userKey) { 8 | var store = getStore(zr); 9 | store[resourceKey] = userKey; 10 | }, 11 | 12 | release: function (zr, resourceKey, userKey) { 13 | var store = getStore(zr); 14 | var uKey = store[resourceKey]; 15 | 16 | if (uKey === userKey) { 17 | store[resourceKey] = null; 18 | } 19 | }, 20 | 21 | isTaken: function (zr, resourceKey) { 22 | return !!getStore(zr)[resourceKey]; 23 | } 24 | }; 25 | 26 | function getStore(zr) { 27 | return zr[ATTR] || (zr[ATTR] = {}); 28 | } 29 | 30 | /** 31 | * payload: { 32 | * type: 'takeGlobalCursor', 33 | * key: 'dataZoomSelect', or 'brush', or ..., 34 | * If no userKey, release global cursor. 35 | * } 36 | */ 37 | require('../../echarts').registerAction( 38 | {type: 'takeGlobalCursor', event: 'globalCursorTaken', update: 'update'}, 39 | function () {} 40 | ); 41 | 42 | return interactionMutex; 43 | }); -------------------------------------------------------------------------------- /echarts/src/component/legend.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Legend component entry file8 3 | */ 4 | define(function (require) { 5 | 6 | require('./legend/LegendModel'); 7 | require('./legend/legendAction'); 8 | require('./legend/LegendView'); 9 | 10 | var echarts = require('../echarts'); 11 | // Series Filter 12 | echarts.registerProcessor(require('./legend/legendFilter')); 13 | }); -------------------------------------------------------------------------------- /echarts/src/component/legend/legendFilter.js: -------------------------------------------------------------------------------- 1 | define(function () { 2 | return function (ecModel) { 3 | var legendModels = ecModel.findComponents({ 4 | mainType: 'legend' 5 | }); 6 | if (legendModels && legendModels.length) { 7 | ecModel.filterSeries(function (series) { 8 | // If in any legend component the status is not selected. 9 | // Because in legend series is assumed selected when it is not in the legend data. 10 | for (var i = 0; i < legendModels.length; i++) { 11 | if (!legendModels[i].isSelected(series.name)) { 12 | return false; 13 | } 14 | } 15 | return true; 16 | }); 17 | } 18 | }; 19 | }); -------------------------------------------------------------------------------- /echarts/src/component/markArea.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | require('./marker/MarkAreaModel'); 4 | require('./marker/MarkAreaView'); 5 | 6 | require('../echarts').registerPreprocessor(function (opt) { 7 | // Make sure markArea component is enabled 8 | opt.markArea = opt.markArea || {}; 9 | }); 10 | }); -------------------------------------------------------------------------------- /echarts/src/component/markLine.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | require('./marker/MarkLineModel'); 4 | require('./marker/MarkLineView'); 5 | 6 | require('../echarts').registerPreprocessor(function (opt) { 7 | // Make sure markLine component is enabled 8 | opt.markLine = opt.markLine || {}; 9 | }); 10 | }); -------------------------------------------------------------------------------- /echarts/src/component/markPoint.js: -------------------------------------------------------------------------------- 1 | // HINT Markpoint can't be used too much 2 | define(function (require) { 3 | 4 | require('./marker/MarkPointModel'); 5 | require('./marker/MarkPointView'); 6 | 7 | require('../echarts').registerPreprocessor(function (opt) { 8 | // Make sure markPoint component is enabled 9 | opt.markPoint = opt.markPoint || {}; 10 | }); 11 | }); -------------------------------------------------------------------------------- /echarts/src/component/marker/MarkAreaModel.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | return require('./MarkerModel').extend({ 4 | 5 | type: 'markArea', 6 | 7 | defaultOption: { 8 | zlevel: 0, 9 | // PENDING 10 | z: 1, 11 | tooltip: { 12 | trigger: 'item' 13 | }, 14 | // markArea should fixed on the coordinate system 15 | animation: false, 16 | label: { 17 | normal: { 18 | show: true, 19 | position: 'top' 20 | }, 21 | emphasis: { 22 | show: true, 23 | position: 'top' 24 | } 25 | }, 26 | itemStyle: { 27 | normal: { 28 | // color and borderColor default to use color from series 29 | // color: 'auto' 30 | // borderColor: 'auto' 31 | borderWidth: 0 32 | } 33 | } 34 | } 35 | }); 36 | }); -------------------------------------------------------------------------------- /echarts/src/component/marker/MarkLineModel.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | return require('./MarkerModel').extend({ 4 | 5 | type: 'markLine', 6 | 7 | defaultOption: { 8 | zlevel: 0, 9 | z: 5, 10 | 11 | symbol: ['circle', 'arrow'], 12 | symbolSize: [8, 16], 13 | 14 | //symbolRotate: 0, 15 | 16 | precision: 2, 17 | tooltip: { 18 | trigger: 'item' 19 | }, 20 | label: { 21 | normal: { 22 | show: true, 23 | position: 'end' 24 | }, 25 | emphasis: { 26 | show: true 27 | } 28 | }, 29 | lineStyle: { 30 | normal: { 31 | type: 'dashed' 32 | }, 33 | emphasis: { 34 | width: 3 35 | } 36 | }, 37 | animationEasing: 'linear' 38 | } 39 | }); 40 | }); -------------------------------------------------------------------------------- /echarts/src/component/marker/MarkPointModel.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | return require('./MarkerModel').extend({ 4 | 5 | type: 'markPoint', 6 | 7 | defaultOption: { 8 | zlevel: 0, 9 | z: 5, 10 | symbol: 'pin', 11 | symbolSize: 50, 12 | //symbolRotate: 0, 13 | //symbolOffset: [0, 0] 14 | tooltip: { 15 | trigger: 'item' 16 | }, 17 | label: { 18 | normal: { 19 | show: true, 20 | position: 'inside' 21 | }, 22 | emphasis: { 23 | show: true 24 | } 25 | }, 26 | itemStyle: { 27 | normal: { 28 | borderWidth: 2 29 | } 30 | } 31 | } 32 | }); 33 | }); -------------------------------------------------------------------------------- /echarts/src/component/marker/MarkerView.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | return require('../../echarts').extendComponentView({ 4 | 5 | type: 'marker', 6 | 7 | init: function () { 8 | /** 9 | * Markline grouped by series 10 | * @private 11 | * @type {Object} 12 | */ 13 | this.markerGroupMap = {}; 14 | }, 15 | 16 | render: function (markerModel, ecModel, api) { 17 | var markerGroupMap = this.markerGroupMap; 18 | for (var name in markerGroupMap) { 19 | if (markerGroupMap.hasOwnProperty(name)) { 20 | markerGroupMap[name].__keep = false; 21 | } 22 | } 23 | 24 | var markerModelKey = this.type + 'Model'; 25 | ecModel.eachSeries(function (seriesModel) { 26 | var markerModel = seriesModel[markerModelKey]; 27 | markerModel && this.renderSeries(seriesModel, markerModel, ecModel, api); 28 | }, this); 29 | 30 | for (var name in markerGroupMap) { 31 | if (markerGroupMap.hasOwnProperty(name) && !markerGroupMap[name].__keep) { 32 | this.group.remove(markerGroupMap[name].group); 33 | } 34 | } 35 | }, 36 | 37 | renderSeries: function () {} 38 | }); 39 | }); -------------------------------------------------------------------------------- /echarts/src/component/parallelAxis.js: -------------------------------------------------------------------------------- 1 | define(function(require) { 2 | 3 | require('../coord/parallel/parallelCreator'); 4 | require('./axis/parallelAxisAction'); 5 | require('./axis/ParallelAxisView'); 6 | 7 | }); -------------------------------------------------------------------------------- /echarts/src/component/polar.js: -------------------------------------------------------------------------------- 1 | define(function(require) { 2 | 'use strict'; 3 | 4 | require('../coord/polar/polarCreator'); 5 | require('./angleAxis'); 6 | require('./radiusAxis'); 7 | 8 | // Polar view 9 | require('../echarts').extendComponentView({ 10 | type: 'polar' 11 | }); 12 | }); -------------------------------------------------------------------------------- /echarts/src/component/radar.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | require('../coord/radar/Radar'); 4 | require('../coord/radar/RadarModel'); 5 | 6 | require('./radar/RadarView'); 7 | }); -------------------------------------------------------------------------------- /echarts/src/component/radiusAxis.js: -------------------------------------------------------------------------------- 1 | define(function(require) { 2 | 3 | require('../coord/polar/polarCreator'); 4 | 5 | require('./axis/RadiusAxisView'); 6 | }); -------------------------------------------------------------------------------- /echarts/src/component/singleAxis.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | require('../coord/single/singleCreator'); 4 | require('./axis/SingleAxisView'); 5 | require('../coord/single/AxisModel'); 6 | 7 | var echarts = require('../echarts'); 8 | 9 | echarts.extendComponentView({ 10 | type: 'single' 11 | }); 12 | 13 | }); -------------------------------------------------------------------------------- /echarts/src/component/timeline.js: -------------------------------------------------------------------------------- 1 | /** 2 | * DataZoom component entry 3 | */ 4 | define(function (require) { 5 | 6 | var echarts = require('../echarts'); 7 | 8 | echarts.registerPreprocessor(require('./timeline/preprocessor')); 9 | 10 | require('./timeline/typeDefaulter'); 11 | require('./timeline/timelineAction'); 12 | require('./timeline/SliderTimelineModel'); 13 | require('./timeline/SliderTimelineView'); 14 | 15 | }); -------------------------------------------------------------------------------- /echarts/src/component/timeline/TimelineView.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Timeline view 3 | */ 4 | define(function (require) { 5 | 6 | // var zrUtil = require('zrender/core/util'); 7 | // var graphic = require('../../util/graphic'); 8 | var ComponentView = require('../../view/Component'); 9 | 10 | return ComponentView.extend({ 11 | 12 | type: 'timeline' 13 | }); 14 | 15 | }); -------------------------------------------------------------------------------- /echarts/src/component/timeline/timelineAction.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Timeilne action 3 | */ 4 | define(function(require) { 5 | 6 | var echarts = require('../../echarts'); 7 | var zrUtil = require('zrender/core/util'); 8 | 9 | echarts.registerAction( 10 | 11 | {type: 'timelineChange', event: 'timelineChanged', update: 'prepareAndUpdate'}, 12 | 13 | function (payload, ecModel) { 14 | 15 | var timelineModel = ecModel.getComponent('timeline'); 16 | if (timelineModel && payload.currentIndex != null) { 17 | timelineModel.setCurrentIndex(payload.currentIndex); 18 | 19 | if (!timelineModel.get('loop', true) && timelineModel.isIndexMax()) { 20 | timelineModel.setPlayState(false); 21 | } 22 | } 23 | 24 | // Set normalized currentIndex to payload. 25 | ecModel.resetOption('timeline'); 26 | 27 | return zrUtil.defaults({ 28 | currentIndex: timelineModel.option.currentIndex 29 | }, payload); 30 | } 31 | ); 32 | 33 | echarts.registerAction( 34 | 35 | {type: 'timelinePlayChange', event: 'timelinePlayChanged', update: 'update'}, 36 | 37 | function (payload, ecModel) { 38 | var timelineModel = ecModel.getComponent('timeline'); 39 | if (timelineModel && payload.playState != null) { 40 | timelineModel.setPlayState(payload.playState); 41 | } 42 | } 43 | ); 44 | 45 | }); -------------------------------------------------------------------------------- /echarts/src/component/timeline/typeDefaulter.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | require('../../model/Component').registerSubTypeDefaulter('timeline', function () { 4 | // Only slider now. 5 | return 'slider'; 6 | }); 7 | 8 | }); -------------------------------------------------------------------------------- /echarts/src/component/toolbox.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | require('./toolbox/ToolboxModel'); 4 | require('./toolbox/ToolboxView'); 5 | 6 | require('./toolbox/feature/SaveAsImage'); 7 | require('./toolbox/feature/MagicType'); 8 | require('./toolbox/feature/DataView'); 9 | require('./toolbox/feature/DataZoom'); 10 | require('./toolbox/feature/Restore'); 11 | }); -------------------------------------------------------------------------------- /echarts/src/component/toolbox/ToolboxModel.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var featureManager = require('./featureManager'); 4 | var zrUtil = require('zrender/core/util'); 5 | 6 | var ToolboxModel = require('../../echarts').extendComponentModel({ 7 | 8 | type: 'toolbox', 9 | 10 | layoutMode: { 11 | type: 'box', 12 | ignoreSize: true 13 | }, 14 | 15 | mergeDefaultAndTheme: function (option) { 16 | ToolboxModel.superApply(this, 'mergeDefaultAndTheme', arguments); 17 | 18 | zrUtil.each(this.option.feature, function (featureOpt, featureName) { 19 | var Feature = featureManager.get(featureName); 20 | Feature && zrUtil.merge(featureOpt, Feature.defaultOption); 21 | }); 22 | }, 23 | 24 | defaultOption: { 25 | 26 | show: true, 27 | 28 | z: 6, 29 | 30 | zlevel: 0, 31 | 32 | orient: 'horizontal', 33 | 34 | left: 'right', 35 | 36 | top: 'top', 37 | 38 | // right 39 | // bottom 40 | 41 | backgroundColor: 'transparent', 42 | 43 | borderColor: '#ccc', 44 | 45 | borderWidth: 0, 46 | 47 | padding: 5, 48 | 49 | itemSize: 15, 50 | 51 | itemGap: 8, 52 | 53 | showTitle: true, 54 | 55 | iconStyle: { 56 | normal: { 57 | borderColor: '#666', 58 | color: 'none' 59 | }, 60 | emphasis: { 61 | borderColor: '#3E98C5' 62 | } 63 | } 64 | // textStyle: {}, 65 | 66 | // feature 67 | } 68 | }); 69 | 70 | return ToolboxModel; 71 | }); -------------------------------------------------------------------------------- /echarts/src/component/toolbox/feature/Restore.js: -------------------------------------------------------------------------------- 1 | define(function(require) { 2 | 'use strict'; 3 | 4 | var history = require('../../dataZoom/history'); 5 | 6 | function Restore(model) { 7 | this.model = model; 8 | } 9 | 10 | Restore.defaultOption = { 11 | show: true, 12 | icon: 'M3.8,33.4 M47,18.9h9.8V8.7 M56.3,20.1 C52.1,9,40.5,0.6,26.8,2.1C12.6,3.7,1.6,16.2,2.1,30.6 M13,41.1H3.1v10.2 M3.7,39.9c4.2,11.1,15.8,19.5,29.5,18 c14.2-1.6,25.2-14.1,24.7-28.5', 13 | title: '还原' 14 | }; 15 | 16 | var proto = Restore.prototype; 17 | 18 | proto.onclick = function (ecModel, api, type) { 19 | history.clear(ecModel); 20 | 21 | api.dispatchAction({ 22 | type: 'restore', 23 | from: this.uid 24 | }); 25 | }; 26 | 27 | 28 | require('../featureManager').register('restore', Restore); 29 | 30 | 31 | require('../../../echarts').registerAction( 32 | {type: 'restore', event: 'restore', update: 'prepareAndUpdate'}, 33 | function (payload, ecModel) { 34 | ecModel.resetOption('recreate'); 35 | } 36 | ); 37 | 38 | return Restore; 39 | }); -------------------------------------------------------------------------------- /echarts/src/component/toolbox/featureManager.js: -------------------------------------------------------------------------------- 1 | define(function(require) { 2 | 'use strict'; 3 | 4 | var features = {}; 5 | 6 | return { 7 | register: function (name, ctor) { 8 | features[name] = ctor; 9 | }, 10 | 11 | get: function (name) { 12 | return features[name]; 13 | } 14 | }; 15 | }); -------------------------------------------------------------------------------- /echarts/src/component/tooltip.js: -------------------------------------------------------------------------------- 1 | // FIXME Better way to pack data in graphic element 2 | define(function (require) { 3 | 4 | require('./tooltip/TooltipModel'); 5 | 6 | require('./tooltip/TooltipView'); 7 | 8 | // Show tip action 9 | /** 10 | * @action 11 | * @property {string} type 12 | * @property {number} seriesIndex 13 | * @property {number} dataIndex 14 | * @property {number} [x] 15 | * @property {number} [y] 16 | */ 17 | require('../echarts').registerAction( 18 | { 19 | type: 'showTip', 20 | event: 'showTip', 21 | update: 'tooltip:manuallyShowTip' 22 | }, 23 | // noop 24 | function () {} 25 | ); 26 | // Hide tip action 27 | require('../echarts').registerAction( 28 | { 29 | type: 'hideTip', 30 | event: 'hideTip', 31 | update: 'tooltip:manuallyHideTip' 32 | }, 33 | // noop 34 | function () {} 35 | ); 36 | }); -------------------------------------------------------------------------------- /echarts/src/component/visualMap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * visualMap component entry 3 | */ 4 | define(function (require) { 5 | 6 | require('./visualMapContinuous'); 7 | require('./visualMapPiecewise'); 8 | 9 | }); -------------------------------------------------------------------------------- /echarts/src/component/visualMap/preprocessor.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file VisualMap preprocessor 3 | */ 4 | define(function(require) { 5 | 6 | var zrUtil = require('zrender/core/util'); 7 | var each = zrUtil.each; 8 | 9 | return function (option) { 10 | var visualMap = option && option.visualMap; 11 | 12 | if (!zrUtil.isArray(visualMap)) { 13 | visualMap = visualMap ? [visualMap] : []; 14 | } 15 | 16 | each(visualMap, function (opt) { 17 | if (!opt) { 18 | return; 19 | } 20 | 21 | // rename splitList to pieces 22 | if (has(opt, 'splitList') && !has(opt, 'pieces')) { 23 | opt.pieces = opt.splitList; 24 | delete opt.splitList; 25 | } 26 | 27 | var pieces = opt.pieces; 28 | if (pieces && zrUtil.isArray(pieces)) { 29 | each(pieces, function (piece) { 30 | if (zrUtil.isObject(piece)) { 31 | if (has(piece, 'start') && !has(piece, 'min')) { 32 | piece.min = piece.start; 33 | } 34 | if (has(piece, 'end') && !has(piece, 'max')) { 35 | piece.max = piece.end; 36 | } 37 | } 38 | }); 39 | } 40 | }); 41 | }; 42 | 43 | function has(obj, name) { 44 | return obj && obj.hasOwnProperty && obj.hasOwnProperty(name); 45 | } 46 | 47 | }); -------------------------------------------------------------------------------- /echarts/src/component/visualMap/typeDefaulter.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | require('../../model/Component').registerSubTypeDefaulter('visualMap', function (option) { 4 | // Compatible with ec2, when splitNumber === 0, continuous visualMap will be used. 5 | return ( 6 | !option.categories 7 | && ( 8 | !( 9 | option.pieces 10 | ? option.pieces.length > 0 11 | : option.splitNumber > 0 12 | ) 13 | || option.calculable 14 | ) 15 | ) 16 | ? 'continuous' : 'piecewise'; 17 | }); 18 | 19 | }); -------------------------------------------------------------------------------- /echarts/src/component/visualMap/visualMapAction.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Data range action 3 | */ 4 | define(function(require) { 5 | 6 | var echarts = require('../../echarts'); 7 | 8 | var actionInfo = { 9 | type: 'selectDataRange', 10 | event: 'dataRangeSelected', 11 | // FIXME use updateView appears wrong 12 | update: 'update' 13 | }; 14 | 15 | echarts.registerAction(actionInfo, function (payload, ecModel) { 16 | 17 | ecModel.eachComponent({mainType: 'visualMap', query: payload}, function (model) { 18 | model.setSelected(payload.selected); 19 | }); 20 | 21 | }); 22 | 23 | }); -------------------------------------------------------------------------------- /echarts/src/component/visualMapContinuous.js: -------------------------------------------------------------------------------- 1 | /** 2 | * DataZoom component entry 3 | */ 4 | define(function (require) { 5 | 6 | require('../echarts').registerPreprocessor( 7 | require('./visualMap/preprocessor') 8 | ); 9 | 10 | require('./visualMap/typeDefaulter'); 11 | require('./visualMap/visualEncoding'); 12 | require('./visualMap/ContinuousModel'); 13 | require('./visualMap/ContinuousView'); 14 | require('./visualMap/visualMapAction'); 15 | 16 | }); -------------------------------------------------------------------------------- /echarts/src/component/visualMapPiecewise.js: -------------------------------------------------------------------------------- 1 | /** 2 | * DataZoom component entry 3 | */ 4 | define(function (require) { 5 | 6 | require('../echarts').registerPreprocessor( 7 | require('./visualMap/preprocessor') 8 | ); 9 | 10 | require('./visualMap/typeDefaulter'); 11 | require('./visualMap/visualEncoding'); 12 | require('./visualMap/PiecewiseModel'); 13 | require('./visualMap/PiecewiseView'); 14 | require('./visualMap/visualMapAction'); 15 | 16 | }); -------------------------------------------------------------------------------- /echarts/src/coord/cartesian/GridModel.js: -------------------------------------------------------------------------------- 1 | // Grid 是在有直角坐标系的时候必须要存在的 2 | // 所以这里也要被 Cartesian2D 依赖 3 | define(function(require) { 4 | 5 | 'use strict'; 6 | 7 | require('./AxisModel'); 8 | var ComponentModel = require('../../model/Component'); 9 | 10 | return ComponentModel.extend({ 11 | 12 | type: 'grid', 13 | 14 | dependencies: ['xAxis', 'yAxis'], 15 | 16 | layoutMode: 'box', 17 | 18 | /** 19 | * @type {module:echarts/coord/cartesian/Grid} 20 | */ 21 | coordinateSystem: null, 22 | 23 | defaultOption: { 24 | show: false, 25 | zlevel: 0, 26 | z: 0, 27 | left: '10%', 28 | top: 60, 29 | right: '10%', 30 | bottom: 60, 31 | // If grid size contain label 32 | containLabel: false, 33 | // width: {totalWidth} - left - right, 34 | // height: {totalHeight} - top - bottom, 35 | backgroundColor: 'rgba(0,0,0,0)', 36 | borderWidth: 1, 37 | borderColor: '#ccc' 38 | } 39 | }); 40 | }); -------------------------------------------------------------------------------- /echarts/src/coord/cartesian/axisLabelInterval.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Helper function for axisLabelInterval calculation 3 | */ 4 | 5 | define(function(require) { 6 | 'use strict'; 7 | 8 | var zrUtil = require('zrender/core/util'); 9 | var axisHelper = require('../axisHelper'); 10 | 11 | return function (axis) { 12 | var axisModel = axis.model; 13 | var labelModel = axisModel.getModel('axisLabel'); 14 | var labelInterval = labelModel.get('interval'); 15 | if (!(axis.type === 'category' && labelInterval === 'auto')) { 16 | return labelInterval === 'auto' ? 0 : labelInterval; 17 | } 18 | 19 | return axisHelper.getAxisLabelInterval( 20 | zrUtil.map(axis.scale.getTicks(), axis.dataToCoord, axis), 21 | axisModel.getFormattedLabels(), 22 | labelModel.getModel('textStyle').getFont(), 23 | axis.isHorizontal() 24 | ); 25 | }; 26 | }); -------------------------------------------------------------------------------- /echarts/src/coord/geo/fix/geoCoord.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var zrUtil = require('zrender/core/util'); 4 | 5 | var geoCoordMap = { 6 | 'Russia': [100, 60], 7 | 'United States of America': [-99, 38] 8 | }; 9 | 10 | return function (geo) { 11 | zrUtil.each(geo.regions, function (region) { 12 | var geoCoord = geoCoordMap[region.name]; 13 | if (geoCoord) { 14 | var cp = region.center; 15 | cp[0] = geoCoord[0]; 16 | cp[1] = geoCoord[1]; 17 | } 18 | }); 19 | }; 20 | }); -------------------------------------------------------------------------------- /echarts/src/coord/geo/fix/nanhai.js: -------------------------------------------------------------------------------- 1 | // Fix for 南海诸岛 2 | define(function (require) { 3 | 4 | var Region = require('../Region'); 5 | 6 | var geoCoord = [126, 25]; 7 | 8 | var points = [ 9 | [[0,3.5],[7,11.2],[15,11.9],[30,7],[42,0.7],[52,0.7], 10 | [56,7.7],[59,0.7],[64,0.7],[64,0],[5,0],[0,3.5]], 11 | [[13,16.1],[19,14.7],[16,21.7],[11,23.1],[13,16.1]], 12 | [[12,32.2],[14,38.5],[15,38.5],[13,32.2],[12,32.2]], 13 | [[16,47.6],[12,53.2],[13,53.2],[18,47.6],[16,47.6]], 14 | [[6,64.4],[8,70],[9,70],[8,64.4],[6,64.4]], 15 | [[23,82.6],[29,79.8],[30,79.8],[25,82.6],[23,82.6]], 16 | [[37,70.7],[43,62.3],[44,62.3],[39,70.7],[37,70.7]], 17 | [[48,51.1],[51,45.5],[53,45.5],[50,51.1],[48,51.1]], 18 | [[51,35],[51,28.7],[53,28.7],[53,35],[51,35]], 19 | [[52,22.4],[55,17.5],[56,17.5],[53,22.4],[52,22.4]], 20 | [[58,12.6],[62,7],[63,7],[60,12.6],[58,12.6]], 21 | [[0,3.5],[0,93.1],[64,93.1],[64,0],[63,0],[63,92.4], 22 | [1,92.4],[1,3.5],[0,3.5]] 23 | ]; 24 | for (var i = 0; i < points.length; i++) { 25 | for (var k = 0; k < points[i].length; k++) { 26 | points[i][k][0] /= 10.5; 27 | points[i][k][1] /= -10.5 / 0.75; 28 | 29 | points[i][k][0] += geoCoord[0]; 30 | points[i][k][1] += geoCoord[1]; 31 | } 32 | } 33 | return function (geo) { 34 | if (geo.map === 'china') { 35 | geo.regions.push(new Region( 36 | '南海诸岛', points, geoCoord 37 | )); 38 | } 39 | }; 40 | }); -------------------------------------------------------------------------------- /echarts/src/coord/geo/fix/textCoord.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var zrUtil = require('zrender/core/util'); 4 | 5 | var coordsOffsetMap = { 6 | '南海诸岛' : [32, 80], 7 | // 全国 8 | '广东': [0, -10], 9 | '香港': [10, 5], 10 | '澳门': [-10, 10], 11 | //'北京': [-10, 0], 12 | '天津': [5, 5] 13 | }; 14 | 15 | return function (geo) { 16 | zrUtil.each(geo.regions, function (region) { 17 | var coordFix = coordsOffsetMap[region.name]; 18 | if (coordFix) { 19 | var cp = region.center; 20 | cp[0] += coordFix[0] / 10.5; 21 | cp[1] += -coordFix[1] / (10.5 / 0.75); 22 | } 23 | }); 24 | }; 25 | }); -------------------------------------------------------------------------------- /echarts/src/coord/parallel/ParallelAxis.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var zrUtil = require('zrender/core/util'); 4 | var Axis = require('../Axis'); 5 | 6 | /** 7 | * @constructor module:echarts/coord/parallel/ParallelAxis 8 | * @extends {module:echarts/coord/Axis} 9 | * @param {string} dim 10 | * @param {*} scale 11 | * @param {Array.} coordExtent 12 | * @param {string} axisType 13 | */ 14 | var ParallelAxis = function (dim, scale, coordExtent, axisType, axisIndex) { 15 | 16 | Axis.call(this, dim, scale, coordExtent); 17 | 18 | /** 19 | * Axis type 20 | * - 'category' 21 | * - 'value' 22 | * - 'time' 23 | * - 'log' 24 | * @type {string} 25 | */ 26 | this.type = axisType || 'value'; 27 | 28 | /** 29 | * @type {number} 30 | * @readOnly 31 | */ 32 | this.axisIndex = axisIndex; 33 | }; 34 | 35 | ParallelAxis.prototype = { 36 | 37 | constructor: ParallelAxis, 38 | 39 | /** 40 | * Axis model 41 | * @param {module:echarts/coord/parallel/AxisModel} 42 | */ 43 | model: null 44 | 45 | }; 46 | 47 | zrUtil.inherits(ParallelAxis, Axis); 48 | 49 | return ParallelAxis; 50 | }); -------------------------------------------------------------------------------- /echarts/src/coord/parallel/parallelCreator.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Parallel coordinate system creater. 3 | */ 4 | define(function(require) { 5 | 6 | var Parallel = require('./Parallel'); 7 | 8 | function create(ecModel, api) { 9 | var coordSysList = []; 10 | 11 | ecModel.eachComponent('parallel', function (parallelModel, idx) { 12 | var coordSys = new Parallel(parallelModel, ecModel, api); 13 | 14 | coordSys.name = 'parallel_' + idx; 15 | coordSys.resize(parallelModel, api); 16 | 17 | parallelModel.coordinateSystem = coordSys; 18 | coordSys.model = parallelModel; 19 | 20 | coordSysList.push(coordSys); 21 | }); 22 | 23 | // Inject the coordinateSystems into seriesModel 24 | ecModel.eachSeries(function (seriesModel) { 25 | if (seriesModel.get('coordinateSystem') === 'parallel') { 26 | var parallelModel = ecModel.queryComponents({ 27 | mainType: 'parallel', 28 | index: seriesModel.get('parallelIndex'), 29 | id: seriesModel.get('parallelId') 30 | })[0]; 31 | seriesModel.coordinateSystem = parallelModel.coordinateSystem; 32 | } 33 | }); 34 | 35 | return coordSysList; 36 | } 37 | 38 | require('../../CoordinateSystem').register('parallel', {create: create}); 39 | 40 | }); -------------------------------------------------------------------------------- /echarts/src/coord/parallel/parallelPreprocessor.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var zrUtil = require('zrender/core/util'); 4 | var modelUtil = require('../../util/model'); 5 | 6 | return function (option) { 7 | createParallelIfNeeded(option); 8 | mergeAxisOptionFromParallel(option); 9 | }; 10 | 11 | /** 12 | * Create a parallel coordinate if not exists. 13 | * @inner 14 | */ 15 | function createParallelIfNeeded(option) { 16 | if (option.parallel) { 17 | return; 18 | } 19 | 20 | var hasParallelSeries = false; 21 | 22 | zrUtil.each(option.series, function (seriesOpt) { 23 | if (seriesOpt && seriesOpt.type === 'parallel') { 24 | hasParallelSeries = true; 25 | } 26 | }); 27 | 28 | if (hasParallelSeries) { 29 | option.parallel = [{}]; 30 | } 31 | } 32 | 33 | /** 34 | * Merge aixs definition from parallel option (if exists) to axis option. 35 | * @inner 36 | */ 37 | function mergeAxisOptionFromParallel(option) { 38 | var axes = modelUtil.normalizeToArray(option.parallelAxis); 39 | 40 | zrUtil.each(axes, function (axisOption) { 41 | if (!zrUtil.isObject(axisOption)) { 42 | return; 43 | } 44 | 45 | var parallelIndex = axisOption.parallelIndex || 0; 46 | var parallelOption = modelUtil.normalizeToArray(option.parallel)[parallelIndex]; 47 | 48 | if (parallelOption && parallelOption.parallelAxisDefault) { 49 | zrUtil.merge(axisOption, parallelOption.parallelAxisDefault, false); 50 | } 51 | }); 52 | } 53 | 54 | }); -------------------------------------------------------------------------------- /echarts/src/coord/polar/AngleAxis.js: -------------------------------------------------------------------------------- 1 | define(function(require) { 2 | 'use strict'; 3 | 4 | var zrUtil = require('zrender/core/util'); 5 | var Axis = require('../Axis'); 6 | 7 | function AngleAxis(scale, angleExtent) { 8 | 9 | angleExtent = angleExtent || [0, 360]; 10 | 11 | Axis.call(this, 'angle', scale, angleExtent); 12 | 13 | /** 14 | * Axis type 15 | * - 'category' 16 | * - 'value' 17 | * - 'time' 18 | * - 'log' 19 | * @type {string} 20 | */ 21 | this.type = 'category'; 22 | } 23 | 24 | AngleAxis.prototype = { 25 | 26 | constructor: AngleAxis, 27 | 28 | dataToAngle: Axis.prototype.dataToCoord, 29 | 30 | angleToData: Axis.prototype.coordToData 31 | }; 32 | 33 | zrUtil.inherits(AngleAxis, Axis); 34 | 35 | return AngleAxis; 36 | }); -------------------------------------------------------------------------------- /echarts/src/coord/polar/AxisModel.js: -------------------------------------------------------------------------------- 1 | define(function(require) { 2 | 3 | 'use strict'; 4 | 5 | var zrUtil = require('zrender/core/util'); 6 | var ComponentModel = require('../../model/Component'); 7 | var axisModelCreator = require('../axisModelCreator'); 8 | 9 | var PolarAxisModel = ComponentModel.extend({ 10 | 11 | type: 'polarAxis', 12 | 13 | /** 14 | * @type {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis} 15 | */ 16 | axis: null, 17 | 18 | /** 19 | * @override 20 | */ 21 | getCoordSysModel: function () { 22 | return this.ecModel.queryComponents({ 23 | mainType: 'polar', 24 | index: this.option.polarIndex, 25 | id: this.option.polarId 26 | })[0]; 27 | } 28 | 29 | }); 30 | 31 | zrUtil.merge(PolarAxisModel.prototype, require('../axisModelCommonMixin')); 32 | 33 | var polarAxisDefaultExtendedOption = { 34 | angle: { 35 | // polarIndex: 0, 36 | // polarId: '', 37 | 38 | startAngle: 90, 39 | 40 | clockwise: true, 41 | 42 | splitNumber: 12, 43 | 44 | axisLabel: { 45 | rotate: false 46 | } 47 | }, 48 | radius: { 49 | // polarIndex: 0, 50 | // polarId: '', 51 | 52 | splitNumber: 5 53 | } 54 | }; 55 | 56 | function getAxisType(axisDim, option) { 57 | // Default axis with data is category axis 58 | return option.type || (option.data ? 'category' : 'value'); 59 | } 60 | 61 | axisModelCreator('angle', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.angle); 62 | axisModelCreator('radius', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.radius); 63 | 64 | }); -------------------------------------------------------------------------------- /echarts/src/coord/polar/PolarModel.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | 'use strict'; 4 | 5 | require('./AxisModel'); 6 | 7 | require('../../echarts').extendComponentModel({ 8 | 9 | type: 'polar', 10 | 11 | dependencies: ['polarAxis', 'angleAxis'], 12 | 13 | /** 14 | * @type {module:echarts/coord/polar/Polar} 15 | */ 16 | coordinateSystem: null, 17 | 18 | /** 19 | * @param {string} axisType 20 | * @return {module:echarts/coord/polar/AxisModel} 21 | */ 22 | findAxisModel: function (axisType) { 23 | var foundAxisModel; 24 | var ecModel = this.ecModel; 25 | 26 | ecModel.eachComponent(axisType, function (axisModel) { 27 | if (axisModel.getCoordSysModel() === this) { 28 | foundAxisModel = axisModel; 29 | } 30 | }, this); 31 | return foundAxisModel; 32 | }, 33 | 34 | defaultOption: { 35 | 36 | zlevel: 0, 37 | 38 | z: 0, 39 | 40 | center: ['50%', '50%'], 41 | 42 | radius: '80%' 43 | } 44 | }); 45 | }); -------------------------------------------------------------------------------- /echarts/src/coord/polar/RadiusAxis.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 'use strict'; 3 | 4 | var zrUtil = require('zrender/core/util'); 5 | var Axis = require('../Axis'); 6 | 7 | function RadiusAxis(scale, radiusExtent) { 8 | 9 | Axis.call(this, 'radius', scale, radiusExtent); 10 | 11 | /** 12 | * Axis type 13 | * - 'category' 14 | * - 'value' 15 | * - 'time' 16 | * - 'log' 17 | * @type {string} 18 | */ 19 | this.type = 'category'; 20 | } 21 | 22 | RadiusAxis.prototype = { 23 | 24 | constructor: RadiusAxis, 25 | 26 | dataToRadius: Axis.prototype.dataToCoord, 27 | 28 | radiusToData: Axis.prototype.coordToData 29 | }; 30 | 31 | zrUtil.inherits(RadiusAxis, Axis); 32 | 33 | return RadiusAxis; 34 | }); -------------------------------------------------------------------------------- /echarts/src/coord/radar/IndicatorAxis.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var zrUtil = require('zrender/core/util'); 4 | var Axis = require('../Axis'); 5 | 6 | function IndicatorAxis(dim, scale, radiusExtent) { 7 | Axis.call(this, dim, scale, radiusExtent); 8 | 9 | /** 10 | * Axis type 11 | * - 'category' 12 | * - 'value' 13 | * - 'time' 14 | * - 'log' 15 | * @type {string} 16 | */ 17 | this.type = 'value'; 18 | 19 | this.angle = 0; 20 | 21 | /** 22 | * Indicator name 23 | * @type {string} 24 | */ 25 | this.name = ''; 26 | /** 27 | * @type {module:echarts/model/Model} 28 | */ 29 | this.model; 30 | } 31 | 32 | zrUtil.inherits(IndicatorAxis, Axis); 33 | 34 | return IndicatorAxis; 35 | }); -------------------------------------------------------------------------------- /echarts/src/coord/single/singleCreator.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Single coordinate system creator. 3 | */ 4 | define(function (require) { 5 | 6 | var Single = require('./Single'); 7 | 8 | /** 9 | * Create single coordinate system and inject it into seriesModel. 10 | * 11 | * @param {module:echarts/model/Global} ecModel 12 | * @param {module:echarts/ExtensionAPI} api 13 | * @return {Array.} 14 | */ 15 | function create(ecModel, api) { 16 | var singles = []; 17 | 18 | ecModel.eachComponent('singleAxis', function(axisModel, idx) { 19 | 20 | var single = new Single(axisModel, ecModel, api); 21 | single.name = 'single_' + idx; 22 | single.resize(axisModel, api); 23 | axisModel.coordinateSystem = single; 24 | singles.push(single); 25 | 26 | }); 27 | 28 | ecModel.eachSeries(function (seriesModel) { 29 | if (seriesModel.get('coordinateSystem') === 'singleAxis') { 30 | var singleAxisModel = ecModel.queryComponents({ 31 | mainType: 'singleAxis', 32 | index: seriesModel.get('singleAxisIndex'), 33 | id: seriesModel.get('singleAxisId') 34 | })[0]; 35 | seriesModel.coordinateSystem = singleAxisModel && singleAxisModel.coordinateSystem; 36 | } 37 | }); 38 | 39 | return singles; 40 | } 41 | 42 | require('../../CoordinateSystem').register('single', { 43 | create: create, 44 | dimensions: Single.prototype.dimensions 45 | }); 46 | }); -------------------------------------------------------------------------------- /echarts/src/layout/points.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | return function (seriesType, ecModel) { 4 | ecModel.eachSeriesByType(seriesType, function (seriesModel) { 5 | var data = seriesModel.getData(); 6 | var coordSys = seriesModel.coordinateSystem; 7 | 8 | if (coordSys) { 9 | var dims = coordSys.dimensions; 10 | 11 | if (coordSys.type === 'singleAxis') { 12 | data.each(dims[0], function (x, idx) { 13 | // Also {Array.}, not undefined to avoid if...else... statement 14 | data.setItemLayout(idx, isNaN(x) ? [NaN, NaN] : coordSys.dataToPoint(x)); 15 | }); 16 | } 17 | else { 18 | data.each(dims, function (x, y, idx) { 19 | // Also {Array.}, not undefined to avoid if...else... statement 20 | data.setItemLayout( 21 | idx, (isNaN(x) || isNaN(y)) ? [NaN, NaN] : coordSys.dataToPoint([x, y]) 22 | ); 23 | }, true); 24 | } 25 | } 26 | }); 27 | }; 28 | }); -------------------------------------------------------------------------------- /echarts/src/model/mixin/areaStyle.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | return { 3 | getAreaStyle: require('./makeStyleMapper')( 4 | [ 5 | ['fill', 'color'], 6 | ['shadowBlur'], 7 | ['shadowOffsetX'], 8 | ['shadowOffsetY'], 9 | ['opacity'], 10 | ['shadowColor'] 11 | ] 12 | ) 13 | }; 14 | }); -------------------------------------------------------------------------------- /echarts/src/model/mixin/boxLayout.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | return { 4 | getBoxLayoutParams: function () { 5 | return { 6 | left: this.get('left'), 7 | top: this.get('top'), 8 | right: this.get('right'), 9 | bottom: this.get('bottom'), 10 | width: this.get('width'), 11 | height: this.get('height') 12 | }; 13 | } 14 | }; 15 | }); -------------------------------------------------------------------------------- /echarts/src/model/mixin/colorPalette.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var classUtil = require('../../util/clazz'); 4 | var set = classUtil.set; 5 | var get = classUtil.get; 6 | 7 | return { 8 | clearColorPalette: function () { 9 | set(this, 'colorIdx', 0); 10 | set(this, 'colorNameMap', {}); 11 | }, 12 | 13 | getColorFromPalette: function (name, scope) { 14 | scope = scope || this; 15 | var colorIdx = get(scope, 'colorIdx') || 0; 16 | var colorNameMap = get(scope, 'colorNameMap') || set(scope, 'colorNameMap', {}); 17 | if (colorNameMap[name]) { 18 | return colorNameMap[name]; 19 | } 20 | var colorPalette = this.get('color', true) || []; 21 | if (!colorPalette.length) { 22 | return; 23 | } 24 | 25 | var color = colorPalette[colorIdx]; 26 | if (name) { 27 | colorNameMap[name] = color; 28 | } 29 | set(scope, 'colorIdx', (colorIdx + 1) % colorPalette.length); 30 | 31 | return color; 32 | } 33 | }; 34 | }); -------------------------------------------------------------------------------- /echarts/src/model/mixin/itemStyle.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | var getItemStyle = require('./makeStyleMapper')( 3 | [ 4 | ['fill', 'color'], 5 | ['stroke', 'borderColor'], 6 | ['lineWidth', 'borderWidth'], 7 | ['opacity'], 8 | ['shadowBlur'], 9 | ['shadowOffsetX'], 10 | ['shadowOffsetY'], 11 | ['shadowColor'], 12 | ['textPosition'], 13 | ['textAlign'] 14 | ] 15 | ); 16 | return { 17 | getItemStyle: function (excludes) { 18 | var style = getItemStyle.call(this, excludes); 19 | var lineDash = this.getBorderLineDash(); 20 | lineDash && (style.lineDash = lineDash); 21 | return style; 22 | }, 23 | 24 | getBorderLineDash: function () { 25 | var lineType = this.get('borderType'); 26 | return (lineType === 'solid' || lineType == null) ? null 27 | : (lineType === 'dashed' ? [5, 5] : [1, 1]); 28 | } 29 | }; 30 | }); -------------------------------------------------------------------------------- /echarts/src/model/mixin/lineStyle.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | var getLineStyle = require('./makeStyleMapper')( 3 | [ 4 | ['lineWidth', 'width'], 5 | ['stroke', 'color'], 6 | ['opacity'], 7 | ['shadowBlur'], 8 | ['shadowOffsetX'], 9 | ['shadowOffsetY'], 10 | ['shadowColor'] 11 | ] 12 | ); 13 | return { 14 | getLineStyle: function (excludes) { 15 | var style = getLineStyle.call(this, excludes); 16 | var lineDash = this.getLineDash(style.lineWidth); 17 | lineDash && (style.lineDash = lineDash); 18 | return style; 19 | }, 20 | 21 | getLineDash: function (lineWidth) { 22 | if (lineWidth == null) { 23 | lineWidth = 1; 24 | } 25 | var lineType = this.get('type'); 26 | var dotSize = Math.max(lineWidth, 2); 27 | var dashSize = lineWidth * 4; 28 | return (lineType === 'solid' || lineType == null) ? null 29 | : (lineType === 'dashed' ? [dashSize, dashSize] : [dotSize, dotSize]); 30 | } 31 | }; 32 | }); -------------------------------------------------------------------------------- /echarts/src/model/mixin/makeStyleMapper.js: -------------------------------------------------------------------------------- 1 | // TODO Parse shadow style 2 | // TODO Only shallow path support 3 | define(function (require) { 4 | var zrUtil = require('zrender/core/util'); 5 | 6 | return function (properties) { 7 | // Normalize 8 | for (var i = 0; i < properties.length; i++) { 9 | if (!properties[i][1]) { 10 | properties[i][1] = properties[i][0]; 11 | } 12 | } 13 | return function (excludes) { 14 | var style = {}; 15 | for (var i = 0; i < properties.length; i++) { 16 | var propName = properties[i][1]; 17 | if (excludes && zrUtil.indexOf(excludes, propName) >= 0) { 18 | continue; 19 | } 20 | var val = this.getShallow(propName); 21 | if (val != null) { 22 | style[properties[i][0]] = val; 23 | } 24 | } 25 | return style; 26 | }; 27 | }; 28 | }); -------------------------------------------------------------------------------- /echarts/src/model/mixin/textStyle.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var textContain = require('zrender/contain/text'); 4 | 5 | function getShallow(model, path) { 6 | return model && model.getShallow(path); 7 | } 8 | 9 | return { 10 | /** 11 | * Get color property or get color from option.textStyle.color 12 | * @return {string} 13 | */ 14 | getTextColor: function () { 15 | var ecModel = this.ecModel; 16 | return this.getShallow('color') 17 | || (ecModel && ecModel.get('textStyle.color')); 18 | }, 19 | 20 | /** 21 | * Create font string from fontStyle, fontWeight, fontSize, fontFamily 22 | * @return {string} 23 | */ 24 | getFont: function () { 25 | var ecModel = this.ecModel; 26 | var gTextStyleModel = ecModel && ecModel.getModel('textStyle'); 27 | return [ 28 | // FIXME in node-canvas fontWeight is before fontStyle 29 | this.getShallow('fontStyle') || getShallow(gTextStyleModel, 'fontStyle'), 30 | this.getShallow('fontWeight') || getShallow(gTextStyleModel, 'fontWeight'), 31 | (this.getShallow('fontSize') || getShallow(gTextStyleModel, 'fontSize') || 12) + 'px', 32 | this.getShallow('fontFamily') || getShallow(gTextStyleModel, 'fontFamily') || 'sans-serif' 33 | ].join(' '); 34 | }, 35 | 36 | getTextRect: function (text) { 37 | return textContain.getBoundingRect( 38 | text, 39 | this.getFont(), 40 | this.getShallow('align'), 41 | this.getShallow('baseline') 42 | ); 43 | }, 44 | 45 | truncateText: function (text, containerWidth, ellipsis, options) { 46 | return textContain.truncateText( 47 | text, containerWidth, this.getFont(), ellipsis, options 48 | ); 49 | } 50 | }; 51 | }); -------------------------------------------------------------------------------- /echarts/src/processor/dataFilter.js: -------------------------------------------------------------------------------- 1 | define(function () { 2 | return function (seriesType, ecModel) { 3 | var legendModels = ecModel.findComponents({ 4 | mainType: 'legend' 5 | }); 6 | if (!legendModels || !legendModels.length) { 7 | return; 8 | } 9 | ecModel.eachSeriesByType(seriesType, function (series) { 10 | var data = series.getData(); 11 | data.filterSelf(function (idx) { 12 | var name = data.getName(idx); 13 | // If in any legend component the status is not selected. 14 | for (var i = 0; i < legendModels.length; i++) { 15 | if (!legendModels[i].isSelected(name)) { 16 | return false; 17 | } 18 | } 19 | return true; 20 | }, this); 21 | }, this); 22 | }; 23 | }); -------------------------------------------------------------------------------- /echarts/src/view/Component.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var Group = require('zrender/container/Group'); 4 | var componentUtil = require('../util/component'); 5 | var clazzUtil = require('../util/clazz'); 6 | 7 | var Component = function () { 8 | /** 9 | * @type {module:zrender/container/Group} 10 | * @readOnly 11 | */ 12 | this.group = new Group(); 13 | 14 | /** 15 | * @type {string} 16 | * @readOnly 17 | */ 18 | this.uid = componentUtil.getUID('viewComponent'); 19 | }; 20 | 21 | Component.prototype = { 22 | 23 | constructor: Component, 24 | 25 | init: function (ecModel, api) {}, 26 | 27 | render: function (componentModel, ecModel, api, payload) {}, 28 | 29 | dispose: function () {} 30 | 31 | }; 32 | 33 | var componentProto = Component.prototype; 34 | componentProto.updateView 35 | = componentProto.updateLayout 36 | = componentProto.updateVisual 37 | = function (seriesModel, ecModel, api, payload) { 38 | // Do nothing; 39 | }; 40 | // Enable Component.extend. 41 | clazzUtil.enableClassExtend(Component); 42 | 43 | // Enable capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. 44 | clazzUtil.enableClassManagement(Component, {registerWhenExtend: true}); 45 | 46 | return Component; 47 | }); -------------------------------------------------------------------------------- /echarts/src/visual/seriesColor.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | var Gradient = require('zrender/graphic/Gradient'); 3 | return function (ecModel) { 4 | function encodeColor(seriesModel) { 5 | var colorAccessPath = (seriesModel.visualColorAccessPath || 'itemStyle.normal.color').split('.'); 6 | var data = seriesModel.getData(); 7 | var color = seriesModel.get(colorAccessPath) // Set in itemStyle 8 | || seriesModel.getColorFromPalette(seriesModel.get('name')); // Default color 9 | 10 | // FIXME Set color function or use the platte color 11 | data.setVisual('color', color); 12 | 13 | // Only visible series has each data be visual encoded 14 | if (!ecModel.isSeriesFiltered(seriesModel)) { 15 | if (typeof color === 'function' && !(color instanceof Gradient)) { 16 | data.each(function (idx) { 17 | data.setItemVisual( 18 | idx, 'color', color(seriesModel.getDataParams(idx)) 19 | ); 20 | }); 21 | } 22 | 23 | // itemStyle in each data item 24 | data.each(function (idx) { 25 | var itemModel = data.getItemModel(idx); 26 | var color = itemModel.get(colorAccessPath, true); 27 | if (color != null) { 28 | data.setItemVisual(idx, 'color', color); 29 | } 30 | }); 31 | } 32 | } 33 | ecModel.eachRawSeries(encodeColor); 34 | }; 35 | }); -------------------------------------------------------------------------------- /echarts/src/visual/visualDefault.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Visual mapping. 3 | */ 4 | define(function (require) { 5 | 6 | var zrUtil = require('zrender/core/util'); 7 | 8 | var visualDefault = { 9 | 10 | /** 11 | * @public 12 | */ 13 | get: function (visualType, key, isCategory) { 14 | var value = zrUtil.clone( 15 | (defaultOption[visualType] || {})[key] 16 | ); 17 | 18 | return isCategory 19 | ? (zrUtil.isArray(value) ? value[value.length - 1] : value) 20 | : value; 21 | } 22 | 23 | }; 24 | 25 | var defaultOption = { 26 | 27 | color: { 28 | active: ['#006edd', '#e0ffff'], 29 | inactive: ['rgba(0,0,0,0)'] 30 | }, 31 | 32 | colorHue: { 33 | active: [0, 360], 34 | inactive: [0, 0] 35 | }, 36 | 37 | colorSaturation: { 38 | active: [0.3, 1], 39 | inactive: [0, 0] 40 | }, 41 | 42 | colorLightness: { 43 | active: [0.9, 0.5], 44 | inactive: [0, 0] 45 | }, 46 | 47 | colorAlpha: { 48 | active: [0.3, 1], 49 | inactive: [0, 0] 50 | }, 51 | 52 | opacity: { 53 | active: [0.3, 1], 54 | inactive: [0, 0] 55 | }, 56 | 57 | symbol: { 58 | active: ['circle', 'roundRect', 'diamond'], 59 | inactive: ['none'] 60 | }, 61 | 62 | symbolSize: { 63 | active: [10, 50], 64 | inactive: [0, 0] 65 | } 66 | }; 67 | 68 | return visualDefault; 69 | 70 | }); 71 | -------------------------------------------------------------------------------- /echarts/test/-primary-cases.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |

Necessary cases for quick test.

10 |
11 |
12 | 13 | 50 | 51 | -------------------------------------------------------------------------------- /echarts/test/README.md: -------------------------------------------------------------------------------- 1 | # Test Guide 2 | 3 | 4 | 5 | ## Functional Test 6 | 7 | Open `./*.html` files in Web Browsers. 8 | 9 | 10 | 11 | ## Unit Test 12 | 13 | ### Rendering-relevant 14 | 15 | Our test strategy is to compare the rendered canvas of current version with last release version. The comparison can either based on the *content* of rendered canvas, or the *stack* of canvas operations. 16 | 17 | When a test case fails, it doesn't necessary to be a bug since the rendering method may be changed intentionally in a commit. So in this case, we output the rendering result of both versions and the diff result. 18 | 19 | Make sure `../dist/echarts.js` is the built based on current source files by: 20 | 21 | ```bash 22 | cd ../build 23 | npm install 24 | bash build.sh 25 | ``` 26 | 27 | By default, we compare current version with last release version. To run the test, you should first download last release using: 28 | 29 | ```bash 30 | cd ../test/ut 31 | ./configure 32 | ``` 33 | 34 | which will download `echart.js` of last release into `./ut/tmp/oldEcharts.js`. 35 | 36 | Then, open `./ut/ui.html` in Web Browsers. 37 | 38 | #### Compare current with a specific release 39 | 40 | If one argument is passed, we take it as the hash code of a release and compare current version with `/dist/echarts.js` of the that version. 41 | 42 | ```bash 43 | # this compares current `/dist/echarts.js` with that of v3.1.6 44 | ./configure 3724a16 45 | ``` 46 | 47 | #### Compare arbitrary two commits 48 | 49 | Since `/dist/echarts.js` is only the build result of release versions, to compare arbitrary versions, you need to checkout specific commits and build the source files. Put the build results as `./tmp/oldEcharts.js` and `./tmp/newEcharts.js` will work. 50 | 51 | 52 | 53 | ### Rendering-irrelevant 54 | 55 | Open `./ut.html` files in Web Browsers. 56 | -------------------------------------------------------------------------------- /echarts/test/config.js: -------------------------------------------------------------------------------- 1 | require.config({ 2 | paths: { 3 | 'geoJson': '../geoData/geoJson', 4 | 'theme': '../theme', 5 | 'data': './data', 6 | 'map': '../map', 7 | 'extension': '../extension' 8 | }, 9 | packages: [ 10 | { 11 | main: 'echarts', 12 | location: '../src', 13 | name: 'echarts' 14 | }, 15 | { 16 | main: 'zrender', 17 | location: '../../zrender/src', 18 | name: 'zrender' 19 | } 20 | ] 21 | // urlArgs: '_v_=' + +new Date() 22 | }); -------------------------------------------------------------------------------- /echarts/test/data/Michelson-Morley.json.js: -------------------------------------------------------------------------------- 1 | // five experiments. 2 | // each experiments has 20 runs. 3 | // speed(km/s minus 299,000) 4 | define([ 5 | [850, 740, 900, 1070, 930, 850, 950, 980, 980, 880, 1000, 980, 930, 650, 760, 810, 1000, 1000, 960, 960], 6 | [960, 940, 960, 940, 880, 800, 850, 880, 900, 840, 830, 790, 810, 880, 880, 830, 800, 790, 760, 800], 7 | [880, 880, 880, 860, 720, 720, 620, 860, 970, 950, 880, 910, 850, 870, 840, 840, 850, 840, 840, 840], 8 | [890, 810, 810, 820, 800, 770, 760, 740, 750, 760, 910, 920, 890, 860, 880, 720, 840, 850, 850, 780], 9 | [890, 840, 780, 810, 760, 810, 790, 810, 820, 850, 870, 870, 810, 740, 810, 940, 950, 800, 810, 870] 10 | ]); -------------------------------------------------------------------------------- /echarts/test/data/aqi/BJdata.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | [1,55,9,56,0.46,18,6,"良"], 3 | [2,25,11,21,0.65,34,9,"优"], 4 | [3,56,7,63,0.3,14,5,"良"], 5 | [4,33,7,29,0.33,16,6,"优"], 6 | [5,42,24,44,0.76,40,16,"优"], 7 | [6,82,58,90,1.77,68,33,"良"], 8 | [7,74,49,77,1.46,48,27,"良"], 9 | [8,78,55,80,1.29,59,29,"良"], 10 | [9,267,216,280,'-',108,64,"重度污染"], 11 | [10,185,127,216,2.52,61,27,"中度污染"], 12 | [11,39,19,38,0.57,31,15,"优"], 13 | [12,41,11,40,0.43,21,7,"优"], 14 | [13,64,38,74,1.04,46,22,"良"], 15 | [14,108,79,120,1.7,75,41,"轻度污染"], 16 | [15,108,63,116,1.48,44,26,"轻度污染"], 17 | [16,33,6,29,0.34,13,5,"优"], 18 | [17,94,66,110,1.54,62,31,"良"], 19 | [18,186,142,192,3.88,93,79,"中度污染"], 20 | [19,57,31,54,0.96,32,14,"良"], 21 | [20,22,8,17,0.48,23,10,"优"], 22 | [21,39,15,36,0.61,29,13,"优"], 23 | [22,94,69,114,2.08,73,39,"良"], 24 | [23,99,73,110,2.43,76,48,"良"], 25 | [24,31,12,30,0.5,32,16,"优"], 26 | [25,42,27,43,1,53,22,"优"], 27 | [26,154,117,157,3.05,92,58,"中度污染"], 28 | [27,234,185,230,4.09,123,69,"重度污染"], 29 | [28,160,120,186,2.77,91,50,"中度污染"], 30 | [29,134,96,165,2.76,83,41,"轻度污染"], 31 | [30,52,24,60,1.03,50,21,"良"], 32 | [31,46,5,49,0.28,10,6,"优"] 33 | ]); -------------------------------------------------------------------------------- /echarts/test/data/aqi/GZdata.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | [1,26,37,27,1.163,27,13,"优"], 3 | [2,85,62,71,1.195,60,8,"良"], 4 | [3,78,38,74,1.363,37,7,"良"], 5 | [4,21,21,36,0.634,40,9,"优"], 6 | [5,41,42,46,0.915,81,13,"优"], 7 | [6,56,52,69,1.067,92,16,"良"], 8 | [7,64,30,28,0.924,51,2,"良"], 9 | [8,55,48,74,1.236,75,26,"良"], 10 | [9,76,85,113,1.237,114,27,"良"], 11 | [10,91,81,104,1.041,56,40,"良"], 12 | [11,84,39,60,0.964,25,11,"良"], 13 | [12,64,51,101,0.862,58,23,"良"], 14 | [13,70,69,120,1.198,65,36,"良"], 15 | [14,77,105,178,2.549,64,16,"良"], 16 | [15,109,68,87,0.996,74,29,"轻度污染"], 17 | [16,73,68,97,0.905,51,34,"良"], 18 | [17,54,27,47,0.592,53,12,"良"], 19 | [18,51,61,97,0.811,65,19,"良"], 20 | [19,91,71,121,1.374,43,18,"良"], 21 | [20,73,102,182,2.787,44,19,"良"], 22 | [21,73,50,76,0.717,31,20,"良"], 23 | [22,84,94,140,2.238,68,18,"良"], 24 | [23,93,77,104,1.165,53,7,"良"], 25 | [24,99,130,227,3.97,55,15,"良"], 26 | [25,146,84,139,1.094,40,17,"轻度污染"], 27 | [26,113,108,137,1.481,48,15,"轻度污染"], 28 | [27,81,48,62,1.619,26,3,"良"], 29 | [28,56,48,68,1.336,37,9,"良"], 30 | [29,82,92,174,3.29,0,13,"良"], 31 | [30,106,116,188,3.628,101,16,"轻度污染"], 32 | [31,118,50,0,1.383,76,11,"轻度污染"] 33 | ] 34 | ); -------------------------------------------------------------------------------- /echarts/test/data/aqi/SHdata.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | [1,91,45,125,0.82,34,23,"良"], 3 | [2,65,27,78,0.86,45,29,"良"], 4 | [3,83,60,84,1.09,73,27,"良"], 5 | [4,109,81,121,1.28,68,51,"轻度污染"], 6 | [5,106,77,114,1.07,55,51,"轻度污染"], 7 | [6,109,81,121,1.28,68,51,"轻度污染"], 8 | [7,106,77,114,1.07,55,51,"轻度污染"], 9 | [8,89,65,78,0.86,51,26,"良"], 10 | [9,53,33,47,0.64,50,17,"良"], 11 | [10,80,55,80,1.01,75,24,"良"], 12 | [11,117,81,124,1.03,45,24,"轻度污染"], 13 | [12,99,71,142,1.1,62,42,"良"], 14 | [13,95,69,130,1.28,74,50,"良"], 15 | [14,116,87,131,1.47,84,40,"轻度污染"], 16 | [15,108,80,121,1.3,85,37,"轻度污染"], 17 | [16,134,83,167,1.16,57,43,"轻度污染"], 18 | [17,79,43,107,1.05,59,37,"良"], 19 | [18,71,46,89,0.86,64,25,"良"], 20 | [19,97,71,113,1.17,88,31,"良"], 21 | [20,84,57,91,0.85,55,31,"良"], 22 | [21,87,63,101,0.9,56,41,"良"], 23 | [22,104,77,119,1.09,73,48,"轻度污染"], 24 | [23,87,62,100,1,72,28,"良"], 25 | [24,168,128,172,1.49,97,56,"中度污染"], 26 | [25,65,45,51,0.74,39,17,"良"], 27 | [26,39,24,38,0.61,47,17,"优"], 28 | [27,39,24,39,0.59,50,19,"优"], 29 | [28,93,68,96,1.05,79,29,"良"], 30 | [29,188,143,197,1.66,99,51,"中度污染"], 31 | [30,174,131,174,1.55,108,50,"中度污染"], 32 | [31,187,143,201,1.39,89,53,"中度污染"] 33 | ] 34 | ); -------------------------------------------------------------------------------- /echarts/test/data/aqi/processAQI.js: -------------------------------------------------------------------------------- 1 | function processAQI(arr) { 2 | for (var i = 0; i < arr.length; i++) { 3 | var line = arr[i]; 4 | var aqi = line[1]; 5 | 6 | if (aqi <= 50) { 7 | line[7] = '"优"'; 8 | } 9 | else if (aqi <= 100) { 10 | line[7] = '"良"'; 11 | } 12 | else if (aqi <= 150) { 13 | line[7] = '"轻度污染"'; 14 | } 15 | else if (aqi <= 200) { 16 | line[7] = '"中度污染"'; 17 | } 18 | else if (aqi <= 300) { 19 | line[7] = '"重度污染"'; 20 | } 21 | else { 22 | line[7] = '"严重污染"'; 23 | } 24 | } 25 | 26 | console.log(arr.join('],\n [')); 27 | } -------------------------------------------------------------------------------- /echarts/test/loading.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 19 |
20 | 33 | 34 | -------------------------------------------------------------------------------- /echarts/test/reset.css: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | #main, 4 | body > .main { 5 | width: 100%; 6 | height: 100%; 7 | margin: 0; 8 | padding: 0; 9 | font-family: arial; 10 | } 11 | -------------------------------------------------------------------------------- /echarts/test/scale-integer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 15 |
16 | 45 | 46 | -------------------------------------------------------------------------------- /echarts/test/ut/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "bitwise": false, 3 | "camelcase": true, 4 | "curly": true, 5 | "es3": true, 6 | "eqeqeq": true, 7 | "forin": true, 8 | "freeze": true, 9 | "immed": true, 10 | "latedef": "nofunc", 11 | "newcap": true, 12 | "noarg": true, 13 | "noempty": true, 14 | "nonbsp": true, 15 | "nonew": true, 16 | "plusplus": false, 17 | "quotmark": "single", 18 | "undef": true, 19 | "predef": ["define", "require", "describe", "expect", "beforeEach", "it"], 20 | "unused": "vars", 21 | "strict": false, 22 | "maxparams": 20, 23 | "maxdepth": 6, 24 | "maxlen": 120, 25 | 26 | "asi": false, 27 | "boss": true, 28 | "debug": false, 29 | "eqnull": true, 30 | "esnext": false, 31 | "evil": false, 32 | "expr": true, 33 | "funcscope": false, 34 | "globalstrict": false, 35 | "iterator": false, 36 | "lastsemic": false, 37 | "laxbreak": true, 38 | "laxcomma": false, 39 | "loopfunc": false, 40 | "multistr": false, 41 | "notypeof": false, 42 | "proto": false, 43 | "scripturl": false, 44 | "shadow": true, 45 | "sub": true, 46 | "supernew": false, 47 | "validthis": true, 48 | 49 | "browser": true, 50 | "jasmine": true, 51 | "couch": false, 52 | "devel": true, 53 | "dojo": false, 54 | "jquery": false, 55 | "mootools": false, 56 | "node": true, 57 | "nonstandard": true, 58 | "prototypejs": false, 59 | "rhino": false, 60 | "wsh": true 61 | } 62 | -------------------------------------------------------------------------------- /echarts/test/ut/MIT.LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2014 Pivotal Labs 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /echarts/test/ut/config.js: -------------------------------------------------------------------------------- 1 | require.config({ 2 | baseUrl: '../', 3 | paths: { 4 | 'geoJson': '../geoData/geoJson', 5 | 'theme': '../theme', 6 | 'data': './data', 7 | 'map': '../map', 8 | 'extension': '../extension' 9 | }, 10 | packages: [ 11 | { 12 | main: 'echarts', 13 | location: '../src', 14 | name: 'echarts' 15 | }, 16 | { 17 | main: 'zrender', 18 | location: '../../zrender/src', 19 | name: 'zrender' 20 | } 21 | ] 22 | // urlArgs: '_v_=' + +new Date() 23 | }); -------------------------------------------------------------------------------- /echarts/test/ut/configure: -------------------------------------------------------------------------------- 1 | if [ "$#" -eq 1 ]; then 2 | # use specific version 3 | old=$1 4 | else 5 | # use last release 6 | old=$(git rev-list --tags --max-count=1) 7 | fi 8 | mkdir -p tmp 9 | cp ../../dist/echarts.js "tmp/newEcharts.js" 10 | git show $old:dist/echarts.js > 'tmp/oldEcharts.js' 11 | -------------------------------------------------------------------------------- /echarts/test/ut/lib/jasmine-2.3.4/jasmine_favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrysmt/echarts3/2079e13fcbfb249b7d929732c8c6dbd7b47dfde1/echarts/test/ut/lib/jasmine-2.3.4/jasmine_favicon.png -------------------------------------------------------------------------------- /echarts/test/ut/spec/scale/interval.js: -------------------------------------------------------------------------------- 1 | describe('scale_interval', function() { 2 | 3 | var utHelper = window.utHelper; 4 | 5 | var testCase = utHelper.prepare([ 6 | 'echarts/component/grid', 7 | 'echarts/chart/line' 8 | ]); 9 | 10 | testCase.createChart()('ticks', function () { 11 | var min = 0; 12 | var max = 54.090909; 13 | var splitNumber = 5; 14 | 15 | this.chart.setOption({ 16 | xAxis: {}, 17 | yAxis: { 18 | type: 'value', 19 | min: min, 20 | max: max, 21 | interval: max / splitNumber, 22 | splitNumber: splitNumber 23 | }, 24 | series: [{type: 'line', data: []}] 25 | }); 26 | 27 | var yAxis = this.chart.getModel().getComponent('yAxis', 0); 28 | var scale = yAxis.axis.scale; 29 | var ticks = scale.getTicks(); 30 | 31 | expect(ticks[0]).toEqual(min); 32 | expect(ticks[ticks.length - 1]).toEqual(max); 33 | }); 34 | 35 | }); -------------------------------------------------------------------------------- /echarts/test/ut/spec/ui/config.js: -------------------------------------------------------------------------------- 1 | require.config({ 2 | paths: { 3 | 'oldEcharts': 'tmp/oldEcharts', 4 | 'newEcharts': '../../dist/echarts' 5 | } 6 | }); 7 | -------------------------------------------------------------------------------- /echarts/test/ut/ui.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Jasmine Spec Runner v2.3.4 6 | 7 | 8 | 9 | 10 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /echarts/test/ut/ut.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Jasmine Spec Runner v2.3.4 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /echarts/test/ut/ut.js: -------------------------------------------------------------------------------- 1 | document.write(' 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /zrender/src/animation/requestAnimationFrame.js: -------------------------------------------------------------------------------- 1 | define(function(require) { 2 | 3 | return (typeof window !== 'undefined' && 4 | (window.requestAnimationFrame 5 | || window.msRequestAnimationFrame 6 | || window.mozRequestAnimationFrame 7 | || window.webkitRequestAnimationFrame)) 8 | || function (func) { 9 | setTimeout(func, 16); 10 | }; 11 | }); 12 | -------------------------------------------------------------------------------- /zrender/src/config.js: -------------------------------------------------------------------------------- 1 | define(function () { 2 | var dpr = 1; 3 | // If in browser environment 4 | if (typeof window !== 'undefined') { 5 | dpr = Math.max(window.devicePixelRatio || 1, 1); 6 | } 7 | /** 8 | * config默认配置项 9 | * @exports zrender/config 10 | * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) 11 | */ 12 | var config = { 13 | /** 14 | * debug日志选项:catchBrushException为true下有效 15 | * 0 : 不生成debug数据,发布用 16 | * 1 : 异常抛出,调试用 17 | * 2 : 控制台输出,调试用 18 | */ 19 | debugMode: 2,//默认为0 20 | 21 | // retina 屏幕优化 22 | devicePixelRatio: dpr 23 | }; 24 | return config; 25 | }); 26 | 27 | -------------------------------------------------------------------------------- /zrender/src/contain/arc.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var normalizeRadian = require('./util').normalizeRadian; 4 | var PI2 = Math.PI * 2; 5 | 6 | return { 7 | /** 8 | * 圆弧描边包含判断 9 | * @param {number} cx 10 | * @param {number} cy 11 | * @param {number} r 12 | * @param {number} startAngle 13 | * @param {number} endAngle 14 | * @param {boolean} anticlockwise 15 | * @param {number} lineWidth 16 | * @param {number} x 17 | * @param {number} y 18 | * @return {Boolean} 19 | */ 20 | containStroke: function ( 21 | cx, cy, r, startAngle, endAngle, anticlockwise, 22 | lineWidth, x, y 23 | ) { 24 | 25 | if (lineWidth === 0) { 26 | return false; 27 | } 28 | var _l = lineWidth; 29 | 30 | x -= cx; 31 | y -= cy; 32 | var d = Math.sqrt(x * x + y * y); 33 | 34 | if ((d - _l > r) || (d + _l < r)) { 35 | return false; 36 | } 37 | if (Math.abs(startAngle - endAngle) % PI2 < 1e-4) { 38 | // Is a circle 39 | return true; 40 | } 41 | if (anticlockwise) { 42 | var tmp = startAngle; 43 | startAngle = normalizeRadian(endAngle); 44 | endAngle = normalizeRadian(tmp); 45 | } else { 46 | startAngle = normalizeRadian(startAngle); 47 | endAngle = normalizeRadian(endAngle); 48 | } 49 | if (startAngle > endAngle) { 50 | endAngle += PI2; 51 | } 52 | 53 | var angle = Math.atan2(y, x); 54 | if (angle < 0) { 55 | angle += PI2; 56 | } 57 | return (angle >= startAngle && angle <= endAngle) 58 | || (angle + PI2 >= startAngle && angle + PI2 <= endAngle); 59 | } 60 | }; 61 | }); -------------------------------------------------------------------------------- /zrender/src/contain/cubic.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var curve = require('../core/curve'); 4 | 5 | return { 6 | /** 7 | * 三次贝塞尔曲线描边包含判断 8 | * @param {number} x0 9 | * @param {number} y0 10 | * @param {number} x1 11 | * @param {number} y1 12 | * @param {number} x2 13 | * @param {number} y2 14 | * @param {number} x3 15 | * @param {number} y3 16 | * @param {number} lineWidth 17 | * @param {number} x 18 | * @param {number} y 19 | * @return {boolean} 20 | */ 21 | containStroke: function(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) { 22 | if (lineWidth === 0) { 23 | return false; 24 | } 25 | var _l = lineWidth; 26 | // Quick reject 27 | if ( 28 | (y > y0 + _l && y > y1 + _l && y > y2 + _l && y > y3 + _l) 29 | || (y < y0 - _l && y < y1 - _l && y < y2 - _l && y < y3 - _l) 30 | || (x > x0 + _l && x > x1 + _l && x > x2 + _l && x > x3 + _l) 31 | || (x < x0 - _l && x < x1 - _l && x < x2 - _l && x < x3 - _l) 32 | ) { 33 | return false; 34 | } 35 | var d = curve.cubicProjectPoint( 36 | x0, y0, x1, y1, x2, y2, x3, y3, 37 | x, y, null 38 | ); 39 | return d <= _l / 2; 40 | } 41 | }; 42 | }); -------------------------------------------------------------------------------- /zrender/src/contain/line.js: -------------------------------------------------------------------------------- 1 | define(function () { 2 | return { 3 | /** 4 | * 线段包含判断 5 | * @param {number} x0 6 | * @param {number} y0 7 | * @param {number} x1 8 | * @param {number} y1 9 | * @param {number} lineWidth 10 | * @param {number} x 11 | * @param {number} y 12 | * @return {boolean} 13 | */ 14 | containStroke: function (x0, y0, x1, y1, lineWidth, x, y) { 15 | if (lineWidth === 0) { 16 | return false; 17 | } 18 | var _l = lineWidth; 19 | var _a = 0; 20 | var _b = x0; 21 | // Quick reject 22 | if ( 23 | (y > y0 + _l && y > y1 + _l) 24 | || (y < y0 - _l && y < y1 - _l) 25 | || (x > x0 + _l && x > x1 + _l) 26 | || (x < x0 - _l && x < x1 - _l) 27 | ) { 28 | return false; 29 | } 30 | 31 | if (x0 !== x1) { 32 | _a = (y0 - y1) / (x0 - x1); 33 | _b = (x0 * y1 - x1 * y0) / (x0 - x1) ; 34 | } 35 | else { 36 | return Math.abs(x - x0) <= _l / 2; 37 | } 38 | var tmp = _a * x - y + _b; 39 | var _s = tmp * tmp / (_a * _a + 1); 40 | return _s <= _l / 2 * _l / 2; 41 | } 42 | }; 43 | }); -------------------------------------------------------------------------------- /zrender/src/contain/polygon.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var windingLine = require('./windingLine'); 4 | 5 | var EPSILON = 1e-8; 6 | 7 | function isAroundEqual(a, b) { 8 | return Math.abs(a - b) < EPSILON; 9 | } 10 | 11 | function contain(points, x, y) { 12 | var w = 0; 13 | var p = points[0]; 14 | 15 | if (!p) { 16 | return false; 17 | } 18 | 19 | for (var i = 1; i < points.length; i++) { 20 | var p2 = points[i]; 21 | w += windingLine(p[0], p[1], p2[0], p2[1], x, y); 22 | p = p2; 23 | } 24 | 25 | // Close polygon 26 | var p0 = points[0]; 27 | if (!isAroundEqual(p[0], p0[0]) || !isAroundEqual(p[1], p0[1])) { 28 | w += windingLine(p[0], p[1], p0[0], p0[1], x, y); 29 | } 30 | 31 | return w !== 0; 32 | } 33 | 34 | 35 | return { 36 | contain: contain 37 | }; 38 | }); -------------------------------------------------------------------------------- /zrender/src/contain/quadratic.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var curve = require('../core/curve'); 4 | 5 | return { 6 | /** 7 | * 二次贝塞尔曲线描边包含判断 8 | * @param {number} x0 9 | * @param {number} y0 10 | * @param {number} x1 11 | * @param {number} y1 12 | * @param {number} x2 13 | * @param {number} y2 14 | * @param {number} lineWidth 15 | * @param {number} x 16 | * @param {number} y 17 | * @return {boolean} 18 | */ 19 | containStroke: function (x0, y0, x1, y1, x2, y2, lineWidth, x, y) { 20 | if (lineWidth === 0) { 21 | return false; 22 | } 23 | var _l = lineWidth; 24 | // Quick reject 25 | if ( 26 | (y > y0 + _l && y > y1 + _l && y > y2 + _l) 27 | || (y < y0 - _l && y < y1 - _l && y < y2 - _l) 28 | || (x > x0 + _l && x > x1 + _l && x > x2 + _l) 29 | || (x < x0 - _l && x < x1 - _l && x < x2 - _l) 30 | ) { 31 | return false; 32 | } 33 | var d = curve.quadraticProjectPoint( 34 | x0, y0, x1, y1, x2, y2, 35 | x, y, null 36 | ); 37 | return d <= _l / 2; 38 | } 39 | }; 40 | }); -------------------------------------------------------------------------------- /zrender/src/contain/util.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var PI2 = Math.PI * 2; 4 | return { 5 | normalizeRadian: function(angle) { 6 | angle %= PI2; 7 | if (angle < 0) { 8 | angle += PI2; 9 | } 10 | return angle; 11 | } 12 | }; 13 | }); -------------------------------------------------------------------------------- /zrender/src/contain/windingLine.js: -------------------------------------------------------------------------------- 1 | define(function () { 2 | return function windingLine(x0, y0, x1, y1, x, y) { 3 | if ((y > y0 && y > y1) || (y < y0 && y < y1)) { 4 | return 0; 5 | } 6 | // Ignore horizontal line 7 | if (y1 === y0) { 8 | return 0; 9 | } 10 | var dir = y1 < y0 ? 1 : -1; 11 | var t = (y - y0) / (y1 - y0); 12 | 13 | // Avoid winding error when intersection point is the connect point of two line of polygon 14 | if (t === 1 || t === 0) { 15 | dir = y1 < y0 ? 0.5 : -0.5; 16 | } 17 | 18 | var x_ = t * (x1 - x0) + x0; 19 | 20 | return x_ > x ? dir : 0; 21 | }; 22 | }); -------------------------------------------------------------------------------- /zrender/src/core/guid.js: -------------------------------------------------------------------------------- 1 | /** 2 | * zrender: 生成唯一id 3 | * 4 | * @author errorrik (errorrik@gmail.com) 5 | */ 6 | 7 | define(function() { 8 | var idStart = 0x0907; 9 | 10 | return function () { 11 | return idStart++; 12 | }; 13 | }); 14 | -------------------------------------------------------------------------------- /zrender/src/core/log.js: -------------------------------------------------------------------------------- 1 | define( 2 | function (require) { 3 | var config = require('../config'); 4 | 5 | /** 6 | * @exports zrender/tool/log 7 | * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) 8 | */ 9 | return function() { 10 | if (config.debugMode === 0) { 11 | return; 12 | } 13 | else if (config.debugMode == 1) { 14 | for (var k in arguments) { 15 | throw new Error(arguments[k]); 16 | } 17 | } 18 | else if (config.debugMode > 1) { 19 | for (var k in arguments) { 20 | console.log(arguments[k]); 21 | } 22 | } 23 | }; 24 | 25 | /* for debug 26 | return function(mes) { 27 | document.getElementById('wrong-message').innerHTML = 28 | mes + ' ' + (new Date() - 0) 29 | + '
' 30 | + document.getElementById('wrong-message').innerHTML; 31 | }; 32 | */ 33 | } 34 | ); 35 | -------------------------------------------------------------------------------- /zrender/src/graphic/CompoundPath.js: -------------------------------------------------------------------------------- 1 | // CompoundPath to improve performance 2 | define(function (require) { 3 | 4 | var Path = require('./Path'); 5 | return Path.extend({ 6 | 7 | type: 'compound', 8 | 9 | shape: { 10 | 11 | paths: null 12 | }, 13 | 14 | _updatePathDirty: function () { 15 | var dirtyPath = this.__dirtyPath; 16 | var paths = this.shape.paths; 17 | for (var i = 0; i < paths.length; i++) { 18 | // Mark as dirty if any subpath is dirty 19 | dirtyPath = dirtyPath || paths[i].__dirtyPath; 20 | } 21 | this.__dirtyPath = dirtyPath; 22 | this.__dirty = this.__dirty || dirtyPath; 23 | }, 24 | 25 | beforeBrush: function () { 26 | this._updatePathDirty(); 27 | var paths = this.shape.paths || []; 28 | var scale = this.getGlobalScale(); 29 | // Update path scale 30 | for (var i = 0; i < paths.length; i++) { 31 | paths[i].path.setScale(scale[0], scale[1]); 32 | } 33 | }, 34 | 35 | buildPath: function (ctx, shape) { 36 | var paths = shape.paths || []; 37 | for (var i = 0; i < paths.length; i++) { 38 | paths[i].buildPath(ctx, paths[i].shape, true); 39 | } 40 | }, 41 | 42 | afterBrush: function () { 43 | var paths = this.shape.paths; 44 | for (var i = 0; i < paths.length; i++) { 45 | paths[i].__dirtyPath = false; 46 | } 47 | }, 48 | 49 | getBoundingRect: function () { 50 | this._updatePathDirty(); 51 | return Path.prototype.getBoundingRect.call(this); 52 | } 53 | }); 54 | }); -------------------------------------------------------------------------------- /zrender/src/graphic/Gradient.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | /** 4 | * @param {Array.} colorStops 5 | */ 6 | var Gradient = function (colorStops) { 7 | 8 | this.colorStops = colorStops || []; 9 | }; 10 | 11 | Gradient.prototype = { 12 | 13 | constructor: Gradient, 14 | 15 | addColorStop: function (offset, color) { 16 | this.colorStops.push({ 17 | 18 | offset: offset, 19 | 20 | color: color 21 | }); 22 | } 23 | }; 24 | 25 | return Gradient; 26 | }); -------------------------------------------------------------------------------- /zrender/src/graphic/LinearGradient.js: -------------------------------------------------------------------------------- 1 | define(function(require) { 2 | 'use strict'; 3 | 4 | var zrUtil = require('../core/util'); 5 | 6 | var Gradient = require('./Gradient'); 7 | 8 | /** 9 | * x, y, x2, y2 are all percent from 0 to 1 10 | * @param {number} [x=0] 11 | * @param {number} [y=0] 12 | * @param {number} [x2=1] 13 | * @param {number} [y2=0] 14 | * @param {Array.} colorStops 15 | * @param {boolean} [globalCoord=false] 16 | */ 17 | var LinearGradient = function (x, y, x2, y2, colorStops, globalCoord) { 18 | this.x = x == null ? 0 : x; 19 | 20 | this.y = y == null ? 0 : y; 21 | 22 | this.x2 = x2 == null ? 1 : x2; 23 | 24 | this.y2 = y2 == null ? 0 : y2; 25 | 26 | // Can be cloned 27 | this.type = 'linear'; 28 | 29 | // If use global coord 30 | this.global = globalCoord || false; 31 | 32 | Gradient.call(this, colorStops); 33 | }; 34 | 35 | LinearGradient.prototype = { 36 | 37 | constructor: LinearGradient 38 | }; 39 | 40 | zrUtil.inherits(LinearGradient, Gradient); 41 | 42 | return LinearGradient; 43 | }); -------------------------------------------------------------------------------- /zrender/src/graphic/Pattern.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var Pattern = function (image, repeat) { 4 | this.image = image; 5 | this.repeat = repeat; 6 | 7 | // Can be cloned 8 | this.type = 'pattern'; 9 | }; 10 | 11 | Pattern.prototype.getCanvasPattern = function (ctx) { 12 | 13 | return this._canvasPattern 14 | || (this._canvasPattern = ctx.createPattern(this.image, this.repeat)); 15 | }; 16 | 17 | return Pattern; 18 | }); -------------------------------------------------------------------------------- /zrender/src/graphic/RadialGradient.js: -------------------------------------------------------------------------------- 1 | define(function(require) { 2 | 'use strict'; 3 | 4 | var zrUtil = require('../core/util'); 5 | 6 | var Gradient = require('./Gradient'); 7 | 8 | /** 9 | * x, y, r are all percent from 0 to 1 10 | * @param {number} [x=0.5] 11 | * @param {number} [y=0.5] 12 | * @param {number} [r=0.5] 13 | * @param {Array.} [colorStops] 14 | * @param {boolean} [globalCoord=false] 15 | */ 16 | var RadialGradient = function (x, y, r, colorStops, globalCoord) { 17 | this.x = x == null ? 0.5 : x; 18 | 19 | this.y = y == null ? 0.5 : y; 20 | 21 | this.r = r == null ? 0.5 : r; 22 | 23 | // Can be cloned 24 | this.type = 'radial'; 25 | 26 | // If use global coord 27 | this.global = globalCoord || false; 28 | 29 | Gradient.call(this, colorStops); 30 | }; 31 | 32 | RadialGradient.prototype = { 33 | 34 | constructor: RadialGradient 35 | }; 36 | 37 | zrUtil.inherits(RadialGradient, Gradient); 38 | 39 | return RadialGradient; 40 | }); -------------------------------------------------------------------------------- /zrender/src/graphic/helper/poly.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var smoothSpline = require('./smoothSpline'); 4 | var smoothBezier = require('./smoothBezier'); 5 | 6 | return { 7 | buildPath: function (ctx, shape, closePath) { 8 | var points = shape.points; 9 | var smooth = shape.smooth; 10 | if (points && points.length >= 2) { 11 | if (smooth && smooth !== 'spline') { 12 | var controlPoints = smoothBezier( 13 | points, smooth, closePath, shape.smoothConstraint 14 | ); 15 | 16 | ctx.moveTo(points[0][0], points[0][1]); 17 | var len = points.length; 18 | for (var i = 0; i < (closePath ? len : len - 1); i++) { 19 | var cp1 = controlPoints[i * 2]; 20 | var cp2 = controlPoints[i * 2 + 1]; 21 | var p = points[(i + 1) % len]; 22 | ctx.bezierCurveTo( 23 | cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1] 24 | ); 25 | } 26 | } 27 | else { 28 | if (smooth === 'spline') { 29 | points = smoothSpline(points, closePath); 30 | } 31 | 32 | ctx.moveTo(points[0][0], points[0][1]); 33 | for (var i = 1, l = points.length; i < l; i++) { 34 | ctx.lineTo(points[i][0], points[i][1]); 35 | } 36 | } 37 | 38 | closePath && ctx.closePath(); 39 | } 40 | } 41 | }; 42 | }); -------------------------------------------------------------------------------- /zrender/src/graphic/mixin/Stateful.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Stateful mixin for graphic object 3 | */ 4 | 5 | define(function (require) { 6 | 7 | var States = require('../States'); 8 | 9 | var Stateful = function (opts) { 10 | 11 | if (opts.states) { 12 | this.initStates(opts.states); 13 | } 14 | }; 15 | 16 | Stateful.prototype = { 17 | 18 | initStates: function (states) { 19 | this._states = new States({ 20 | el: this, 21 | states: states 22 | }); 23 | }, 24 | 25 | setState: function (name) { 26 | this._states && this._states.setState(name); 27 | }, 28 | 29 | getState: function () { 30 | return this._states && this._states.getState(); 31 | }, 32 | 33 | transitionState: function (name, done) { 34 | this._states && this._states.transitionState(name, done); 35 | } 36 | }; 37 | 38 | return Stateful; 39 | }); -------------------------------------------------------------------------------- /zrender/src/graphic/shape/Arc.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 圆弧 3 | * @module zrender/graphic/shape/Arc 4 | */ 5 | define(function (require) { 6 | 7 | return require('../Path').extend({ 8 | 9 | type: 'arc', 10 | 11 | shape: { 12 | 13 | cx: 0, 14 | 15 | cy: 0, 16 | 17 | r: 0, 18 | 19 | startAngle: 0, 20 | 21 | endAngle: Math.PI * 2, 22 | 23 | clockwise: true 24 | }, 25 | 26 | style: { 27 | 28 | stroke: '#000', 29 | 30 | fill: null 31 | }, 32 | 33 | buildPath: function (ctx, shape) { 34 | 35 | var x = shape.cx; 36 | var y = shape.cy; 37 | var r = Math.max(shape.r, 0); 38 | var startAngle = shape.startAngle; 39 | var endAngle = shape.endAngle; 40 | var clockwise = shape.clockwise; 41 | 42 | var unitX = Math.cos(startAngle); 43 | var unitY = Math.sin(startAngle); 44 | 45 | ctx.moveTo(unitX * r + x, unitY * r + y); 46 | ctx.arc(x, y, r, startAngle, endAngle, !clockwise); 47 | } 48 | }); 49 | }); -------------------------------------------------------------------------------- /zrender/src/graphic/shape/Circle.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 圆形 3 | * @module zrender/shape/Circle 4 | */ 5 | 6 | define(function (require) { 7 | 'use strict'; 8 | 9 | return require('../Path').extend({ 10 | 11 | type: 'circle', 12 | 13 | shape: { 14 | cx: 0, 15 | cy: 0, 16 | r: 0 17 | }, 18 | 19 | 20 | buildPath : function (ctx, shape, inBundle) { 21 | // Better stroking in ShapeBundle 22 | // Always do it may have performence issue ( fill may be 2x more cost) 23 | if (inBundle) { 24 | ctx.moveTo(shape.cx + shape.r, shape.cy); 25 | } 26 | // Better stroking in ShapeBundle 27 | // ctx.moveTo(shape.cx + shape.r, shape.cy); 28 | ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2, true); 29 | } 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /zrender/src/graphic/shape/Droplet.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 水滴形状 3 | * @module zrender/graphic/shape/Droplet 4 | */ 5 | 6 | define(function (require) { 7 | 'use strict'; 8 | 9 | return require('../Path').extend({ 10 | 11 | type: 'droplet', 12 | 13 | shape: { 14 | cx: 0, cy: 0, 15 | width: 0, height: 0 16 | }, 17 | 18 | buildPath : function (ctx, shape) { 19 | var x = shape.cx; 20 | var y = shape.cy; 21 | var a = shape.width; 22 | var b = shape.height; 23 | 24 | ctx.moveTo(x, y + a); 25 | ctx.bezierCurveTo( 26 | x + a, 27 | y + a, 28 | x + a * 3 / 2, 29 | y - a / 3, 30 | x, 31 | y - b 32 | ); 33 | ctx.bezierCurveTo( 34 | x - a * 3 / 2, 35 | y - a / 3, 36 | x - a, 37 | y + a, 38 | x, 39 | y + a 40 | ); 41 | ctx.closePath(); 42 | } 43 | }); 44 | }); 45 | -------------------------------------------------------------------------------- /zrender/src/graphic/shape/Ellipse.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 椭圆形状 3 | * @module zrender/graphic/shape/Ellipse 4 | */ 5 | 6 | define(function (require) { 7 | 'use strict'; 8 | 9 | return require('../Path').extend({ 10 | 11 | type: 'ellipse', 12 | 13 | shape: { 14 | cx: 0, cy: 0, 15 | rx: 0, ry: 0 16 | }, 17 | 18 | buildPath: function (ctx, shape) { 19 | var k = 0.5522848; 20 | var x = shape.cx; 21 | var y = shape.cy; 22 | var a = shape.rx; 23 | var b = shape.ry; 24 | var ox = a * k; // 水平控制点偏移量 25 | var oy = b * k; // 垂直控制点偏移量 26 | // 从椭圆的左端点开始顺时针绘制四条三次贝塞尔曲线 27 | ctx.moveTo(x - a, y); 28 | ctx.bezierCurveTo(x - a, y - oy, x - ox, y - b, x, y - b); 29 | ctx.bezierCurveTo(x + ox, y - b, x + a, y - oy, x + a, y); 30 | ctx.bezierCurveTo(x + a, y + oy, x + ox, y + b, x, y + b); 31 | ctx.bezierCurveTo(x - ox, y + b, x - a, y + oy, x - a, y); 32 | ctx.closePath(); 33 | } 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /zrender/src/graphic/shape/Heart.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 心形 3 | * @module zrender/graphic/shape/Heart 4 | */ 5 | define(function (require) { 6 | 'use strict'; 7 | 8 | return require('../Path').extend({ 9 | 10 | type: 'heart', 11 | 12 | shape: { 13 | cx: 0, 14 | cy: 0, 15 | width: 0, 16 | height: 0 17 | }, 18 | 19 | buildPath: function (ctx, shape) { 20 | var x = shape.cx; 21 | var y = shape.cy; 22 | var a = shape.width; 23 | var b = shape.height; 24 | ctx.moveTo(x, y); 25 | ctx.bezierCurveTo( 26 | x + a / 2, y - b * 2 / 3, 27 | x + a * 2, y + b / 3, 28 | x, y + b 29 | ); 30 | ctx.bezierCurveTo( 31 | x - a * 2, y + b / 3, 32 | x - a / 2, y - b * 2 / 3, 33 | x, y 34 | ); 35 | } 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /zrender/src/graphic/shape/Isogon.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 正多边形 3 | * @module zrender/shape/Isogon 4 | * @author sushuang (宿爽, sushuang0322@gmail.com) 5 | */ 6 | define(function (require) { 7 | 'use strict'; 8 | 9 | var PI = Math.PI; 10 | var sin = Math.sin; 11 | var cos = Math.cos; 12 | 13 | return require('../Path').extend({ 14 | 15 | type: 'isogon', 16 | 17 | shape: { 18 | x: 0, y: 0, 19 | r: 0, n: 0 20 | }, 21 | 22 | buildPath: function (ctx, shape) { 23 | var n = shape.n; 24 | if (!n || n < 2) { 25 | return; 26 | } 27 | 28 | var x = shape.x; 29 | var y = shape.y; 30 | var r = shape.r; 31 | 32 | var dStep = 2 * PI / n; 33 | var deg = -PI / 2; 34 | 35 | ctx.moveTo(x + r * cos(deg), y + r * sin(deg)); 36 | for (var i = 0, end = n - 1; i < end; i++) { 37 | deg += dStep; 38 | ctx.lineTo(x + r * cos(deg), y + r * sin(deg)); 39 | } 40 | 41 | ctx.closePath(); 42 | 43 | return; 44 | } 45 | }); 46 | }); 47 | -------------------------------------------------------------------------------- /zrender/src/graphic/shape/Line.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 直线 3 | * @module zrender/graphic/shape/Line 4 | */ 5 | define(function (require) { 6 | return require('../Path').extend({ 7 | 8 | type: 'line', 9 | 10 | shape: { 11 | // Start point 12 | x1: 0, 13 | y1: 0, 14 | // End point 15 | x2: 0, 16 | y2: 0, 17 | 18 | percent: 1 19 | }, 20 | 21 | style: { 22 | stroke: '#000', 23 | fill: null 24 | }, 25 | 26 | buildPath: function (ctx, shape) { 27 | var x1 = shape.x1; 28 | var y1 = shape.y1; 29 | var x2 = shape.x2; 30 | var y2 = shape.y2; 31 | var percent = shape.percent; 32 | 33 | if (percent === 0) { 34 | return; 35 | } 36 | 37 | ctx.moveTo(x1, y1); 38 | 39 | if (percent < 1) { 40 | x2 = x1 * (1 - percent) + x2 * percent; 41 | y2 = y1 * (1 - percent) + y2 * percent; 42 | } 43 | ctx.lineTo(x2, y2); 44 | }, 45 | 46 | /** 47 | * Get point at percent 48 | * @param {number} percent 49 | * @return {Array.} 50 | */ 51 | pointAt: function (p) { 52 | var shape = this.shape; 53 | return [ 54 | shape.x1 * (1 - p) + shape.x2 * p, 55 | shape.y1 * (1 - p) + shape.y2 * p 56 | ]; 57 | } 58 | }); 59 | }); 60 | -------------------------------------------------------------------------------- /zrender/src/graphic/shape/Polygon.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 多边形 3 | * @module zrender/shape/Polygon 4 | */ 5 | define(function (require) { 6 | 7 | var polyHelper = require('../helper/poly'); 8 | 9 | return require('../Path').extend({ 10 | 11 | type: 'polygon', 12 | 13 | shape: { 14 | points: null, 15 | 16 | smooth: false, 17 | 18 | smoothConstraint: null 19 | }, 20 | 21 | buildPath: function (ctx, shape) { 22 | polyHelper.buildPath(ctx, shape, true); 23 | } 24 | }); 25 | }); -------------------------------------------------------------------------------- /zrender/src/graphic/shape/Polyline.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @module zrender/graphic/shape/Polyline 3 | */ 4 | define(function (require) { 5 | 6 | var polyHelper = require('../helper/poly'); 7 | 8 | return require('../Path').extend({ 9 | 10 | type: 'polyline', 11 | 12 | shape: { 13 | points: null, 14 | 15 | smooth: false, 16 | 17 | smoothConstraint: null 18 | }, 19 | 20 | style: { 21 | stroke: '#000', 22 | 23 | fill: null 24 | }, 25 | 26 | buildPath: function (ctx, shape) { 27 | polyHelper.buildPath(ctx, shape, false); 28 | } 29 | }); 30 | }); -------------------------------------------------------------------------------- /zrender/src/graphic/shape/Rect.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 矩形 3 | * @module zrender/graphic/shape/Rect 4 | */ 5 | 6 | define(function (require) { 7 | var roundRectHelper = require('../helper/roundRect'); 8 | 9 | return require('../Path').extend({ 10 | 11 | type: 'rect', 12 | 13 | shape: { 14 | // 左上、右上、右下、左下角的半径依次为r1、r2、r3、r4 15 | // r缩写为1 相当于 [1, 1, 1, 1] 16 | // r缩写为[1] 相当于 [1, 1, 1, 1] 17 | // r缩写为[1, 2] 相当于 [1, 2, 1, 2] 18 | // r缩写为[1, 2, 3] 相当于 [1, 2, 3, 2] 19 | r: 0, 20 | 21 | x: 0, 22 | y: 0, 23 | width: 0, 24 | height: 0 25 | }, 26 | 27 | buildPath: function (ctx, shape) { 28 | var x = shape.x; 29 | var y = shape.y; 30 | var width = shape.width; 31 | var height = shape.height; 32 | if (!shape.r) { 33 | ctx.rect(x, y, width, height); 34 | } 35 | else { 36 | roundRectHelper.buildPath(ctx, shape); 37 | } 38 | ctx.closePath(); 39 | return; 40 | } 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /zrender/src/graphic/shape/Ring.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 圆环 3 | * @module zrender/graphic/shape/Ring 4 | */ 5 | define(function (require) { 6 | 7 | return require('../Path').extend({ 8 | 9 | type: 'ring', 10 | 11 | shape: { 12 | cx: 0, 13 | cy: 0, 14 | r: 0, 15 | r0: 0 16 | }, 17 | 18 | buildPath: function (ctx, shape) { 19 | var x = shape.cx; 20 | var y = shape.cy; 21 | var PI2 = Math.PI * 2; 22 | ctx.moveTo(x + shape.r, y); 23 | ctx.arc(x, y, shape.r, 0, PI2, false); 24 | ctx.moveTo(x + shape.r0, y); 25 | ctx.arc(x, y, shape.r0, 0, PI2, true); 26 | } 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /zrender/src/graphic/shape/Rose.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 玫瑰线 3 | * @module zrender/graphic/shape/Rose 4 | */ 5 | define(function (require) { 6 | 7 | var sin = Math.sin; 8 | var cos = Math.cos; 9 | var radian = Math.PI / 180; 10 | 11 | return require('../Path').extend({ 12 | 13 | type: 'rose', 14 | 15 | shape: { 16 | cx: 0, 17 | cy: 0, 18 | r: [], 19 | k: 0, 20 | n: 1 21 | }, 22 | 23 | style: { 24 | stroke: '#000', 25 | fill: null 26 | }, 27 | 28 | buildPath: function (ctx, shape) { 29 | var x; 30 | var y; 31 | var R = shape.r; 32 | var r; 33 | var k = shape.k; 34 | var n = shape.n; 35 | 36 | var x0 = shape.cx; 37 | var y0 = shape.cy; 38 | 39 | ctx.moveTo(x0, y0); 40 | 41 | for (var i = 0, len = R.length; i < len ; i++) { 42 | r = R[i]; 43 | 44 | for (var j = 0; j <= 360 * n; j++) { 45 | x = r 46 | * sin(k / n * j % 360 * radian) 47 | * cos(j * radian) 48 | + x0; 49 | y = r 50 | * sin(k / n * j % 360 * radian) 51 | * sin(j * radian) 52 | + y0; 53 | ctx.lineTo(x, y); 54 | } 55 | } 56 | } 57 | }); 58 | }); 59 | -------------------------------------------------------------------------------- /zrender/src/graphic/shape/Star.js: -------------------------------------------------------------------------------- 1 | /** 2 | * n角星(n>3) 3 | * @module zrender/graphic/shape/Star 4 | */ 5 | 6 | define(function (require) { 7 | var PI = Math.PI; 8 | 9 | var cos = Math.cos; 10 | var sin = Math.sin; 11 | 12 | return require('../Path').extend({ 13 | 14 | type: 'star', 15 | 16 | shape: { 17 | cx: 0, 18 | cy: 0, 19 | n: 3, 20 | r0: null, 21 | r: 0 22 | }, 23 | 24 | buildPath: function (ctx, shape) { 25 | 26 | var n = shape.n; 27 | if (!n || n < 2) { 28 | return; 29 | } 30 | 31 | var x = shape.cx; 32 | var y = shape.cy; 33 | var r = shape.r; 34 | var r0 = shape.r0; 35 | 36 | // 如果未指定内部顶点外接圆半径,则自动计算 37 | if (r0 == null) { 38 | r0 = n > 4 39 | // 相隔的外部顶点的连线的交点, 40 | // 被取为内部交点,以此计算r0 41 | ? r * cos(2 * PI / n) / cos(PI / n) 42 | // 二三四角星的特殊处理 43 | : r / 3; 44 | } 45 | 46 | var dStep = PI / n; 47 | var deg = -PI / 2; 48 | var xStart = x + r * cos(deg); 49 | var yStart = y + r * sin(deg); 50 | deg += dStep; 51 | 52 | // 记录边界点,用于判断inside 53 | ctx.moveTo(xStart, yStart); 54 | for (var i = 0, end = n * 2 - 1, ri; i < end; i++) { 55 | ri = i % 2 === 0 ? r0 : r; 56 | ctx.lineTo(x + ri * cos(deg), y + ri * sin(deg)); 57 | deg += dStep; 58 | } 59 | 60 | ctx.closePath(); 61 | } 62 | }); 63 | }); 64 | -------------------------------------------------------------------------------- /zrender/src/readme.md: -------------------------------------------------------------------------------- 1 | 本文件夹下的源码注释过 2 | -------------------------------------------------------------------------------- /zrender/src/svg/core.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | 3 | var svgURI = "http://www.w3.org/2000/svg"; 4 | 5 | return { 6 | createElement: function (name) { 7 | return document.createElementNS(svgURI, name); 8 | } 9 | }; 10 | }); -------------------------------------------------------------------------------- /zrender/src/svg/svg.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | require('./graphic'); 3 | require('../zrender').registerPainter('svg', require('./Painter')); 4 | }); -------------------------------------------------------------------------------- /zrender/src/vml/core.js: -------------------------------------------------------------------------------- 1 | define(function (require, exports, module) { 2 | 3 | if (!require('../core/env').canvasSupported) { 4 | var urn = 'urn:schemas-microsoft-com:vml'; 5 | 6 | var createNode; 7 | var win = window; 8 | var doc = win.document; 9 | 10 | var vmlInited = false; 11 | 12 | try { 13 | !doc.namespaces.zrvml && doc.namespaces.add('zrvml', urn); 14 | createNode = function (tagName) { 15 | return doc.createElement(''); 16 | }; 17 | } 18 | catch (e) { 19 | createNode = function (tagName) { 20 | return doc.createElement('<' + tagName + ' xmlns="' + urn + '" class="zrvml">'); 21 | }; 22 | } 23 | 24 | // From raphael 25 | var initVML = function () { 26 | if (vmlInited) { 27 | return; 28 | } 29 | vmlInited = true; 30 | 31 | var styleSheets = doc.styleSheets; 32 | if (styleSheets.length < 31) { 33 | doc.createStyleSheet().addRule('.zrvml', 'behavior:url(#default#VML)'); 34 | } 35 | else { 36 | // http://msdn.microsoft.com/en-us/library/ms531194%28VS.85%29.aspx 37 | styleSheets[0].addRule('.zrvml', 'behavior:url(#default#VML)'); 38 | } 39 | }; 40 | 41 | // Not useing return to avoid error when converting to CommonJS module 42 | module.exports = { 43 | doc: doc, 44 | initVML: initVML, 45 | createNode: createNode 46 | }; 47 | } 48 | }); -------------------------------------------------------------------------------- /zrender/src/vml/vml.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | require('./graphic'); 3 | require('../zrender').registerPainter('vml', require('./Painter')); 4 | }); --------------------------------------------------------------------------------