设置数值显示

Posted liyanyan665

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了设置数值显示相关的知识,希望对你有一定的参考价值。


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(http://www.my516.com/heimitao/)).getChildren().addAll(chart,caption);
stage.setScene(scene);
stage.show();


public static void main(String[] args)
launch(args);


--------------------- 

以上是关于设置数值显示的主要内容,如果未能解决你的问题,请参考以下文章

设置数值显示

excel怎么将数值展示为“万”“亿”的单位?

JavaFX Chart设置数值显示

JavaFX Chart设置数值显示

python中使用squarify包可视化treemap图:treemap将分层数据显示为一组嵌套矩形自定义设置每一个数据格的颜色添加数值数值标签自定义设置边框的色彩自定义设置边框线条的粗细

python中使用squarify包可视化treemap图:treemap将分层数据显示为一组嵌套矩形自定义设置每一个数据格的颜色添加数值数值标签自定义设置边框的色彩