`
js_hum
  • 浏览: 17425 次
  • 性别: Icon_minigender_1
  • 来自: 合肥
社区版块
存档分类
最新评论

ofc2 之lineChart

    博客分类:
  • ofc
阅读更多

 

 

 

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那个就可以显示出来。。。

分享到:
评论

相关推荐

    Principles of Communication System Simulation with Wireless Aplications (英文版PDF)

    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. Guru, H. Hiziroglu

    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

    微软内部资料-SQL性能优化2

    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 ...

    绿色版PocketDOS 和 绿色版TC3.0

    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...

    非常优秀的PCB设计辅助工具

    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 ...

    Python - How to Program, 1e (2002).pdf

    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...

    TeeChart2018ActiveX_0_2_9Eval3264

    - 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 ...

    Radio Frequency Integrated Circuit Design

    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...

    html5和c++开源 K线图工具

    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 » ...

    word表格格式

    //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....

    CECharts:图表学习

    CEChartsLink : Learn of Charts==> LineChart==> BarChart==> PieChart注意使用版本及环境:Xcode 9.2 / Swift 4.0iOS >= 8.0Charts v3.0.5clone/download zip后需要对Charts 文件夹执行"pod update" 和修改swift ...

    Diskeeper 2008 v12.0.759.0

    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 ...

    FastReport.v4.15 for.Delphi.BCB.Full.Source企业版含ClientServer中文修正版支持D4-XE5

    - 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 ...

    ginh:ginh不是直方图:直观地评估您的shell使用模式

    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. ...

    eclipse-testng 离线包下载

    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"/>...

    TeeChart Pro Activex Control v2018

    - 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 ...

    Senfore_DragDrop_v4.1

    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 ...

    Data Visualization Toolkit: Using JavaScript

    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...

    ZendFramework中文文档

    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. 精细的...

    FastReport.v4.9.81 for.Delphi.BCB.Full.Source企业版含ClientServer中文修正版

    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 ...

Global site tag (gtag.js) - Google Analytics