package org.lizhen;
import java.io.*;
import jofc2.model.*;
import jofc2.model.axis.XAxis;
import jofc2.model.axis.YAxis;
import jofc2.model.elements.*;
public class LineDemo {
/**
* 使用 JOFC2 创建数据模型的一般流程为:
* 创建特定图表类型实例 -> 添加图表描述数据 -> 创建 OFC 图表对象 -> 序列化为 JSON 文件
* @param args
*/
public static void main (String[] args) {
System.out.println("*******************");
LineChart lineChart = new LineChart(LineChart.Style
.NORMAL);//创建特定图表类型实例
lineChart.setColour("#669900");
lineChart.setText("line1");
lineChart.setFontSize(15);
lineChart.setTooltip("#val#%");
//添加图表描述数据 点的描述
/* lineChart.addValues(10);
lineChart.addValues(20);
lineChart.addValues(40);
lineChart.addValues(30);*/
LineChart.Dot dot1 = new LineChart.Dot(70,"0x6699CC");
LineChart.Dot dot2 = new LineChart.Dot(75,"0x6699CC");
LineChart.Dot dot3 = new LineChart.Dot(80,"0x6699CC");
LineChart.Dot dot4 = new LineChart.Dot(85,"0x6699CC");
LineChart.Dot dot5 = new LineChart.Dot(80,"0x6699CC");
LineChart.Dot dot6 = new LineChart.Dot(75,"0x6699CC");
LineChart.Dot dot7 = new LineChart.Dot(70,"0x6699CC");
LineChart.Dot dot8 = new LineChart.Dot(60,"0x6699CC");
lineChart.addDots(dot1);
lineChart.addDots(dot2);
lineChart.addDots(dot3);
lineChart.addDots(dot4);
lineChart.addDots(dot5);
lineChart.addDots(dot6);
lineChart.addDots(dot7);
lineChart.addDots(dot8);
//添加图表描述数据 X、Y坐标
XAxis xAxis = new XAxis();
xAxis.addLabels("1月份");
xAxis.addLabels("2月份");
xAxis.addLabels("3月份");
xAxis.addLabels("4月份");
xAxis.addLabels("5月份");
xAxis.addLabels("6月份");
xAxis.addLabels("7月份");
xAxis.addLabels("8月份");
xAxis.setColour("#9933CC");
long max =100;
YAxis yAxis = new YAxis();
yAxis.setMax(max+0.0);
yAxis.setSteps(10);
//创建 OFC 图表对象
Chart flashChart = new Chart("lineChart_demo","font-size:18px;color:#ff0000;");
flashChart.setXAxis(xAxis);
flashChart.setYAxis(yAxis);
Text yText = new Text("***lineChart***",Text.createStyle(20, "#736AFF", Text.TEXT_ALIGN_CENTER));
flashChart.setYLegend(yText);
flashChart.addElements(lineChart);
//序列化为 JSON 文件
String jsonString = flashChart.toString();
String fileName = System.currentTimeMillis()+".json";
System.out.println(fileName);
try {
FileOutputStream fos = new FileOutputStream(new File("D:/data/"+fileName));
try {
fos.write(jsonString.getBytes("UTF-8"));
fos.close();
System.out.println("OK");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
用ofc2写折线的JSO出现了一个问题,就是无法在HTML上显示出来,后来看到文档上说LineChart.Style 有三种枚举类型,选NORMAL那个就可以显示出来。。。
分享到:
相关推荐
1.1 Examples of Complexity 2 1.1.1 The Analytically Tractable System 3 1.1.2 The Analytically Tedious System 5 1.1.3 The Analytically Intractable System 7 1.2 Multidisciplinary Aspects of Simulation 8...
Electromagnetic Field Theory Fundamentals 2nd ed - B....APPENDIX A SMITH CHART AND ITS APPLICATIONS APPENDIX B COMPUTER PROGRAMS FOR VARIOUS PROBLEMS APPENDIX C USEFUL MATHEMATICAL TABLES INDEX
Although 2 GB of address space may seem like a large amount of memory, application such as SQL Server could leverage more memory if it were available. The boot.ini option /3GB was created for those ...
PLOTEMP3 C - C example - modification of PLOTEMP2.C PLOTEMP4 C - C example - modification of PLOTEMP3.C PLOTEMP5 C - C example - modification of PLOTEMP4.C PLOTEMP6 C - C example - modification of...
Calculates the differential pair impedance of a balanced line. PCB Padstack Calculator Calculates the outer and inner layer diameters of a padstack given the drill size. BGA land calculator based on ...
Table of Contents 1. Introduction to Computers, Internet and the World Wide Web. 2. Introduction to Python Programming. 3. Control Structures. 4. Functions. 5. Tuples, Lists, and Dictionaries. 6...
- Designtime saved content of a Chart does not always successfully import to a NET project. We recommend you open the project first in its current environment (eg. Visual Basic v6) and provoke a ...
Chip Transmission Lines 129 5.23.1 Effect of Transmission Line 130 5.23.2 Transmission Line Examples 131 5.24 High-Frequency Measurement of On-Chip Passives and Some Common De-Embedding...
Used by tens of thousands of developers and 61 out of the world's 100 largest companies, Highcharts is the simplest yet most flexible charting API on the market. Read more » Download » ...
//Change width of columns 1 & 2 oTable.Columns[2].Width = oWord.InchesToPoints(3); <br>//Keep inserting text. When you get to 7 inches from top of the //document, insert a hard page break....
CEChartsLink : Learn of Charts==> LineChart==> BarChart==> PieChart注意使用版本及环境:Xcode 9.2 / Swift 4.0iOS >= 8.0Charts v3.0.5clone/download zip后需要对Charts 文件夹执行"pod update" 和修改swift ...
document for a chart of the different Diskeeper editions and the Windows versions each supports. Note that x64 versions of Diskeeper will only install on x64 editions of Windows. B. OVERVIEW OF ...
- fixed bug with truncate of font size combo-box in Windows Vista/7 in designer (lost of vertical scroll bar) - fixed bug when lost file name in inherited report - fixed bug in multi-page report with ...
Usage: `ginh [-h] [-a] [-n entries] [-f hist_file] [-c chart_char] [-l line_len]` `ginh` generates a bar chart of your most frequently used shell commands, according to your shell's history file. ...
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/> declaration="yes"/> name="testNgXslt.outputDir"/>...
- Designtime saved content of a Chart does not always successfully import to a NET project. We recommend you open the project first in its current environment (eg. Visual Basic v6) and provoke a ...
2) Install the source into a directory of your choice. The files are installed into three directories: DragDrop DragDrop\Components DragDrop\Demo 3) Install and compile the appropriate design ...
Handle spotty data, or data that doesn’t line up with what your chart expects Use D3 to build pie and bar charts, scatter and box plots, and more Work effectively with time-series data Tweak Ruby and...
2. Zend_Acl 2.1. 简介 2.1.1. 关于资源(Resource) 2.1.2. 关于角色(Role) 2.1.3. 创建访问控制列表(ACL) 2.1.4. 注册角色(Role) 2.1.5. 定义访问控制 2.1.6. 查询 ACL 2.2. 精细的访问控制 2.2.1. 精细的...
A wide range of objects used in report (text, image, chart, barcode, etc.) and data-formatting tools - everything necessary to create professional-looking reports; A built-in dialog designer to ...