Line chart - x-axis labels
Line chart - x-axis labels
Hi,
I use FastLine for creating line charts.
Suppose I have to add (1,2,3,4,5, [Missing]) on the X-axis, then how would I do that ? I normally use add(double, double), but now I have a special case wherein I have to add a String value to the X-axis along with some double values. I tried using add(double, String) along with add(double, double). But I am getting exceptions when I call the former one. So is it like, we can not have two data types on the same Axis ? Or am I calling some wrong API ?
Thanks,
Varun
I use FastLine for creating line charts.
Suppose I have to add (1,2,3,4,5, [Missing]) on the X-axis, then how would I do that ? I normally use add(double, double), but now I have a special case wherein I have to add a String value to the X-axis along with some double values. I tried using add(double, String) along with add(double, double). But I am getting exceptions when I call the former one. So is it like, we can not have two data types on the same Axis ? Or am I calling some wrong API ?
Thanks,
Varun
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Varun,
This is a bug (TJ71013286). Calling add method with a string parameter raises an exception. I've added the issue to the defect list to be fixed ASAP.
In the meantime you can use custom axis labels as shown in the Axes\Labels\Custom Labels II example at TeeChart.Features.jar.
This is a bug (TJ71013286). Calling add method with a string parameter raises an exception. I've added the issue to the defect list to be fixed ASAP.
In the meantime you can use custom axis labels as shown in the Axes\Labels\Custom Labels II example at TeeChart.Features.jar.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Varun,
As an update, I've just fixed this issue for the next TeeChart for Java release. When it comes out you'll be able to do this:
I recommend you to be aware at this forum or subscribe to our RSS news feed for new release announcements.
Thanks in advance.
As an update, I've just fixed this issue for the next TeeChart for Java release. When it comes out you'll be able to do this:
Code: Select all
Random y = new Random();
for (int i=0; i<5; i++) {
line1.add(i,y.nextDouble(), String.valueOf(i));
}
line1.add("Missing");
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi,
I do not know whether you have understood my question or not. Maybe we are talking about the same thing. I just want to confirm my view points.
I have an X-axis and a Y-Axis.
X- axis - represents integer or continuous variable. (1,2,3,4,...)
Y -axis - represents a double variable.
So I use line.add(double, double) to add points to a line series.
But in some special cases, I have to represent a null value on the x-axis for the same series. So my x- axis labels would look like(1,2,3,4,....,[Missing]).
So when I see a [Missing] in my data, I try to use line.add(double, "[Missing]") instead of line.add(double, double). This time I am getting some exceptions which I have mentioned in my first mail. I suppose that, two different calls to add points to the same line series causes these exceptions. Am I doing something wrong here ? Or is it a special case for me ?
Thanks,
Varun
I do not know whether you have understood my question or not. Maybe we are talking about the same thing. I just want to confirm my view points.
I have an X-axis and a Y-Axis.
X- axis - represents integer or continuous variable. (1,2,3,4,...)
Y -axis - represents a double variable.
So I use line.add(double, double) to add points to a line series.
But in some special cases, I have to represent a null value on the x-axis for the same series. So my x- axis labels would look like(1,2,3,4,....,[Missing]).
So when I see a [Missing] in my data, I try to use line.add(double, "[Missing]") instead of line.add(double, double). This time I am getting some exceptions which I have mentioned in my first mail. I suppose that, two different calls to add points to the same line series causes these exceptions. Am I doing something wrong here ? Or is it a special case for me ?
Thanks,
Varun
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Varun,
Thanks for the information. I think we are speaking about the same issue. I did some tests with what you reported and I found that any add method override that uses a string parameter caused an exception. That's what I fixed yesterday and the bug fix will be included in the next maintenance release.
Can you confirm that what's causing exceptions at your end is using add method with a string?
Thanks in advance.
Thanks for the information. I think we are speaking about the same issue. I did some tests with what you reported and I found that any add method override that uses a string parameter caused an exception. That's what I fixed yesterday and the bug fix will be included in the next maintenance release.
Can you confirm that what's causing exceptions at your end is using add method with a string?
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Varun,
Thanks for the information.
The version you are using is the last publically available. When a new maintenance release is posted it will be announced in this forum. You may also be interested in subscribing to our RSS news feed for automatic announcements.
In the meantime, I'll send you StringList.java with the fix to this issue, you can backup and replace current version for the new one and compile your projects from TeeChart's sources.
Thanks for the information.
The version you are using is the last publically available. When a new maintenance release is posted it will be announced in this forum. You may also be interested in subscribing to our RSS news feed for automatic announcements.
In the meantime, I'll send you StringList.java with the fix to this issue, you can backup and replace current version for the new one and compile your projects from TeeChart's sources.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Varun,
Sure, just sent it.
Sure, just sent it.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi,
Thanks for sending the file. It could eliminate the exception but it did not add the point to the line series. I do not see the added point in the chart.
The code below explains what I was trying to do,
try {
Double xAxisPoint = Double.parseDouble(xLabelItem);
series[count].add(xAxisPoint, yData.doubleValue());
} catch (NumberFormatException ne) {
series[count].add(yData.doubleValue(),xLabelItem);
}
I have 3 xvalues (1,15 and [Missing]) and corresponding yvalues. Chart displays only 1 and 15.
Thanks,
Varun
Thanks for sending the file. It could eliminate the exception but it did not add the point to the line series. I do not see the added point in the chart.
The code below explains what I was trying to do,
try {
Double xAxisPoint = Double.parseDouble(xLabelItem);
series[count].add(xAxisPoint, yData.doubleValue());
} catch (NumberFormatException ne) {
series[count].add(yData.doubleValue(),xLabelItem);
}
I have 3 xvalues (1,15 and [Missing]) and corresponding yvalues. Chart displays only 1 and 15.
Thanks,
Varun
Hello Varun,
Sorry for the delay. Personnel changes for holidays caused us to need to re-tread the steps on this issue. Re-checking this, rolling back to before the fix you're testing doesn't give the same results as discussed in this thread.
The following uses a FastLine, adds Labels and adds a zero value for the last 'missing' value:
--------
If you wish the last value to add the Label but no value to be plotted then you could do the following:
The value could exist as a null between other values, eg. changing the loop to:
Please let us know if that doesn't resolve the question in hand.
Regards,
Marc Meumann
Sorry for the delay. Personnel changes for holidays caused us to need to re-tread the steps on this issue. Re-checking this, rolling back to before the fix you're testing doesn't give the same results as discussed in this thread.
The following uses a FastLine, adds Labels and adds a zero value for the last 'missing' value:
--------
Code: Select all
com.steema.teechart.styles.FastLine line1 = new com.steema.teechart.styles.FastLine(tChart.getChart());
java.util.Random y = new java.util.Random();
for (int i=0; i<5; i++) {
line1.add(i,y.nextDouble(), "val " + String.valueOf(i));
}
line1.add("Missing");
Code: Select all
com.steema.teechart.styles.FastLine line1 = new com.steema.teechart.styles.FastLine(tChart.getChart());
java.util.Random y = new java.util.Random();
for (int i=0; i<5; i++) {
if (i < 4)
line1.add(i,y.nextDouble(), "val " + String.valueOf(i));
else
{
line1.add(i,y.nextDouble(), "missing");
line1.setNull( i );
}
}
line1.setIgnoreNulls( false );
Code: Select all
for (int i=0; i<10; i++) {
if (i == 4)
{
line1.add(i,y.nextDouble(), "missing");
line1.setNull( i );
}
else
line1.add(i,y.nextDouble(), "val " + String.valueOf(i));
}
line1.setIgnoreNulls( false );
Regards,
Marc Meumann
Steema Support
Hi,
No it does not solve my issue.
1)
Why we need to add "missing" always at the end or at the beginning.
I noticed that when I try to add "missing" in between some values then it is not showing up in the chart.
2)
If you run the code shown below then you will see a gap between 2 and 4.
Why is it like this? I do not want to see breaks in between my x axis label items. Is there any way I could solve this issue/feature/bug ?.
3) series.add(ArrayList xvalues, ArrayList yvalues) does not work.
If you see the source code, it returns null arrays.
import javax.swing.JFrame;
import javax.swing.JPanel;
import com.steema.teechart.TChart;
import com.steema.teechart.styles.FastLine;
public class TestTeeChart {
/**
* @param args
*/
public static void main(String[] args) {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
panel.setSize(600, 600);
TChart chart = new TChart();
panel.add(chart);
FastLine fastLine = new FastLine(chart.getChart());
for (int i = 0; i < 10; i++) {
if (i != 3)
fastLine.add(i, i * i, "" + i);
}
frame.add(panel);
frame.setSize(600, 600);
frame.setVisible(true);
}
}
4) I am new to charting domain so please bear with me if I am conveying something really stupid.
As per my initial understanding, A line chart or trend chart is ;-
A graph that uses points connected by lines to show how something changes in value (as time goes by, or as something else happens).
We need to consider x-axis as a categorical axis in the case of a line chart. So we need to have equal spacing between x axis labels.
eg-: http://pubs.logicalexpressions.com/pub0 ... asp?ID=190
I may not have understood TChart API's very well. So if you could clear all my doubts then it would be very helpful.
Thanks,
Varun
No it does not solve my issue.
1)
Why we need to add "missing" always at the end or at the beginning.
I noticed that when I try to add "missing" in between some values then it is not showing up in the chart.
2)
If you run the code shown below then you will see a gap between 2 and 4.
Why is it like this? I do not want to see breaks in between my x axis label items. Is there any way I could solve this issue/feature/bug ?.
3) series.add(ArrayList xvalues, ArrayList yvalues) does not work.
If you see the source code, it returns null arrays.
import javax.swing.JFrame;
import javax.swing.JPanel;
import com.steema.teechart.TChart;
import com.steema.teechart.styles.FastLine;
public class TestTeeChart {
/**
* @param args
*/
public static void main(String[] args) {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
panel.setSize(600, 600);
TChart chart = new TChart();
panel.add(chart);
FastLine fastLine = new FastLine(chart.getChart());
for (int i = 0; i < 10; i++) {
if (i != 3)
fastLine.add(i, i * i, "" + i);
}
frame.add(panel);
frame.setSize(600, 600);
frame.setVisible(true);
}
}
4) I am new to charting domain so please bear with me if I am conveying something really stupid.
As per my initial understanding, A line chart or trend chart is ;-
A graph that uses points connected by lines to show how something changes in value (as time goes by, or as something else happens).
We need to consider x-axis as a categorical axis in the case of a line chart. So we need to have equal spacing between x axis labels.
eg-: http://pubs.logicalexpressions.com/pub0 ... asp?ID=190
I may not have understood TChart API's very well. So if you could clear all my doubts then it would be very helpful.
Thanks,
Varun
Hello Varun,
Re. when I try to add "missing" in between some values then it is not showing up in the chart.
The code from my last post would be an example of that. The Label shows correctly here:
It may be that there is no physical space on the Axis if you have many values, though with the example above for a standard dimensioned Chart I wouldn't expect a problem. To improve fit though, when there are many labels, you can change the Angle of them:
eg.
2. Gap between 2 and 4.
If you add Labels with your data TeeChart assumes you are overriding default control of the Labels and follows the instruction of doing nothing (in this example) at 3.
Modify you loop to treat those Labels that the loop omits.
or (simpler maybe)
Re. 3) series.add(ArrayList xvalues, ArrayList yvalues) does not work.
Yes, that fails, we have fixed it now for inclusion in the next update (imminent), and included an overload for double[],double[] that might be more practical for some developers. Aplogies for the inconvenience caused.
Re 4.
Your description seems coherent to me. With regard to null points we have received multiple views from different developers on how they would like to see them plotted. TeeChart attempts to offer more than one option in its API. Once coded the decision on that option becomes fixed for that application (if requiring to be fixed). The next update of TeeChart for Java, currently being developed, includes a type called TreatNulls to offer several predefined options for dealing with null values.
Regards,
Marc
Re. when I try to add "missing" in between some values then it is not showing up in the chart.
The code from my last post would be an example of that. The Label shows correctly here:
Code: Select all
for (int i=0; i<10; i++) {
if (i == 4)
{
line1.add(i,y.nextDouble(), "missing");
line1.setNull( i );
}
else
line1.add(i,y.nextDouble(), "val " + String.valueOf(i));
}
line1.setIgnoreNulls( false );
eg.
Code: Select all
tChart.getAxes().getBottom().getLabels().setAngle(90);
If you add Labels with your data TeeChart assumes you are overriding default control of the Labels and follows the instruction of doing nothing (in this example) at 3.
Modify you loop to treat those Labels that the loop omits.
Code: Select all
for (int i = 0; i < 10; i++) {
if (i != 3)
line1.add(i, i * i, " " + i);
else
{
line1.add(i, 0.0, " " + i);
line1.setNull( i );
}
}
line1.setIgnoreNulls( false );
Code: Select all
for (int i = 0; i < 10; i++) {
if (i != 3)
line1.add(i, i * i, " " + i,Color.BLUE);
else
{
line1.add(i, i, " " + i, Color.TRANSPARENT);
}
}
Re. 3) series.add(ArrayList xvalues, ArrayList yvalues) does not work.
Yes, that fails, we have fixed it now for inclusion in the next update (imminent), and included an overload for double[],double[] that might be more practical for some developers. Aplogies for the inconvenience caused.
Re 4.
Your description seems coherent to me. With regard to null points we have received multiple views from different developers on how they would like to see them plotted. TeeChart attempts to offer more than one option in its API. Once coded the decision on that option becomes fixed for that application (if requiring to be fixed). The next update of TeeChart for Java, currently being developed, includes a type called TreatNulls to offer several predefined options for dealing with null values.
Regards,
Marc
Steema Support
Hi,
Thanks for your reply. I think you have not completely understood my question number 2. Even if I follow your instructions, I would get a 3 in between 2 and 4. I do not want to display 3 and its axis point in the chart.
The x-axis should be like 1 2 4 5 6 7 8 9. If you plot a line chart in MS Excel then you would get a better understanding of my issue.
http://picasaweb.google.com/cbvarun/Ste ... 5609702322
Thanks,
Varun
Thanks for your reply. I think you have not completely understood my question number 2. Even if I follow your instructions, I would get a 3 in between 2 and 4. I do not want to display 3 and its axis point in the chart.
The x-axis should be like 1 2 4 5 6 7 8 9. If you plot a line chart in MS Excel then you would get a better understanding of my issue.
http://picasaweb.google.com/cbvarun/Ste ... 5609702322
Thanks,
Varun