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那个就可以显示出来。。。
分享到:
相关推荐
Open Flash Chart(简称OFC)是一款基于Flash的开源图表库,它允许开发者通过简单的JSON数据格式创建丰富的、交互式的图表。由于其采用Flash技术,使得图表具有良好的视觉效果和跨平台兼容性。OFC在Web开发中常用于...
chart.add_element(new openflashchart.Line(0, {line_thickness: 2, line_color: "#ff0000"})); document.getElementById('chart').innerHTML = chart.render(); ``` 5. **实现动态更新**:使用Ajax请求从服务器...
在提供的压缩包"ofc"中,可能包含了Open Flash Chart 2的示例代码和资源文件。这些示例通常包括HTML文件和对应的JavaScript文件,演示如何配置和生成线性图、柱形图和饼状图。通过学习和分析这些示例,开发者能够...
$chart = new OFC_Chart(); $chart->set_title($title); $chart->add_element($line_dot); echo $chart->toPrettyString(); ``` 访问这个PHP文件会返回一个JSON格式的数据,供Open Flash Chart解析。 B. JSON数据...
OFC的强大之处还体现在其丰富的图表元素和自定义选项上。例如,对于柱状图,你可以调整柱子的宽度、颜色,甚至添加阴影效果;饼图则可以设置各个扇区的颜色、标签,以及旋转角度;线形图支持平滑曲线、数据点标记等...
- **说明**:此参数决定了图表的基本形态,是 OFC 最基础也是最重要的配置项之一。 2. **data**:设置图表的数据源。 - **说明**:可以是数组形式的数据,也可以是 URL 地址指向的外部数据文件。根据不同的图表...
在压缩包文件"ofc"中,可能包含了Open Flash Chart的源代码、示例项目、文档和库文件,供开发者学习和参考。通过深入研究这些内容,开发者可以更好地理解和掌握Open Flash Chart的使用方法,从而在自己的ASP.NET项目...
- **定义**:Openflashchart(简称ofc)是一款开源的Flash图表组件,允许用户免费使用及修改其源代码,以便根据需求定制图表样式。它通过在客户端的Flash Player中渲染数据来生成动态图表。 - **特性**: - 免费与...
xAxis.valueFormatter = IndexAxisValueFormatter(arrayOf("A", "B", "C", "D", "E")) val yAxisLeft = lineChart.axisLeft yAxisLeft.axisMinimum = 0f yAxisLeft.axisMaximum = 20f yAxisLeft.setDrawGridLines...
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...
2. 折线图(Line Chart) 折线图常用于展示数据随时间的变化趋势。Chart.js提供了简单易用的API来创建折线图。首先,我们需要创建一个canvas元素,并通过`new Chart(ctx, config)`来初始化图表,其中`config`对象...
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 » ...
echo “swfobject.embedSWF(‘”.$this->path.”/open-flash-chart.swf’, ‘$this->id’, ‘$this->width’,’$this->height’,’9.0.0′,’expressInstall.swf’,{‘get-data’:’ofc_get_dataOf{$this->id}’} )...