LineChart change color dynamically
I have a StackPane with a line chart and a button: I would like to change the color by clicking on a button, that is, from white to black.
How to get there?
Thank you.
import java.util.Set; import javafx.application.Application; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.chart.CategoryAxis; import javafx.scene.chart.LineChart; import javafx.scene.chart.NumberAxis; import javafx.scene.chart.XYChart; import javafx.scene.control.Button; import javafx.scene.input.MouseEvent; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import static javafx.scene.paint.Color.RED; import javafx.stage.Stage; /** * * @author Alberto */ public class SimpleLineChart extends Application { @Override public void start(Stage primaryStage) { final NumberAxis xAxis = new NumberAxis(); final NumberAxis yAxis = new NumberAxis(); final LineChart<Number, Number> lineChart = new LineChart<>(xAxis, yAxis); XYChart.Series series = new XYChart.Series(); series.getData().add(new XYChart.Data(1, 100)); series.getData().add(new XYChart.Data(2, 200)); series.getData().add(new XYChart.Data(3, 50)); series.getData().add(new XYChart.Data(4, 75)); series.getData().add(new XYChart.Data(5, 110)); series.getData().add(new XYChart.Data(6, 300)); series.getData().add(new XYChart.Data(7, 111)); series.getData().add(new XYChart.Data(8, 30)); series.getData().add(new XYChart.Data(9, 75)); series.getData().add(new XYChart.Data(10, 55)); series.getData().add(new XYChart.Data(11, 225)); series.getData().add(new XYChart.Data(12, 99)); lineChart.setCreateSymbols(false); lineChart.setAlternativeColumnFillVisible(false); lineChart.setAlternativeRowFillVisible(false); lineChart.setLegendVisible(false); lineChart.setAnimated(false); lineChart.setVerticalZeroLineVisible(true); lineChart.setEffect(null); lineChart.getData().add(series); String color = "White"; String lineColor = "-fx-stroke: " + color + ";"; Set<Node> lineNode = lineChart.lookupAll(".series0"); for (final Node line : lineNode) { line.setStyle(lineColor); } StackPane sp = new StackPane(); Button btn = new Button(); btn.setText("test"); btn.setOnMousePressed(new EventHandler<MouseEvent>(){ @Override public void handle(MouseEvent me){ System.out.println("prova print"); } }); sp.getChildren().addAll(lineChart, btn); Scene scene = new Scene(sp, primaryStage.getWidth(), primaryStage.getHeight()); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
You already have the code to change the color of the line on the graph and the code to respond to the key (even if you use onAction, not onMousePressed). Just put it together:
btn.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { Set lineNode = lineChart.lookupAll(".series0"); for (final Node line : lineNode) { line.setStyle("-fx-stroke: black;"); } } });
Tags: Java
Similar Questions
-
How to change the background color dynamically on the page of the ofa
How to change the background color dynamically on the page of the ofa
Hello
Can you please let me know the dynamic conditions to change the background color?
Thank you
Vincent
-
Spinner widget will not change color
Hello
When I copy the entire view changes their color according to the dynamic thresholds spinners.
However, when I create this spinner by drag-and - drop, it do not change colors.
So my question is: How do this spinner change dynamically the color?
Best regards
Victor
This widget you drag from a dashboard? I just tested host cpu and it seems to be showing with colors
Can you please send some screenshots?
Golan
-
Change color to the overview and click
Hello
I have stock dynamics created symbols:
MouseEnter: change color when the mouse is on the button.
Mouseout/mouseouthandler(): to reset the color when the mouse is in progress to another button.
And I have problem on the click event, because I can't keep the blck color, which means clicking on the symbol, as I have a mouseout/mouseouthandler() that reset.
Here is the code:
$.getJSON ("menubuttons.json") (.the)
function (data) {}
$(données, fonction (index, item) {} .each)
var menubtn = stage.createChildSymbol ("templ-menubuttons", "Stage");
var menubtnelem = menubtn.getSymbolElement ();
menubtnelem.Attr ("id", item.title)
. CSS ({"background-size': 'contain', 'left': 1256," top":"95px","cursor":"pointeur"});})
menubtn.$("txt").html (Item.title);
MouseOver
menubtnelem.on ("mouseenter", function () {}
If ($(this) .attr ("id") = "Exit") {}
TweenLite.to (menubtn.$("imageholder"), 0.3, {backgroundColor: 'red', left: '2px'});
}
else {}
TweenLite.to (menubtn.$("imageholder"), 0.1, {backgroundColor: 'black', left: '2px'});
}
});
Mouseout/mouseouthandler()
menubtnelem.on ("mouseleave", function () {}
TweenLite.to (menubtn.$("imageholder"), 0.1, {backgroundColor: '#ffcf00', left: '0px'});
});
Click
menubtnelem.on ("mousedown", function () {}
With 'for' I'm trying to reset the color of all the yellow buttons and then one that is clicked to be black - but does not work - how is Possible to work?
for (var i = 0; i < data.length; i ++) {}
TweenLite.to (menubtn.$("imageholder"), 0.1, {backgroundColor: '#ffcf00', left: '0px'});
}
TweenLite.to (menubtn.$("imageholder"), 0.1, {backgroundColor: 'black', left: '2px'});
});
});
});
This may help - it's not created dynamically well symbols, but it can give you an idea how to solve your problem
-
Need to change color depends on the action
Hello
I use JDeveloeper 11.1.1.6
My scenario is that I order five link in my model Page.Click the each commandlink he will open a separate page.
After clicking the order link I want to change the color for her. But I'm not able to change color permanently, I tried below things,
1, af | CommandLink:hover it works only the mouse on the link command.
2, af | CommandLink: active it works when click the link after you open the page again, it is replaced by the old color.
3, af | CommandLink: selected it does not work.
4, af | CommandLink: visited it does not work.
Thank you...
Hello
commandLink lacks selectors selected and visited. You should use some EL to dynamically set the styleClass.
E.g. create two classes of style
af|commandLink.unvisited{ color: Green; } af|commandLink.visited{ color: Fuchsia; }
Set the commandLink styleClass property an EL and add a setPropertyListener to set a variable, click on the link.
Arun-
-
MY older iPad has changed color in the negative as opposed to a positive image. I could change this in black and white. How do I change back to color if settings > general > accessibility > invert colors does not solve the problem?
Hello
Go to accessibility disable grayscale settings.
See you soon
Brian
-
How can I find places to change color after I visited their?
the question says:
Looking for secure downloads that I have to click on more, then look elsewhere if
There is information that they are safe or not.In Internet Explorer, the link to the site would always change color after I had visited it.
It was great.
But with my newly installed Firefox Version 12 on my XP re-built, is not. This has caused me
wrongly visiting some of the same sites repeatedly. That's the bad news that I find
me starts to download from only to discover I already did and have to go to
uninstall programs (from Control Panel) to cancel it.Is it possible to make this browser tell me what I have already visited sites?
Thank you
TomHave you installed SP3 for Windows XP?
-
Text when scrolling of the page changes color
When the scrolling text change color until it stops moving
It was very good work. Play well.
Please report your last post as solved while others will know. -
visited links not changing color using the latest Firefox and windows 10
running windows 10 and the latest firefox freshly downloaded and installed.
have checked the visited_links is enabled, and I'm not running in private mode
I know it's only a problem of firefox like links change color using other browsersYou can check for problems with the database places.sqlite file in the Firefox profile folder.
-
Hello
My places.sqlite file size is 30 720 KB I reached the maximum size, is there a maximum size for this.
Suddenly the visited links don't change is no longer the font color, that I prepare for an exam, I need visited issues to change color, to follow up on issues that I ended. But if I delete a few days of history, then again once, most visited links change color and then it stops, it seems that something is getting full and not able to accommodate more? Why my visited links don't change color after a number of visits? I would like to make a back up of the file places.sqlite. So I tried everything to remove the profile, uninstalling reinstalling, creating a new profile, and then copy paste places.sqlite etc, but as mentioned after a few visits, visited links is no longer change color, if I delete a few days in history and then a few visits is again change color and then stop again, so what should I increase so that my quota of visited links is increased , I also tried tweaking about: config and there has been no result. Although I was not really convinced that _pages growing brower.history_max (don't remember the name, but I'm sure you get the idea) will help.
Seems that while my visited links change color, quota is met and only if I delete the history of a few days will I get some links most visited to change color. Can someone enlighten us? As mentioned that my places.sqlite file size is 30 720 KB so I think maybe this has something to do with it? Would be very grateful if someone could help me. Thank you.Sorry it is not looking good.
- Unlike bookmarks history is not saved in Firefox.
- There is a possibility using Windows.
- Sync is not expected to back up things until the synchronization server
- If places.sqlite does not sort itself you may have to re-create remove it. You will lose your history, but can still access indirectly IF you have saved a copy of the appropriate
- Different databases to try to create new profiles
- History
is rather less robust than bookmarks, you should deliberately somehow return it upward, but it's too late now - Earlier versions of Windows
This is really the last chance. Make sure you have some places.sqlite you saved. Always before and after any attempt to restore the backup. Windows must be able to provide a previous version. One of these versions may be usable as is; or can be used after a repair with housekeeping. Of course, this is not the latest version but it should help. - Sync is not a server backup service.
Sync is intended to save on another device, no backup is the fact that the second device then contains synchronized information. IIRC Sync development ceased, and the replacement when available may include a server backup option. - Recreate the database of bookmarks (including history)
Unfortunately, recess can only use saved bookmarks, there is no saved history to use. Once the database is re-created, it will continue to store the history but it loses the existing history. This time take steps to save on a regular basis.- The backup profile or at least the places.sqlite in this
Backup and restore Firefox profiles information
https://addons.Mozilla.org/en-us/Firefox/addon/FEBE/ - http://KB.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox#Rebuild_Places_database
- The backup profile or at least the places.sqlite in this
- Use the new profiles for database testing.
To simplify comparison of the results of the database different files create one or more new additional profiles. Then try to smash the places.sqlite file into the test profile with any other places.sqlite, you want to try. Allows you to directly compare the databases, without seeking to use sync and without changing the Firefox profile work unnecessarily. You can keep a reference profile of studies with the best of the profiles of any shows results of history; According to the best recreated or corrupted database is.- Use the Profile Manager to create and delete profiles Firefox
- CARE, do not rename or delete profiles created once or use anything other than empty folders when they are created. Don't nest in the other profiles. (At least until you know exactly how it behaves - post back if you never consider such actions)
-
"Title" bar continues to change color
The "Title" bar continues to change color. I don't mind above all this except that one color is green and I hate this color!
Is it possible to change this behavior?
Hello
I took a screenshot of my title bar in Firefox (Windows 7) and it marked with an arrow below. I think that is what changes the color on your machine?
In Windows 8, the color of the bars title in all applications is determined by the operating system not Firefox. This varies according to the theme of your operating system, but by default, it is a kind of 'average' colors sampled in your background. This replaces the Aero translucent look of Windows 7.
So detestable green color is most likely taken from your screen background image. To get rid of him the best bet is to change your background.
If you wish to override the settings for Windows, you can try a Firefox theme:
https://addons.Mozilla.org/en-us/Firefox/themes/
Or you can change the color of the title bar with the code to userChrome.css
Also, see this MozillaZine forum thread:
I hope this helps.
-
During navigation, links visited suddenly no longer change color browing is so difficult. I changed the suggestions "remember history" and other suggestions on posts but nothing has worked.
Hello
Many issues of the site can be caused by corrupted cookies or cache. To try to solve these problems, the first step is to clear cookies and cache.
Note: This will be you temporarily disconnect all sites, you're connected to.
To clear the cache and cookies to do the following:- Go to Firefox > history > clear recent history or (if no Firefox button is displayed) go to tools > clear recent history.
- Under "Time range to clear", select "all".
- Now, click the arrow next to details to toggle the active details list.
- In the list of details, see the Cache and Cookies and uncheck everything.
- Now click the clear now button.
More information can be found in article to clear your cache, history, and other personal information in Firefox .
This solve your problems? Please report to us!
Thank you.
______________________________________________________________________________
Hello
Try Firefox Safe mode to see if the problem goes away. Safe mode is a troubleshooting mode, which disables most of the modules.
(If you use it, switch to the default theme).
- You can open Firefox 4.0 + in Safe Mode holding the key SHIFT key when you open the desktop Firefox or shortcut in the start menu.
- Or open the Help menu and click on the restart with the disabled... modules menu item while Firefox is running.
Once you get the pop-up, simply select "" boot mode safe. "
If the issue is not present in Firefox Safe Mode, your problem is probably caused by an extension, and you need to understand that one. To do this, please follow article Troubleshooting extensions, themes and problems of hardware acceleration to resolve common Firefox problems .
To exit safe mode of Firefox, simply close Firefox and wait a few seconds before you open Firefox for normal use again.
When find you what is causing your problems, please let us know. It might help others who have the same problem.
Thank you.
-
My address bar has changed color in itself
I use the default theme in Mozilla and today the address bar has changed color from clear blue to windows blue, and the arrows and the "home" button are white instead of black. Since I haven't done anything intentionally and don't want it to appear like that, how can I reverse it? Curiously, the address bar when 'Help' is opened seems the usual way.
Hi Jscher,
Thank you for taking the time to look at my question. I managed to me after a little sorting (Finally, a little) tweaking autour. It seems that I unchecked the "always show the bar of tabs" under Options/tabs and made the section of bar any transparent address as the windows and buttons next to him white instead of black. After I checked it again, everything is back to normal.
-
When I open Firefox, a cursor appears in the search text box, but I have to click on it before I can enter text. When I click on the text box changes color (from teal'c white to a light color) and the slider and I type text is invisible.
Which may be caused by protection of typing"Comcast constant guard.
'Configure the Anti-keylogger settings'-> disable
-
How can I change/color/font size of tab independently controls?
How can I change/color/font size of tab independently controls?
When I change one of these attributes, it applies to all the controls on the tab...
Thanks for the help!
christophe69000 wrote:
How can I change the /color/font of the tab size controls independently?
When I change one of these attributes, it applies to all the controls on the tab...
Thanks for the help!
Tim has manipulated the colorful side of the tab of this Q.
If you ask about the text than the tabs labels, they are all the same.
If you really want and can settle their definition at run time, you can use
Advance > Layout tab > image only and use your own image to make it look like different sizes and fonts.
Maybe you are looking for
-
Information system: Ubuntu 11.10, running Firefox-trunk 12.0a1 (2012-01-21), cannot remove bookmarks.
-
Some Web sites I am using a very old version of Firefox and will not work. I use 9.0
This occurs even on some help pages for Firefox! Some plugins also refuse to load, citing an outdated version of FF. Some sites say that I use Firefox 1.0.7, which I've not used for years. The drop "about FF" confirms that I am under FF 9.0.1 Even th
-
Satellite M30X-129: CPU fan runs constantly after new XP Pro re - install
I just installed a new Samsung 120 GB drive in my M30X-129, an upgrade of the 60 GB IBM drive with what it was originally provided. Tried ghost XP Home installation of the old drive to the new - but it didn't work for some reason, installation, attac
-
Unable to activate Windows Vista reinstallation
I reinstalled Windows Vista Home Premium on my pc with the cd that I got when I bought my computer. After installing windows do not accept the activation code as I type. The code is typed on the COA at the back of my pc, I checked it several times an
-
HP Deskjet 1051: HP Deskjet 1051 set preferences
I don't know how to set my preferences for my HP Deskjet 1051. I want to print on both sides of the paper, and I don't see where it says that in the settings. Can someone tell me please how to do this? Thank you.