Jump to content
JChartFX Community
  • 0

Null last series leaves label off of legend


ChrisS

Question

Hi,

 

We have come into an issue with jChartFX in displaying multi-series legend labels in a chart.  In this case we are using a line chart.  The problem is when the last series has null data (i.e. no data points), but there is a series label, that series label does not show on the legend.

 

If there null series in the middle (like series 3 of 5) that label IS shown in the legend. 

 

The only workaround is to create a datapoint for the last series, then the legend label shows.

 

Example attached. 

In the example attached there are 5 series.  Series #3 and series #5 are null.  You will see that series' 3 label (i.e. "Category3") is shown in the legend, but series' 5 label is not shown in the legend (i.e. "Category5").

 

Even though the data has no values, it is important to know that the series was included in the chart; it's just that there was no data.

 

Chris

jChartFX - Issue with null last series.html

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

The misunderstanding is that trying to get a specific series (last loop) or setting its text does not create a series so the chart is not aware of the existence of such series.

 

One way to fix this would be for you to tell us the size of your data set before you pass the values, i.e. before you call chartdata.setItem

 

chartdata.setPoints(2);

chartdata.setSeries(5);
 
This will also result in better performance as we can preallocate the right size of buffers and not have to "grow" them as needed when you pass the data without telling us the size of the data set.
 
Also this means you do not need the try/catch in the loop that sets the series labels, you needed that because the last series does not exist so when you say getSeries().getItem(4) it was probably failing or returning null
 
JuanC
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...