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

Support set step value for Horizontal and Vertical Axis (x/y axis) #30

Closed
tsengvn opened this issue Dec 17, 2014 · 5 comments
Closed

Support set step value for Horizontal and Vertical Axis (x/y axis) #30

tsengvn opened this issue Dec 17, 2014 · 5 comments

Comments

@tsengvn
Copy link

tsengvn commented Dec 17, 2014

Hi, after deeply searching in this lib, I see you do not support for setting these values yet.

For example, I have a bunch of data of temperature of few months, and I want to draw a chart with step in Y axis is 5 degree, and step in X axis is each 7 days, what I want is the gridline always point to that step value.

I see some others chart lib have this feature, but I love this library (the style, animation, setup). Could you please add this in next release ?

Thanks.

@lecho
Copy link
Owner

lecho commented Dec 17, 2014

Hi, thanks for idea, I think it is relatively easy task so I will try to implement it in this week.

@tsengvn
Copy link
Author

tsengvn commented Dec 18, 2014

@lecho thanks, I'm looking forward for it

@lecho
Copy link
Owner

lecho commented Dec 18, 2014

I added three static methods in Axis class for axis generation:

/**
* Generates Axis with values from start to stop inclusive.
*/
public static Axis generateAxisFromRange(float start, float stop, float step);

/**
* Generates Axis with values from given list.
*/
public static Axis generateAxisFromCollection(List<Float> axisValues);

/**
* Generates Axis with values and labels from given lists, both lists must have the same size.
*/
public static Axis generateAxisFromCollection(List<Float> axisValues, List<String> axisValuesLabels);

@tsengvn
Copy link
Author

tsengvn commented Dec 19, 2014

Hi, tested, they worked well. Thanks you alot @lecho

@tsengvn tsengvn closed this as completed Dec 19, 2014
@fjpatil
Copy link

fjpatil commented May 3, 2016

Hi Lecho,

Let me know how to use the above mentioned static methods.

My Requirement: I want show the X axis values dynamically.
For Example: If my Total distance is 50KM, then I need to show 0,10,20,30,40,50 points in x axis.
Let me know how can I achive it.

Example Code for X axis Value Generation:

public class graph1 {

public static void main(String[] args) {
    // TODO Auto-generated method stub


    int slicing=5;
    int toal_distance=50;

    int sliced=toal_distance/5;
    System.out.println("========The Following Points to be displayed===========");
    for(int i=0;i<=5;i++){  
        int total_points=sliced*i;
        System.out.println("Total Points:"+total_points);

    }
}

}

Output:
========The Following Points to be displayed===========
Total Points:0
Total Points:10
Total Points:20
Total Points:30
Total Points:40
Total Points:50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants