Hard Corners in Linecahrt

UI Components for JSF
Post Reply
DaBe1812
Posts: 17
Joined: 11 Jun 2021, 14:32

21 Jun 2021, 15:50

Hi,

I have a Primefaces 10.0.0 Linechart in my Application and I don't want this fancy polishing thing it does by default.
If I have the values 330, 350, 340 it does a tiny leap at the point after the 350 which looks like a 351, but there are no 351.

Is there a way to draw the lines from point to point in a hard way?
Like in the Radar Example?

And while I'm asking:
Is there or will there be a way to submit the data via JSON to the chart?
I've seen that many other frameworks for charts work with a JSON model, so it would be easier for anybody if I see in future, that the primfaces datachart possibilities are too limited, I can always switch to a chartframework with more possibilities.

Thanks for your reply.

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

21 Jun 2021, 16:36

PrimeFaces just uses Charts.js under the covers so for your line issue you might want to start there!

See: https://www.chartjs.org/

Anything you can do with Charts.js you can do with PF I would think. And at my company we use HighCharts for our charts in JSF and we send the JSON data directly from our app to the HighCharts charts. Just an FYI.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

DaBe1812
Posts: 17
Joined: 11 Jun 2021, 14:32

21 Jun 2021, 21:45

Hi,

thanks for the info. The option I'm searching for is the interpolation mode. But the option is in the js part of the chart.
How do I get to manipulate those? I don't have my system until tomorrow, but I'm curious now.

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

21 Jun 2021, 21:53

You mean this? https://www.chartjs.org/docs/latest/sam ... ation.html

Every one of those options should be available in the Java model backing your chart which gets turned into JSON values to configure the chart.

For example the value in the dataset cubicInterpolationMode: 'monotone', you can set right in the LineChartDataSet see here:

https://github.com/primefaces/primeface ... t.java#L52
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

DaBe1812
Posts: 17
Joined: 11 Jun 2021, 14:32

22 Jun 2021, 07:56

My fault. I had seen this option but didn't use it because of the String parameter. I think an ENUM would have done better. So you don't have to crawl the documentation to find which values are accepted.
By searching those accepted values I've found that the option I'm looking for is tension which can be set by giving an int value, which is much easier than searching for the correct string which does the magic.
So if any programmer is reading this. Try switching the cubicInterpolationMode to an ENUM.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 22 guests