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 7664531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:19:47+00:00 2026-05-31T14:19:47+00:00

In our JavaFX project we need a line chart. I can easy stylize the

  • 0

In our JavaFX project we need a line chart. I can easy stylize the whole chart and series using CSS, but content of our chart can change dynamically:

  1. number of series and their displaying order depends on user actions and his data. Each series represents a concrete data category and the each category has its own style, eg. category A is shown as a dotted line and category B is shown as a dashed line. The chart can contain 0 or more series for each category,

  2. style of series depends on data values too, eg. series line over the average is red, and below is blue.

How to do it in JavaFX?

  • 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-05-31T14:19:48+00:00Added an answer on May 31, 2026 at 2:19 pm

    Update 2024

    I would not advise using the lookup function for styling anymore.

    Instead, JavaFX (since 17) now supports data URIs for stylesheets.

    I think that the data URIs are a better solution.

    You can build a CSS stylesheet string in code to dynamically completely customize most style aspects of the chart by applying the string as a data URI. This allows more robust styling using a language designed for that purpose.

    To find the default chart styles so you can update them with your own (including overriding colors) in the chart and legend, review the standard JavaFX style sheet named modena.css which can be found in the javafx-controls jar of your JavaFX distribution.

    If, for whatever reason either the static CSS stylesheet approach or the dynamic data uri CSS styling technique does not work for you, the lookup technique proposed in the original answer can still be applied.

    Original Answer

    1. number of series and their displaying order depends on user actions and his data.

    The number of series displayed and the display order can be modified by changing the ObservableList of series which you passed to the chart’s setData() call. As the chart listens for changes to the list, as the backing list changes, the chart is automatically updated to reflect the changes.

    each category has its own style, eg. category A is shown as a dotted line and category B is shown as a dashed line.

    This can done by determining which series in the chart is in which category, looking up all nodes related to the series via the node lookupAll(cssStyleSelector) function and applying a new custom style to the series which matches the style for the category. Dotted and dashed lines can be styled via css by setting the -fx-stroke-dash-array css property. Alternately, rather than a lookup you can dynamically change the css styleclass assigned to nodes via modifying the ObservableList returned from getStyleClass().

    style of series depends on data values too, eg. series line over the average is red, and below is blue.

    This is similar to how the dotted and dashed lines are displayed, but instead the color of the lines are modifed by the -fx-stroke css property and the modification depends on the average values calculated for the series.

    To demonstrate the above points, I created a sample solution for this question here: https://gist.github.com/2129306

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

Sidebar

Related Questions

We are using GroovyFX in our project, to build our user interfaces. It already
I need the javax.comm library when building my project on our Hudson build server
I'm trying to compile our jsp files using jspc within gradle but am getting
We are using JavaFX's TextArea control in our application, and trying to integrate it
We are using OpenSessionInViewFilter in our JSF 1.1 web application which is using Spring
We are using Primefaces 3M4 and one of our pages has a p:dataTable which
We use composite components inside other components in our project. Everything works just fine
I am working on a project that is using a Java service to encrypt
Im getting in instantiation exception inf our Myfaces 2 application. But the exception printing
I'm using this code to download the timeline page from our local Trac system:

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.