StackedBarChart not updated in FXML app.

The stacked bar chart does not not with the class FXML and controller. Please help me. My code is given below

Controller class

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package javafxapplication27;

import java.net.URL;
import java.util.Arrays;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.chart.BarChart;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.StackedBarChart;
import javafx.scene.chart.XYChart;
import javafx.scene.control.Label;
import javafx.stage.Stage;


public class FXMLDocumentController implements Initializable {
   
    @FXML
    private Label label;
   
    @FXML
    private StackedBarChart stackChart;
   
    @FXML
    private BarChart barChart;
   
    @FXML
    private void handleButtonAction(ActionEvent event) {
        System.out.println("You clicked me!");
        label.setText("Hello World!");
       
    final  String austria   = "Austria";
    final  String brazil    = "Brazil";
    final  String france    = "France";
    final  String italy     = "Italy";
    final  String usa       = "USA";
    final CategoryAxis xAxis = new CategoryAxis();
    final NumberAxis yAxis = new NumberAxis();
    ObservableList<XYChart.Series<String, Number>> barChartData = FXCollections.observableArrayList();
    ObservableList<XYChart.Series<String, Number>> stackBarChartData = FXCollections.observableArrayList();
    final BarChart.Series<String, Number> series1 =  new BarChart.Series<String, Number>();
    final StackedBarChart.Series<String, Number> series2 =   new StackedBarChart.Series<String, Number>();
    final StackedBarChart.Series<String, Number> series3 =   new StackedBarChart.Series<String, Number>();
        series1.setName("2001");
        series1.getData().add(new XYChart.Data<String, Number>(austria, 25601.34));
        series1.getData().add(new XYChart.Data<String, Number>(brazil, 20148.82));
        series1.getData().add(new XYChart.Data<String, Number>(france, 10000));
        series1.getData().add(new XYChart.Data<String, Number>(italy, 35407.15));
        series1.getData().add(new XYChart.Data<String, Number>(usa, 12000));
        series2.setName("2004");
        series2.getData().add(new XYChart.Data<String, Number>(austria, 57401.85));
        series2.getData().add(new XYChart.Data<String, Number>(brazil, 41941.19));
        series2.getData().add(new XYChart.Data<String, Number>(france, 45263.37));
        series2.getData().add(new XYChart.Data<String, Number>(italy, 117320.16));
        series2.getData().add(new XYChart.Data<String, Number>(usa, 14845.27));
        series3.setName("2005");
        series3.getData().add(new XYChart.Data<String, Number>(austria, 45000.65));
        series3.getData().add(new XYChart.Data<String, Number>(brazil, 44835.76));
        series3.getData().add(new XYChart.Data<String, Number>(france, 18722.18));
        series3.getData().add(new XYChart.Data<String, Number>(italy, 17557.31));
        series3.getData().add(new XYChart.Data<String, Number>(usa, 92633.68));    
      
        barChartData.add(series1);
        stackBarChartData.addAll(series2,series3);
        stackChart.setData(stackBarChartData);
        barChart.setData(barChartData);
    }
   
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }   
   
}

File FXML

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.chart.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="487.0" prefWidth="610.0" xmlns:fx="http://javafx.com/fxml" fx:controller="javafxapplication27.FXMLDocumentController">
  <children>
    <Button fx:id="button" layoutX="14.0" layoutY="14.0" onAction="#handleButtonAction" text="Click Me!" />
    <Label fx:id="label" layoutX="126.0" layoutY="120.0" minHeight="16.0" minWidth="69.0" />
    <StackedBarChart fx:id="stackChart" layoutX="20.0" layoutY="33.0" prefHeight="223.0" prefWidth="576.0">
      <xAxis>
        <CategoryAxis side="BOTTOM" />
      </xAxis>
      <yAxis>
        <NumberAxis side="LEFT" />
      </yAxis>
    </StackedBarChart>
    <BarChart fx:id="barChart" layoutX="30.0" layoutY="264.0" prefHeight="216.0" prefWidth="552.0">
      <xAxis>
        <CategoryAxis side="BOTTOM" />
      </xAxis>
      <yAxis>
        <NumberAxis side="LEFT" />
      </yAxis>
    </BarChart>
  </children>
