JavaFX Chart设置数值显示
一、XYChart
import javafx.application.Application;
import javafx.geometry.NodeOrientation;
import javafx.geometry.Side;
import javafx.scene.Scene;
import javafx.scene.chart.*;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class LineChartSample extends Application {
@Override
public void start(Stage stage) {
stage.setTitle("people");
final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis();
xAxis.setLabel("Country");
final BarChart<String, Number> chart =
new BarChart<String, Number>(xAxis, yAxis);
chart.setTitle("people");
XYChart.Series series = new XYChart.Series();
series.setName("flag");
series.getData().add(new XYChart.Data("China", 14.7));
series.getData().add(new XYChart.Data("America", 2.5));
series.getData().add(new XYChart.Data("India", 14));
XYChart.Data data = new XYChart.Data("Russa", 2);
data.setNode(new Label("2"));
series.getData().add(data);
Scene scene = new Scene(chart, 800, 600);
chart.getData().addAll(series);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
二、PieChart
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.chart.*;
import javafx.scene.Group;
public class PieChartSample extends Application {
@Override public void start(Stage stage) {
Scene scene = new Scene(new Group());
stage.setTitle("Imported Fruits");
stage.setWidth(500);
stage.setHeight(500);
ObservableList<PieChart.Data> pieChartData =
FXCollections.observableArrayList(
new PieChart.Data("Grapefruit", 13),
new PieChart.Data("Oranges", 25),
new PieChart.Data("Plums", 10),
new PieChart.Data("Pears", 22),
new PieChart.Data("Apples", 30)
);
final PieChart chart = new PieChart(pieChartData);
chart.setTitle("Imported Fruits");
final Label caption = new Label("");
caption.setTextFill(Color.DARKORANGE);
caption.setStyle("-fx-font: 24 arial;");
for (final PieChart.Data data : chart.getData()) {
data.getNode().addEventHandler(MouseEvent.MOUSE_PRESSED,
new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent e) {
caption.setTranslateX(e.getSceneX());
caption.setTranslateY(e.getSceneY());
caption.setText(String.valueOf(data.getPieValue()) + "%");
}
});
}
((Group) scene.getRoot()).getChildren().addAll(chart,caption);
stage.setScene(scene);
stage.show(http://www.my516.com);
}
public static void main(String[] args) {
launch(args);
}
}
---------------------
JavaFX Chart设置数值显示的更多相关文章
- c# Chart设置样式
一.chart属性熟悉 能够对C# chart控件属性熟悉起帮助的code, 现在分享给大家,Chart Operate Demo Code Download,如有帮助,别忘点个赞. Chart ...
- Powershell 设置数值格式 1
设置数值格式 1 6 6月, 2013 在 Powershell tagged 字符串 / 数字 / 文本 / 日期 / 格式化 by Mooser Lee 格式化操作符 -f 可以将数值插入到字符 ...
- Highcharts 饼图数值显示在图形上
1.引用js文件 <script type="text/javascript" src="http://cdn.hcharts.cn/jquery/jquery-1 ...
- Linux中文显示乱码?如何设置centos显示中文
Linux中文显示乱码?如何设置centos显示中文 怎么设置Linux系统中文语言,这是很多小伙伴在开始使用Linux的时候,都会遇到一个问题,就是终端输入命令回显的时候中文显示乱码.出现这个情况一 ...
- 在线图片压缩后以ImageIO 流的形式 设置大小显示指定页面
1.Servlet 代码 public class ZoomImgServlet extends HttpServlet implements Servlet { public void init ...
- 实验10.3_数值显示拓展_dword型数转变为表示十进制数的字符串
assume cs:code data segment db 10 dup (0) data ends code segment start : mov ax,4240H;F4240H=1000000 ...
- 解决JQuery中datatables设置隐藏显示列多次提交后台刷新数据的问题
此次项目开发过程中用到了Jquery的Datatables插件,无疑他是数据列表展示,解决MVC中同步过程中先走控制器后返回视图,查询数据过程中无法提示等待的弊端, 而且他所提供的各种方法也都有较强的 ...
- 设置DataGridView 显示自己添加编辑的列名,不动态显示数据库本身
设置DataGridView 显示自己添加编辑的列名,不动态显示数据库本身. 方法: (1)界面操作,把DataGridView控件拖放在窗体中,就看到DataGridView控件的右上角有个小三角, ...
- emWin(ucGui)数值显示例程 -【worldsing笔记】
本例程下载:2.emWin5.26(ucGui)VS2008数字显示.zip 在emWin显示文本字符还是容易,我们也可以使用字符串和标准 C 库的函数来显示数值.然而,有时候这会是件困难的事.通 ...
随机推荐
- Watir: 如果安装sougou浏览器,有可能导致Watir不能工作
如果安装了搜狗,Watir::Browser.new并不一定能打开新的IE浏览器.这种情况下,必须卸载搜狗浏览器,当然,attach,find方法还是可以用的
- Python学习之旅—生成器与迭代器案例剖析
前言 前面一篇博客笔者带大家详细探讨了生成器与迭代器的本质,本次我们将实际分析一个具体案例来加深对生成器与迭代器相关知识点的理解. 本次的案例是一个文件过滤操作,所做的主要操作就是过滤出一个目录下的文 ...
- hdoj5671 BestCoder Round #81 (div.2)
对于交换行.交换列的操作,分别记录当前状态下每一行.每一列是原始数组的哪一行.哪一列即可. 对每一行.每一列加一个数的操作,也可以两个数组分别记录.注意当交换行.列的同时,也要交换增量数组. 输出时通 ...
- Mac上搭建直播服务器Nginx+rtmp,实现手机推流、拉流
转载自http://www.cnblogs.com/jys509/p/5649066.html 简介 nginx是非常优秀的开源服务器,用它来做hls或者rtmp流媒体服务器是非常不错的选择,本人在网 ...
- Asp.net core 框架整理
https://github.com/thangchung/awesome-dotnet-core#cms
- 水题 Codeforces Round #304 (Div. 2) A. Soldier and Bananas
题目传送门 /* 水题:ans = (1+2+3+...+n) * k - n,开long long */ #include <cstdio> #include <algorithm ...
- AWVS11使用教程——Acunetix Web Vulnerability Scanner 11.x
AWVS11使用教程 一:普通扫描. 二:报告生成. 三:登陆扫描. Acunetix Web Vulnerability Scanner(简称AWVS)是一款知名的网络漏洞扫描工具,它通过网络爬虫测 ...
- 题解报告:hdu 3549 Flow Problem(最大流入门)
Problem Description Network flow is a well-known difficult problem for ACMers. Given a graph, your t ...
- magento优化之模板静态化
最近首页很慢,运行magento profile检查的时候,发现首页某个templat运行时间占了一半,大概6s. 用magento自带的缓存,尝试把代码中的collection缓存起来,但不知道为啥 ...
- Java对象的内存布局以及对象的访问定位
一 Java对象的内存布局 在HotSpot虚拟机中,对象在内存中的布局分为3个区域 对象头(Header) Mark Word(在32bit和64bit虚拟机上长度分别为32bit和64bit)存储 ...