Skip to content

Commit

Permalink
Merge pull request #47 from freelyshadow/master
Browse files Browse the repository at this point in the history
增加组件类型->graphic (图形元素组件)
  • Loading branch information
abel533 committed Aug 5, 2018
2 parents fdcf985 + d1e9574 commit dfb2ce7
Show file tree
Hide file tree
Showing 12 changed files with 930 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/java/com/github/abel533/echarts/AbstractData.java
Expand Up @@ -149,6 +149,7 @@ public List data() {
* @param values
* @return
*/
@Override
public T data(Object... values) {
if (values == null || values.length == 0) {
return (T) this;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/github/abel533/echarts/Config.java
Expand Up @@ -60,6 +60,7 @@ public interface Config {
String COMPONENT_TYPE_AXIS_CATEGORY = "categoryAxis";
String COMPONENT_TYPE_AXIS_VALUE = "valueAxis";
String COMPONENT_TYPE_TIMELINE = "timeline";
String COMPONENT_TYPE_GRAPHIC = "graphic";

// 全图默认背景
String backgroundColor = "rgba(0,0,0,0)";
Expand Down
145 changes: 145 additions & 0 deletions src/main/java/com/github/abel533/echarts/Graphic.java
@@ -0,0 +1,145 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2015 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package com.github.abel533.echarts;

import com.github.abel533.echarts.code.GraphicType;
import com.github.abel533.echarts.style.GraphicStyle;
import lombok.Getter;
import lombok.Setter;

/**
* 图形元素组件
*
* @author liuxu
* @date 18-7-9下午2:13
*/
@Getter
@Setter
public class Graphic extends Basic<Graphic> implements Component {

/**
* id 用于在更新图形元素时指定更新哪个图形元素,如果不需要用可以忽略
*/
private String id;

/**
* 这个字段在第一次设置时不能忽略,取值见上方『支持的图形元素』
*/
private GraphicType type;

// 下面的各个属性如果不需要设置都可以忽略,忽略则取默认值

/**
* 指定本次 setOption 对此图形元素进行的操作。默认是 'merge',还可以 'replace' 或 'remove'
*/
private String $action;

/**
* 定位、形状相关的设置,如 x, y, cx, cy, width, height, r, points 等
* 注意,如果设置了 left/right/top/bottom,这里的定位用的 x/y/cx/cy 会失效
*/
private Object shape;

/**
* 样式相关的设置,如 fill, stroke, lineWidth, shadowBlur 等
*/
private GraphicStyle style;

/**
* 表示不响应事件
*/
private Boolean silent;

/**
* 表示节点不显示
*/
private Boolean invisible;

/**
* 设置是否整体限制在父节点范围内。可选值:'raw', 'all'
*/
private String bouding;

/**
* 是否可以被拖拽
*/
private Boolean draggable;

/**
* 事件的监听器,还可以是 onmousemove, ondrag 等
*/
private String onclick;

public Graphic id(String id) {
this.id = id;
return this;
}

public Graphic type(GraphicType type) {
this.type = type;
return this;
}

public Graphic $action(String $action) {
this.$action = $action;
return this;
}

public Graphic shape(Object shape) {
this.shape = shape;
return this;
}

public Graphic style(GraphicStyle style) {
this.style = style;
return this;
}

public Graphic silent(Boolean silent) {
this.silent = silent;
return this;
}

public Graphic invisible(Boolean invisible) {
this.invisible = invisible;
return this;
}

public Graphic bouding(String bouding) {
this.bouding = bouding;
return this;
}

public Graphic draggable(Boolean draggable) {
this.draggable = draggable;
return this;
}

public Graphic onclick(String onclick) {
this.onclick = onclick;
return this;
}

}
32 changes: 32 additions & 0 deletions src/main/java/com/github/abel533/echarts/Option.java
Expand Up @@ -193,6 +193,14 @@ public class Option implements Serializable {
* visualMap 是视觉映射组件,用于进行『视觉编码』,也就是将数据映射到视觉元素(视觉通道)
*/
private List<VisualMap> visualMap;
/**
* 图形元素组件
*/
private Graphic graphic;
/**
* 雷达图
*/
private Radar radar;

public List<VisualMap> visualMap() {
if (this.visualMap == null) {
Expand Down Expand Up @@ -1016,4 +1024,28 @@ public Option options(Option... values) {
this.options().addAll(Arrays.asList(values));
return this;
}

/**
* 添加图形元素组件
*
* @param graphic
* @return
*/
public Option graphic(Graphic graphic) {
this.graphic = graphic;
return this;

}

/**
* 雷达图
*
* @param radar
* @return
*/
public Option radar(Radar radar) {
this.radar = radar;
return this;
}

}

0 comments on commit dfb2ce7

Please sign in to comment.