</AnchorPane>

When I run this program, only the filling barchart, histogram not displas all graph.

Output window

Screenshot from 2014-08-14 14:30:41.png

Please help me solve this problem

This is not a problem with FXML but with the axis lack of categories.

Article of Oracle bar graph, you need to do:

((CategoryAxis)stackChart.getXAxis()).setCategories(FXCollections.observableArrayList(Arrays.asList(austria, brazil, france, italy, usa)));

Or more simply:

((CategoryAxis)stackChart.getXAxis()).getCategories().setAll(austria, brazil, france, italy, usa);

For me, it solves the problem.

Tags: Java

Similar Questions

  • My application is not updated in the app store. Brand is not move stop I try

    Please, I want to update my application do not move all the app s

    What have you tried? for example

    -logging out and back to your account on the phone,

    -disconnect and reconnect to your network

    -close the App Store application via the task bar of the phone,

    -soft-reset/reboot the phone

  • New laptop will be not updated of the apps (0 x 80070490)

    Hello

    My new laptop seems unable to update or install apps on the Store Windows, and I got it 2 days.
    Applications appear as "pending" and will later say I need to "restart the PC to complete the installation of an update" - I've now lost count of how many times I rebooted.
    When you run the "convenience store" it says it has fixed the problems listed:
    -Error in database that can be updated Windows found 0 x 80070490 (fixed)
    -Components Windows Update must be repaired (fixed)
    However, the same thing happens whenever I restart the pc, and when I run again convenience store, he finds the same problems.
    Does anyone know how to fix this?
    Thank you very much

    Maybe a little late, but what helped me was change C:\Windows\SoftwareDistribution to .old

  • Could not update 'in built Apps ".

    I have an internet connection broadband and I have updated all the updates that are provided by microsoft. and after that, I tried to update all the apps 'built-in' such as video, music, etc. (cause they have stopped working and asked me to update when I tried to use'em. given that I didn't have a good internet connection, I didn't do and kept them inactive for more than 2 weeks). I could update camera, photos and sky player. The rest isn't to be downloaded. It displays 'pending' and nothing happens. How can I get rid of this problem and I am sure that there is nothing wrong with my internet connection. Help, please

    From the desk of
    Press the Windows key + R
    Type WSReset.exe and press OK

    http://Windows.Microsoft.com/en-us/Windows-8/what-troubleshoot-problems-app

    Method 3:


    You can try to run Apps Troubleshooter

    Download and run the troubleshooter modern UI App and check.

    http://download.Microsoft.com/download/F/2/4/F24D0C03-4181-4E5B-A23B-5C3A6B5974E3/apps.diagcab

    Please use the following links as reference:

    http://Windows.Microsoft.com/en-us/Windows-8/what-troubleshoot-problems-app

  • Installed Apps not updated in the App Store

    Updating macOS version 10.12 on MacBook Pro retina Sierra updates (end 2013) available in the App Store. When you try to update, receive the message "Apple Media Services terms and Conditions have changed. " ... To continue, you must read and agree to the new terms. I accept conditions and access updates. When you click on the app for the update, the same message again. Through accepting the terms and Conditions again and repeat the same cycle over and over again. May not know what is the problem?

    Start Safe Mode removes the system caches that can help.

    Follow these steps to start in safe mode.

    1. Start or restart your Mac.
    2. As soon as you hear the startup tone, hold down the SHIFT key.
    3. Release the SHIFT key when you see the logo Apple appears on the screen.

    After the Apple logo appears, this may take longer than usual to reach the login screen or your office. This is because your Mac performs a check of directory of your drive to boot in safe mode.

    To leave safe mode, restart your computer without pressing any keys during startup.

    Then try to update applications.

  • Adobe CC is not updated nor showing apps

    Today, I discovered that my latest version of CC is 27/07/2015 2.2.0.129.

    When I connect, I see not all apps in CC only with a wheel turning

    Adobe CC 2.jpg

    Then I registered on en signed again, and CC said I have an update and start the update. But nothing happening that it

    Adobe CC.jpg

    I don't know how to go further with this.

    John

    Use a browser that allows cookies and pop-up windows, please contact adobe for hourly pst support by clicking here and, when it is available, click "still need help," http://helpx.adobe.com/x-productkb/global/service-ccm.html

  • Can not update creative cloud apps.

    When I start my computer tells me updates available, but when he reached 2%, it shows red connect to the server and that is where it stops, nothing else happens. I'm running a Windows 7 computer and this happened to me several months ago. I was able to solve it with substantial assistance but not record a history of what has been done. I was told to delete and reinstall CC but this proved be more than an outright deletion.

    Check your hosts file.

    help for that and other adobe.com sure common connection problems read, http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html

  • The revel on my iPhone and iPad app is not accessible. Needs, update but will not update. Message is Try Again. Should I remove each device and reinstall? I would lose all the photos?

    WWhat can be done when Revel app on iPhone and iPad will not update? Delete apps and reinstall? Photos will be lost?

    Please see the post below updates on the issue of the revel facilities:

    Problem installing Adobe Revel 2.3.2

  • Why creative Cloud will not update on my laptop?

    When I open the creative cloud application, I have an update message is available and have the choice of update or to immediately stop the application. So I choose the update and in the Middle, receive a message from a different version of the creative cloud is running and must be completed to continue. However, it seems according to my icons and the Task Manager, only the installer runs. Yet, when I hit retry, nothing happens, and of course when I close the installer, everything closes. If I choose do not update, the CC app leave immediately, so for the moment it is completely non-functional.

    Is this a bug? Any suggestions?

    Abhijit salvation,

    I actually have the CC desktop application installed for a while. I just chatted with adobe technology, and he remarked, I had to go not only to the Task Manager, which I had already checked, but I also had to "show processes for all users" in order to find the CreativeCloud.exe * 32 which was the addition of CC version that was running and terminate.

    I must say, even if the technology was very polite, well informed and correct, it always irritates me how I feel, I have spend at least an hour a week on various issues like this creative cloud involving dealing with which can take me away from my work. I feel that I have to pay 50 $par month of beta-test software and take more time than I should have to deal with him. I think that perhaps more thorough testing is in order, or at least the recognition that the software is beta and let those who want to test, test, before it was dismissed just as if she was not beta.

  • My App Store did not work... When I try to update or install apps it does not work. Can you please fix this?

    Can you please fix the problem? Appstore cannot update or install apps... App Store not worked yesterday.

    We cannot solve a problem for you, but we can make suggestions of troubleshooting...

    Have you tried restarting your iPhone yet?

    1. Press and hold the sleep/wake button until the Red slider appears.
    2. Drag the slider to turn off your device completely off.
    3. Once the device turns off, press and hold the sleep/wake button again until you see the Apple logo.
  • The Messenger app will be not updated. Stuck on "Waiting."... "and the logo in grey. How can I fix this or return to the previous edition that worked?

    I received a prompt on my Ipod touch 5th generation yesterday, that there is a new update of the Messenger application. So I tried to update, however, the app is now stuck on the phase "Waiting."... "and the logo has been disabled. I still get notifications of new messages from the app, but I can't open. I tried to remove and then reinstall the application but the application did not and the app store think that I always opened it. How can I fix this or return to the previous edition that worked?

    Thank you in advance!

    Hello cfossum,

    Looks like you have problems with a third party on your iPod touch app, since the Messages belongs to iOS and you would receive separate not quickly update.

    The resources below will provide some troubleshooting steps for the problem you are having with the Messenger application.

    If an application you have installed unexpectedly closes, unresponsive, or does not open

    Take care.

  • The apps of Podcasts and find my friends does not update in iTunes

    The apps of Podcasts and find my friends does not update in iTunes.

    Applications appear in iTunes as with updates, but iTunes says "Podcasts is available only on iOS.

    I usually never use the app store on my phone and always update of applications via iTunes.

    Please fix this bug.

    You see these warnings by mistake. These applications can only be updated as part of updating to iOS without iTunes.

    You can ignore the warnings or remove the two apps to iTunes. This will not affect these applications on your iDevices.

  • Recently changed my Apple ID and now does not update apps

    I know that this happens to a lot of people and I searched the forums to find someone with the same problem who received the help of the community, but I have not found the post again so I decided to make my own.

    I had to change my apple ID because I got hacked. I don't have a new brand, I changed the email of the Apple ID, I already had. Everything seems fine, except that now does not update my apps on my iPod touch. I know this is because applications are no longer associated with the correct email and this is most likely the problem, but I'm not sure how to fix it.

    I made sure that I disconnected all my accounts (Apple store/iCloud/choice of account) on all my products apple (2 pounds of Mac and iPod) and has signed all the accounts mentioned previously with new Apple ID. No progress, which makes sense because the applications are linked right old Apple ID?

    So I deleted all my apps thinking I could redownload them. But they are associated with my iCloud it seems... so I tried to disable my iCloud on the iPod so that apps would show 'get' instead of 'download' in the Apple store (basically doing my iPod are realizing that it is a new Apple ID and I want to get the apps for "the first time"), but that no longer works.

    My last attempt was to remove an application on my Macbook, in the hope that "get" appears instead of "Download", but in a way that no longer works. I even connected to my iCloud with my new apple ID and none of the apps show on my iCloud. I'm quite confused. Someone at - it insight, ideas, or suggestions on how I might remedy other that go into an Apple store or do a factory reset on the iPod? Does anyone know if the factory reset would even work?

    Thank you!

    Of the information your provided, it seems that your created a new ID ranting as update the e-mail address for the original code.

    What did you do?

    Say this, you:

    Change your Apple - Apple Support ID

  • updates to iOS app show filled in the App Store but not apps actually updates

    There's something strange happening very recently with the app on my iPhone and iPad updates. Two of them are on the latest version of iOS (9.3.2). Apps would show that they are updated in the App Store, but they are actually not updated. This is the second time that this has happened and I am writing this message I try to solve problems. The first time it happened I had to remove the app and reinstall it. I'm going...

    1. I opened the App Store.
    2. Press update of all.
    3. I saw the download of updates and the finish.
    4. Open the button is appeared next to the application in the list of updates.

    The problem:

    1. Applications will not open by typing open the button next to them.
    2. I went to the home screen and the applications in question are darker color.
    3. I typed on these applications and they changed the "Loading"... "which means that they have not actually completed the setting to.
    4. The apps started to download it again.
    5. Applications is is stuck in download.
    6. I turned both devices power off, then turn it back on.
    7. On my iPad: apps started to redownload and completed. Applications are now open.
    8. On my iPhone: applications made "Waiting."... "then"Loading"... "and have not finished downloading.

    I'll post this and continue to wait for applications to download. I don't want to remove them and reinstall because they are multiple applications I would you connect again and synchronizes again that I find annoying. I'll try to update this post after the completed download apps, if they end up actually or if I'll end up resettlement.

    I posted this at 09:00. It is now 16:45, and only one of the applications is completely downloaded. It is not a problem with the internet, because I can stream movies very well. Another application that has been "updated" this morning went dark. I typed it and it has been "Waiting."... "for 10 minutes now.

  • Podcast app is not updating from iTunes

    Podcast app is not updating from iTunes

    Saying "Podcast is available on IOS - only to get Podcasts search app store for your IOS device.

    I use 3 (new ipad, IOS 9.3.2) iPad and iTunes for windows 12.4.1.6

    How to solve it? Thank you

    Ignore the update, Podcasts is built into iOS 9, you can't update built-in apps on your iPad (except through iOS updates). (It's show due to: remove the built-in apps from the home screen on your device iOS with iOS beta 10 - Apple Support)

    If you have not all devices running older versions of iOS (or if you do, if you do not use Podcasts on them), you could remove the application from the My Apps from your iTunes library section so that the "update" to disappear.

Maybe you are looking for