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

  • Home
  • SEARCH
  • 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 8086089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:20:40+00:00 2026-06-05T18:20:40+00:00

My requirement is to use 2 tables and 1 chart to visualize my data

  • 0

My requirement is to use 2 tables and 1 chart to visualize my data set. Each data element contains its (unique) name and a bunch of data belonging to it. The first table will show the name of every dataset I have and the second table will show the data belonging to the dataset (row) being selected in the first table. The second table and the chart will show the same data and both belong to the dataset (row) being selected in the first table. I have achieved half of this behavior (linking both table) now by using the code below.

The problem I currently have now is: I can’t figure out the way to let the chart display the same data as the second table. My idea is to set the chart data in the ChangeListener, but the problem is the data model of the table is likely to not suitable with the chart. I have the readingData field as ObservableList in the TableDataModel class which is the type that the chart accept but it is an ObservableList of ReadingData not XYChart.Data. Is there any way I can use the XYChart.Data in the ReadData class?

My main class:

ObservableList<TableDataModel> tableData = FXCollections.observableArrayList();
// Other code omitted

/* Create the first table */
TableView<TableDataModel> myTable = new TableView<TableDataModel>();
TableColumn nameColumn = new TableColumn("Name");
nameColumn.setCellValueFactory(new PropertyValueFactory<TableDataModel, String>("name"));
// Other column omitted
myTable.setItems(tableData); 
myTable.getColumns().addAll(nameColumn, ...);

// When user select on any row update the second table items
myTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TableDataModel>()
    {
        @Override
        public void changed(ObservableValue<? extends TableDataModel> arg0, TableDataModel arg1, TableDataModel arg2) 
        {
            dataTable.setItems(arg2.readingData);
        }       
    });

/* The second table */
TableView<ReadData> dataTable = new TableView<ReadData>();
TableColumn valueColumn = new TableColumn("Value");
valueColumn.setCellValueFactory(new PropertyValueFactory<ReadData, Integer>("value"));
// Other column omitted
dataTable.setItems(null);
dataTable.getColumns().addAll(valueColumn, ...);

TableDataModel.java:

private final SimpleStringProperty name;
// Other SimpleStringProperty and its get and set method omitted

public final ObservableList<ReadData> readingData = FXCollections.observableArrayList();

ReadData.java:

// I use XYChart.Data here because I think that this might be useful when I want to show this on the chart
private SimpleObjectProperty<XYChart.Data<Integer, Integer>> value;
// Other property

// Provide this to make below line work
// valueColumn.setCellValueFactory(new PropertyValueFactory<ReadData, Integer>("value"));
public int getValue()
{
    return value.get().getYValue();
}
  • 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-05T18:20:42+00:00Added an answer on June 5, 2026 at 6:20 pm

    AFAIK you need to put your XYChart.Datas into the XYChart.Series first, then put that series into the chart by chart.getData().add(series). I think you can do this in your myTable selected change listener: Create there a new series (or modify existing, previously created and added one), add all your value.get() values from the ReadData. See the example of LineChart.

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

Sidebar

Related Questions

I have a requirement to store the data in encrypted form in database tables.
I have a requirement to use date picker in my applicaiton. I have lot
We have a simple requirement to use https for certain specific pages in a
Can anyone please tell me is there any special requirement to use either EXTERN
I have a requirement where I can use JS Fiddle dropdown to populate States
My current requirement is: I have to package my grails app and use teamcity
We have a requirement to log IP address information of all users who use
I'm using PowerShell v1.0 (It is a requirement that I cannot use 2.0) and
There is a requirement to load a list of items(ArrayList) from two different tables.
i want to create few Reports which picks data from few SQL tables, So

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.