Coder Social home page Coder Social logo

Comments (3)

zaoying avatar zaoying commented on May 18, 2024

你好,你这样的写法其实不适合用我的框架。正确的写法:
//创建TimeLine.java
import cn.edu.gdut.zaoying.Option.timeline.DataArray;
import cn.edu.gdut.zaoying.Option.timeline.SymbolSizeNumber;
import cn.edu.gdut.zaoying.Option.timeline.SymbolString;
import cn.edu.gdut.zaoying.Option.tooltip.FormatterString;
import cn.edu.gdut.zaoying.SingleChart;
@SingleChart
public class TimeLine {
@FormatterString(value = "{b}XXXX")
String formatter;
@dataarray
double data[];
@SymbolString(value = "diamond")
String symbol;
@SymbolSizeNumber(value = 16)
int symbolSize;

public void setData(String[] data) {
    this.data = data;
}

}
//创建ECharts.java
import com.alibaba.fastjson.JSON;
import java.util.HashMap;
import java.util.Map;

public class ECharts {
public static void main(String[] args) {
TimeLine timeLine=new TimeLine();
timeLine.setData(new String[]{"2002-01-01","2003-01-01","2004-01-01","2005-01-01","2006-01-01"});
Map<String,Object> option=new HashMap<>();
Object json=EChartsAnnotationProcessor.parseChart(timeLine);
option.put("baseOption",json);
System.out.print(JSON.toJSONString(option));
}
}
PS:别被那么多代码吓到了,其实核心代码跟你的差不多。但是这个达不到你要的效果,你给的例子是官方的特例,因为它没有写进Option配置里。因此我把你的代码改动如下:
TimeLineCharts charts=new TimeLineCharts();
Map<String,Object> map=new HashMap<>();
Map<String,Object> mtool=new HashMap<>();
mtool.put("formatter", "what");
map.put("value", "2005-01-01");
map.put("tooltip", mtool);
map.put("symbol", "diamond");
map.put("symbolSize", 16);
charts.setData(new Object[]{"2002-01-01","2003-01-01","2004-01-01",map,"2006-01-01"});
//你没有使用框架里的注解,因此调用我的解析器是没有效果的
//Object json=EChartsAnnotationProcessor.parseSingleChart(charts);
System.out.print(JSON.toJSONString(charts));//直接用fastjson输出json
PS:咳!这个可以达到你要的效果,但是我的框架不是专门解析JSON的类库。你如果觉得不喜欢用注解,我推荐你使用fastjson来到你的目的。

from echartsannotation.

fapwlh avatar fapwlh commented on May 18, 2024

非常感谢回复,受教了,是我把你的这个框架还没有完全理解,下来再好好对照echart的api学学,再次感谢!

from echartsannotation.

zaoying avatar zaoying commented on May 18, 2024

不用客气

from echartsannotation.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.