- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to make the labels of a JavaFX Pie chart invisible?
In the pie chart, we represent the data values as slices of a circle. Each slice is differentiated from other (typically by color). In JavaFX, you can create a pie chart by instantiating the javafx.scene.chart.PieChart class.
Making Labels Invisible
Each slice is associated with a label. (name of the slice as value) By default, these labels are visible. This class has a property named labels visible specifying whether to display the labels in the pie chart or not. You can set the value to this property using the setLabelsVisible() method.
To make the labels of the current pie chart invisible you need to invoke this method by passing the boolean value false as a parameter.
Example
import javafx.application.Application; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.scene.chart.PieChart; import javafx.scene.layout.StackPane; public class PieChartExample extends Application { public void start(Stage stage) { //Creating a Pie chart PieChart pieChart = new PieChart(); //Setting data ObservableList<PieChart.Data> data = FXCollections.observableArrayList( new PieChart.Data("Work", 10), new PieChart.Data("Chores", 2), new PieChart.Data("Sleep", 8), new PieChart.Data("Others", 4) ); pieChart.setData(data); //Setting the other properties pieChart.setTitle("Activities"); pieChart.setClockwise(true); pieChart.setLabelLineLength(10); pieChart.setLabelsVisible(true); pieChart.setStartAngle(360); //Creating a stack pane to hold the pie chart StackPane pane = new StackPane(pieChart); //Setting the Scene Scene scene = new Scene(pane, 600, 350); stage.setTitle("Pie chart"); stage.setScene(scene); stage.show(); } public static void main(String args[]){ launch(args); } }
Output
- Related Articles
- How to create a Pie chart using JavaFX?
- How to avoid overlapping of labels & autopct in a Matplotlib pie chart?
- Conditional removal of labels in Matplotlib pie chart
- How to create pie chart in base R with labels?
- How to create/save the image of a JavaFX pie chart without actually showing the window?
- Explain: How to draw Pie chart?
- How to find Central angle of the part of a pie chart?
- How to plot pie-chart with a single pie highlighted with Python Matplotlib?
- How to make a Tkinter widget invisible?
- How to add a legend to a Matplotlib pie chart?
- ReactJS: How to Create a Pie Chart using Recharts?
- How to plot a nested pie chart in Matplotlib?
- How to make a circle invisible using FabricJS?
- How to make a Rectangle invisible using FabricJS?
- How to make a Triangle invisible using FabricJS?

Advertisements