Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8426423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:31:51+00:00 2026-06-10T04:31:51+00:00

I have a simple serie plotted on a XY Line Chart as below public

  • 0

I have a simple serie plotted on a XY Line Chart as below

public class SimpleXYLineChart extends Application {

@Override
public void start(Stage stage) {        
   stage.setTitle("Line plot");       

   final CategoryAxis xAxis = new CategoryAxis();
   final NumberAxis yAxis = new NumberAxis(1, 22, 0.5);

   yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis){
        @Override
    public String toString(Number object){
        return String.format("%7.2f", object);
    }
});
    final LineChart<String, Number>lineChart = new LineChart<String, Number>(xAxis, yAxis);

    lineChart.setCreateSymbols(false);
    lineChart.setAlternativeRowFillVisible(false);
    lineChart.setLegendVisible(false);
    lineChart.setTitle("LineChart");

    XYChart.Series series1 = new XYChart.Series();

    series1.getData().add(new XYChart.Data("Jan", 1));
    series1.getData().add(new XYChart.Data("Feb", 1.5));
    series1.getData().add(new XYChart.Data("Mar", 2));
    series1.getData().add(new XYChart.Data("Apr", 2.5));
    series1.getData().add(new XYChart.Data("May", 3));
    series1.getData().add(new XYChart.Data("Jun", 4));
    series1.getData().add(new XYChart.Data("Jul", 6));
    series1.getData().add(new XYChart.Data("Aug", 9));
    series1.getData().add(new XYChart.Data("Sep", 12));
    series1.getData().add(new XYChart.Data("Oct", 15));
    series1.getData().add(new XYChart.Data("Nov", 20));
    series1.getData().add(new XYChart.Data("Dec", 22));

    lineChart.getData().addAll(series1);        

    Scene scene = new Scene(new Group(), 800, 600);
    final VBox vbox = new VBox();
    final HBox hbox = new HBox();

    final Button remove = new Button("Remove Series");
    remove.setOnAction(new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent e) {
    if (!lineChart.getData().isEmpty()){ 
        System.out.println("Remove Series");
        lineChart.getData().remove((lineChart.getData().size()-1),0);
        }
    }
    });                

    hbox.setSpacing(10);
    hbox.getChildren().addAll(remove);

    vbox.getChildren().addAll(lineChart, hbox);
    hbox.setPadding(new Insets(10, 10, 10, 50));

    ((Group)scene.getRoot()).getChildren().add(vbox);
    stage.setScene(scene);
    stage.show();
}

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

}

I would like to remove the line plotted (by clicking on a button or by flagging a checkBox) and have the empty scene as below

enter image description here

I do not know how to remove the Line once plotted, haven’t found any .remove() or .delete() methods.

How to accomplish this?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:31:52+00:00Added an answer on June 10, 2026 at 4:31 am

    The problem is now solved, it seems it is a bug of JavaFX.

    I have solved by adding

    lineChart.setAnimated(false); and it all works fine. In JIRA Kenai it has been proposed as bug by commenting lineChart.setCreateSymbols(false);

    This also works but I think it is not the right answer, I can use .setCreateSymbols(false) or (true) having setted setAnimated(false);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple class with width and height member fields which define number of
I have a simple hello, world servlet application that I am just playing around
I have simple html page with 3 tabs: <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0
I have a simple Python server, import BaseHTTPServer import SimpleHTTPServer PORT = 8080 class
I have a simple chart, and I'd like the labels on the x-axis to
I have several data series plotted on a chart. This is logged data spanning
I have simple application from this tutorial: WCF 4 Getting Started Tutorial How can
I have simple python server and client. Server: import SocketServer import threading class MyTCPHandler(SocketServer.BaseRequestHandler):
I have a simple chart with two column series containing all months in the
I have some simple data stored in series of text files. Once line per

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.