![]() | Steema Issues DatabaseNote: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;otherwise you can use StackOverflow. Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy. |
Summary: | Wrong left axes label | ||
---|---|---|---|
Product: | .NET TeeChart | Reporter: | Mohammad <mohammad.abuhasan> |
Component: | Chart | Assignee: | Steema Issue Manager <issuemanager> |
Status: | UNCONFIRMED --- | ||
Severity: | critical | CC: | chris |
Priority: | --- | Keywords: | SteemaConfirmed |
Version: | unspecified | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows | ||
Chart Series: | --- | Delphi / C++ Builder RAD IDE Version: | |
Attachments: |
Left Axes increment issue
code to export to file Chart data file Chart data file (csv) screenshot of test project test project Left Axes increment issue Project 2 small values Vlaue format "#,##0.###########" another screenshot Left Axes increment issue Project 3 screen shot us number format tchart independent delphi teechart test |
Created attachment 888 [details]
code to export to file
Hello!
we're going to need to be to reproduce this issue here in order to fix it or suggest a workaround for you. Possibly the easiest way to do this is to export the Chart data to a text file when you next see the issue appear - I've attached an image of the code needed to achieve this. When we have the txt file with the data that reproduces the issue you can expect a fix or a workaround to it to be produced quickly.
Created attachment 889 [details]
Chart data file
Created attachment 890 [details]
Chart data file (csv)
Hi Christopher, Thanks for your quick reply, I exported my chart data to both txt and csv files, and both are attached to this issue. Thanks. Created attachment 891 [details]
screenshot of test project
Created attachment 892 [details] test project attached a test project using the latest version of TeeChart.dll. A screenshot of the result I obtain is here -> http://bugs.teechart.net/attachment.cgi?id=891 Do you obtain the same running this project? Could you please try to reproduce your issue by modifying the above project and returning it to me? Created attachment 893 [details]
Left Axes increment issue Project 2
Hi Christopher,
I just added a line to code, which is show you the issue exactly, line added:
tChart1.Chart.Axes.Left.Labels.ValueFormat = "G";
Actually we need Left Axes to be General type, to show a very small values on zooming.
You can run attached project.
Thanks.
Okay, thank you. As a workaround, you can use the following ValueFormat which will give you the precision you need for zooming but will not produce the rounding around zero you see with "G": tChart1.Chart.Axes.Left.Labels.ValueFormat = "#,##0.###########"; Created attachment 895 [details]
small values
Actually this value format "#,##0.###########" not working properly with too small and too big values, please see attached snapshot.
If we used "#,##0.###########" it will get all labels as "0".
Thanks
"#,##0.###########" is a custom number format; if that format is not what you need then you can change it as described in the .net documentation here: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings In your attachment http://bugs.teechart.net/attachment.cgi?id=895 I cannot see the problem you mention ('all labels as "0"') - are you sure this is the image you wanted to upload? In attachment http://bugs.teechart.net/attachment.cgi?id=895 I used Value formate "G", if i used "#,##0.###########" it get all values as"0". what I need is dynamic label values, if i used number lin 1, 2, 3, then display as it is, but if numbers is 0.00000000000000003 is will display as 3 e-17 Thanks. Okay, can you please modify the test project to show me where there is a significant difference between "G" and "#,##0.###########"? I can then help you design a custom format which adjusts better to you needs. Created attachment 896 [details]
Vlaue format "#,##0.###########"
Please see left axes when using label value formate "#,##0.###########"
Created attachment 897 [details]
another screenshot
Here's a screenshot of the test project using a custom number format. Could you please modify the test project so I can reproduce your issue here?
Created attachment 898 [details]
Left Axes increment issue Project 3
Please find attached project which is contains two charts in same folder, one with label value format "G" and another one with label value format "#,##0.###########".
you can find that "#,##0.###########" is not working well, and "G" is working.
but the problem is when we use "G" sometimes get strange label values.
I investigate the issue and found property in Axis.CalcIncrement is changed.
Thanks.
Created attachment 899 [details]
screen shot
Created attachment 900 [details]
us number format
Created attachment 901 [details] tchart independent We can take TChart out of the equation and have a look at the base .NET Framework functionality. For this test I have set my number format to US, as can be seen here -> http://bugs.teechart.net/attachment.cgi?id=900 I then use the same custom number format string independently of TChart, as can be seen in the screenshot attached. If this does not work at your end, if this also gives you a zero, then I'm afraid I don't know how I can help you. Created attachment 902 [details]
delphi teechart test
We've been looking at this issue in more detail this morning. Using similar code in the Delphi version of TeeChart gives a similar issue as can be seen in the attached screenshot using the following code:
procedure TForm1.Button1Click(Sender: TObject);
begin
With SeriesTextSource1 do
Begin
Series:=Series1;
Filename:='D:\Downloads\LeftAxisTest2\LeftAxisTest\LeftAxisTest\Resources\baseChart.csv';
FieldSeparator:=';';
Headerlines:=1;
SeriesTextSource1.AddField('Index',1);
SeriesTextSource1.AddField('Text',2);
SeriesTextSource1.AddField('X',3);
SeriesTextSource1.AddField('Y',4);
Active:=True;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Legend.Visible:=false;
Chart1.Axes.Bottom.LabelStyle:=TAxisLabelStyle.talPointValue;
Chart1.Axes.Left.AxisValuesFormat:='#,##0.################################';
Chart1.Axes.Left.LabelsSize:=300;
end;
This leads us to the conclusion that this issue is a function of the mathematical operations TeeChart performs on floating point numbers to calculate the axis label values - rounding errors are inevitable. One possible workaround is to manually round these errors when displaying large numbers of significant digits - this can be done with the "G" format and TeeChart by the use of the GetAxisLabel event, e.g.
private void InitializeChart()
{
tChart1.Chart.Axes.Left.Labels.ValueFormat = "G";
points = new Points(tChart1.Chart);
tChart1.Legend.Visible = false;
tChart1.Axes.Bottom.Labels.Style = AxisLabelStyle.PointValue;
tChart1.Axes.Left.Labels.CustomSize = 300;
tChart1.GetAxisLabel += TChart1_GetAxisLabel;
}
private void TChart1_GetAxisLabel(object sender, GetAxisLabelEventArgs e)
{
if(sender.Equals(tChart1.Axes.Left))
{
if (e.LabelText.EndsWith("E-16") || e.LabelText.EndsWith("E-17") || e.LabelText.EndsWith("999999") || e.LabelText.EndsWith("000001"))
{
double num = double.Parse(e.LabelText);
e.LabelText = num.ToString("#,##0.##");
}
}
}
private void BAdd_Click(object sender, EventArgs e)
{
var ts = new TextSource(Application.StartupPath + @"\..\..\Resources\baseChart.csv");
ts.HeaderLines = 1;
ts.Separator = ';';
ts.Fields.Add(0, "Index");
ts.Fields.Add(1, "Text");
ts.Fields.Add(2, "X");
ts.Fields.Add(3, "Y");
points.DataSource = ts;
}
But your workaround will not work in most of cases, it's not always labels end with "E-16" or "E-17", sometimes it's ends with "E-33", so it's unpredictable. I need a general solution for this issue. Thanks. |
Created attachment 887 [details] Left Axes increment issue We found out that in some cases the increment of labels on y-axis is not correct. In the attached snapshot, you notice that increment is 0.2 except for one value where it becomes 2.775557e-16 instead of 0! This makes the charts very ugly and consumes lots of space. We are using version 4.1.2018.5043 on Windows OS Please advise if there are any workarounds for this issue. Thanks