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

Bug: Google LineChart should have a way to differentiated between 0 values and missing points null when log scale applied (probabily other charts too) #984

Open
orwant opened this issue May 9, 2015 · 6 comments

Comments

@orwant
Copy link
Collaborator

orwant commented May 9, 2015

Google LineChart should have a way to differentiated between 0 values and null values
(missing data) when log scale applied. Now 0 points will be considered as missing points

On the added screenshot gap in red line is caused by 0 value at that date. As you see
there is now way to avoid using log scale because of difference in magnitude between
blue line and red line.

This issue is platform independent. 

Original issue reported on code.google.com by eugen.torica on 2012-08-07 12:43:11


- _Attachment: chart.png
![chart.png](https://storage.googleapis.com/google-code-attachments/google-visualization-api-issues/issue-984/comment-0/chart.png)_
@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015

Found a workaround: for 0 value data in log scale chart, use cell object {v: 0.01, f:
'0'}. It will still display as 0, but not be evaluated as 0, drawing the line properly.

Original issue reported on code.google.com by veiko.s on 2012-09-13 08:10:36

@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015

While it is a nice trick it won't work because it will introduce a distortion in the
chart. 
Bellow I uploaded two files. The first one has {v: 0.01, f: '0'} for 0 values and the
second one has {v: 0.0000000001, f: '0'}.
Space between 0 and 1 is enlarging as v tends to 0. Which is normal logarithmic behaviour
but charts start to look too geeky.

Original issue reported on code.google.com by eugen.torica on 2013-04-08 14:55:19


- _Attachment: original_chart_0_gaps.png
![original_chart_0_gaps.png](https://storage.googleapis.com/google-code-attachments/google-visualization-api-issues/issue-984/comment-2/original_chart_0_gaps.png)_ - _Attachment: chart_0.01.png
![chart_0.01.png](https://storage.googleapis.com/google-code-attachments/google-visualization-api-issues/issue-984/comment-2/chart_0.01.png)_ - _Attachment: chart_0.00000001.png
![chart_0.00000001.png](https://storage.googleapis.com/google-code-attachments/google-visualization-api-issues/issue-984/comment-2/chart_0.00000001.png)_

@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015

What worked for me was increasing vAxis.gridlines.count to at least 4 in this case,
which made sure that the first vertical line will be drawn for a value greater than
1 (probably for 10 or 100), thereby plotting the 0.01 value together with 0 instead
of somewhere in the air between 0 and 1. 

Also, setting vAxis.maxValue = 1 helps, because then the chart will choose the maximum
plotted value as a higher bound for the vertical axis, leading the chart scale to best
fit the data.

Original issue reported on code.google.com by veiko.s on 2013-04-08 15:29:22

@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015

With log scale, the 0 value on the Y axis would be infinitely far down, if scaled 'correctly'.
 So there is no way to include 0 values with a normal log scale axis, and the current
behavior is not really a bug.

However, there is an undocumented feature that might work for you.  You can set the
'scale' to 'mirrorLog', which supports 0 and negative values.  For negative values,
it negates each value, computes the log of that, and puts the negative back on.  For
values close to zero, positive and negative, it uses a linear scale. 

Original issue reported on code.google.com by dlaliberte@google.com on 2013-04-08 17:36:57

  • Labels added: Type-Invalid
  • Labels removed: Type-Defect

@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015

I'm sorry. Could you please tell where property scale should be placed?
My options object looks like:
var options = {
    pointSize: 5,
    //interpolateNulls:true,
    vAxis: {
        logScale: true,
        format:'#,###,###',
        gridlines: {count:3},
        minValue : 0,
        baseline : 0
    },

    hAxis: {
        format: 'dd.MM.yyyy',
        maxValue: new Date('03/11/2013'),
        minValue: new Date('04/03/2013'),
        viewWindowMode: 'pretty' 
    }
};
I tried to put scale attribute in options and in vAxis object. Ex: scale:'mirrorLog'
but I didn't see any effect.
Version of visualization package is:
  google.load('visualization', '1', { 'packages': ['corechart'], language:'RU' });

Thank you very much!

Original issue reported on code.google.com by eugen.torica on 2013-04-10 09:13:25

@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015

Sorry, I forgot that the option name was changed as well.  Instead of logScale: true,
use "scaleType": "mirrorLog".

Original issue reported on code.google.com by dlaliberte@google.com on 2013-04-10 13:42:45

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

1 participant