Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChartJs: CartesianAxis add Labels attribute #4112

Closed
markusg80 opened this issue Oct 3, 2018 · 3 comments
Closed

ChartJs: CartesianAxis add Labels attribute #4112

markusg80 opened this issue Oct 3, 2018 · 3 comments
Labels
enhancement Additional functionality to current component
Milestone

Comments

@markusg80
Copy link

IMPORTANT

  • !!! If you open an issue, fill every item. Otherwise the issue might be closed as invalid. !!!

  • Please use the naming convention for the title:
    ${component}: ${title}
    Example:
    SelectOneMenu: Converter not called

  • Before you open an issue, test it with the current/newest version.

  • Try to find an explanation to your problem by yourself, by simply debugging. This will help us to solve your issue 10x faster

  • Clone this repository https://github.com/primefaces/primefaces-test.git in order to reproduce your problem, you'll have better chance to receive an answer and a solution.

  • Otherwise the example must be as small and simple as possible! It must be runnable without any other dependencies (like Spring,..., or project/company internal classes)!

  • Feel free to provide a PR (Primefaces is an open-source project, any fixes or improvements are welcome.)

1) Environment

  • PrimeFaces version: 6.2.9
  • Does it work on the newest released PrimeFaces version? No Version? 6.2.9
  • Does it work on the newest sources in GitHub? (Build by source -> not tested because no changes https://github.com/primefaces/primefaces/wiki/Building-From-Source)
  • Application server + version: Payara 5.182
  • Affected browsers: all

2) Expected behavior

it should be possible to set Labels not only global but also per Axis.

3) Actual behavior

Actual it is only possible to set labels global.

4) Steps to reproduce

..

5) Sample XHTML

..

6) Sample bean

..

7) Expected ChartsJs Config content:

options: {
        scales: {
            xAxes: [{
                type: 'category',
                labels: ['January', 'February', 'March', 'April', 'May', 'June'],
            }]
        }
    }

8) ChartJs Website Link:

https://www.chartjs.org/docs/latest/axes/cartesian/category.html

@tandraschko tandraschko added the enhancement Additional functionality to current component label Oct 3, 2018
@melloware
Copy link
Member

melloware commented Oct 9, 2018

OK it looks like this is already possible. Here is the Javadoc of CartesianAxes.

/**
 * If global configuration is used, labels are drawn from one of the label arrays 
  *   included in the chart data.
 * 
 * If only data.labels is defined, this will be used. 
 *    If data.xLabels is defined and the axis is horizontal, this will be used.
 * 
 * Similarly, if data.yLabels is defined and the axis is vertical, this property will be used.
 * 
 * Using both xLabels and yLabels together can create a chart that uses strings 
 * for both the X and Y axes. CartesianCategoryAxes extends {@link CartesianAxes}.
 */

So it looks like it will use the Global config or you can use data.labels or data.xLabels. Can you give it a shot?

@markusg80
Copy link
Author

@melloware : The Javadoc is from CartesianCategoryAxes. But there i cant see any parameter for example:

setLabels(List<String> labels)

I only can see inside CartesianCategoryTicks a method in this direction. But it seeams that it has no effect.

@melloware
Copy link
Member

melloware commented Oct 9, 2018

@mertsincan can weigh in here he wrote the javadoc that says that so I was assuming it is possible. I agree I don't see any way to set this either. I can definitely add it.

tandraschko added a commit that referenced this issue Nov 16, 2018
Fix #4112: ChartsJS add labels override to Cartesian Axes.
@tandraschko tandraschko added this to the 6.3 milestone Nov 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Additional functionality to current component
Projects
None yet
Development

No branches or pull requests

3 participants