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

Radar chart + Bar Line chart Base + startAtZeroEnabled = false + negative values #166

Closed
liuxuan30 opened this issue Jun 19, 2015 · 7 comments
Labels

Comments

@liuxuan30
Copy link
Member

When turning off startAtZeroEnabled, the negative values are not proper drawn. the radius ratio for each inner web is not correct.

The main trouble is:

        var labelCount = _chart.yAxis.entryCount;

        for (var j = 0; j < labelCount; j++)
        {
            for (var i = 0, xValCount = _chart.data!.xValCount; i < xValCount; i++)
            {
                var r = CGFloat(_chart.yAxis.entries[j] - _chart.chartYMin) * factor;
...

Take an example if _chart.yAxis.entries is: [-100000.0, 0.0, 100000.0, 200000.0, 300000.0, 400000.0]

and _chart.chartYMin is -35991.2689931.

The minimum raw data is -7501.57 and max is 277395.38.
negabug

@liuxuan30 liuxuan30 changed the title Radar chart has troubles when turning off startAtZeroEnabled Radar chart has serious troubles when turning off startAtZeroEnabled Jun 19, 2015
@liuxuan30 liuxuan30 changed the title Radar chart has serious troubles when turning off startAtZeroEnabled [BUG]Radar chart has serious troubles when turning off startAtZeroEnabled and has negative values Jun 19, 2015
@liuxuan30
Copy link
Member Author

Provide data here:
data set 0:
[ChartDataEntry, xIndex: 0, value -7501.574034, ChartDataEntry, xIndex: 1, value 73587.954072, ChartDataEntry, xIndex: 2, value 68861.089668, ChartDataEntry, xIndex: 3, value 79499.134258, ChartDataEntry, xIndex: 4, value 53615.304423]

data set 1:
[ChartDataEntry, xIndex: 0, value 35790.059533, ChartDataEntry, xIndex: 1, value 20118.91748, ChartDataEntry, xIndex: 2, value 42567.845168, ChartDataEntry, xIndex: 3, value 38749.916356, ChartDataEntry, xIndex: 4, value 13551.626137]

data set 2:
[ChartDataEntry, xIndex: 0, value 163400.659256, ChartDataEntry, xIndex: 1, value 187068.443587, ChartDataEntry, xIndex: 2, value 277395.375557, ChartDataEntry, xIndex: 3, value 133373.871463, ChartDataEntry, xIndex: 4, value 132363.776504]

xVals could be any string.

@danielgindi danielgindi changed the title [BUG]Radar chart has serious troubles when turning off startAtZeroEnabled and has negative values Radar chart + startAtZeroEnabled = false + negative values Jun 19, 2015
@danielgindi
Copy link
Collaborator

Well this is not very clear to me. Can you show a visual example of how negative values should behave in a Radar chart vs. how it is now?

@liuxuan30
Copy link
Member Author

radarafterfix

After I apply the code change, it renders like above, which I think is correct. the center will be -100K, and the interval between each inner web is equal. You could compare it to the previous screenshot.

As I mentioned in the pull request, the magic is _yAxis.axisMinimum = _yAxis.entries[0] I am not sure why it is absent currently, only _yAxis.axisMaximum = _yAxis.entries[entryCount - 1] is there.

@liuxuan30
Copy link
Member Author

@danielgindi I am starting using scatter chart view, and I find that these views also have such problems with the negative values and axis rendering. Are you aware of this?

First thing is the interval is not correctly cacluated if it involves with negative values; apply my fix will solve it;

second is the axis rendering about the minimum number is exceeding the bounds like below:

When the axis comes to postive values, everything is fine; however when it is below zero, the y label can draw on out of the xAxis.
overlap
It seems like determining if the negative number label should be drawn is buggy.

@liuxuan30 liuxuan30 changed the title Radar chart + startAtZeroEnabled = false + negative values Radar chart + Bar Line chart Base + startAtZeroEnabled = false + negative values Jun 30, 2015
@liuxuan30
Copy link
Member Author

I have also fixed the issue the negative axis labels will be drawn out bound in liuxuan30@226221c

The interesting part is when the yAxis.entries contains negative values, the transformer will calculate a larger value than the viewPortHandler contentRect bound. I think the transformer is doing its job, just need to clip those labels that beyond the contentRect.

@danielgindi
Copy link
Collaborator

I'm actually not seeing the problem in your screenshot. You are really not clear about this

@liuxuan30
Copy link
Member Author

Focus on the inner web - don't you see the first one, the radar chart, there is a small one not like others? and the distance between each inner web is not equal. Say the -100K should be the center, but -100 ~ 0 distance is not equal 0 ~ 100K

  • Can you try add some negative values on your side, so you can see it? I still believe there is defect while calculating the yAxis range for negative values.

Provide data here:
data set 0:
[ChartDataEntry, xIndex: 0, value -7501.574034, ChartDataEntry, xIndex: 1, value 73587.954072, ChartDataEntry, xIndex: 2, value 68861.089668, ChartDataEntry, xIndex: 3, value 79499.134258, ChartDataEntry, xIndex: 4, value 53615.304423]

data set 1:
[ChartDataEntry, xIndex: 0, value 35790.059533, ChartDataEntry, xIndex: 1, value 20118.91748, ChartDataEntry, xIndex: 2, value 42567.845168, ChartDataEntry, xIndex: 3, value 38749.916356, ChartDataEntry, xIndex: 4, value 13551.626137]

data set 2:
[ChartDataEntry, xIndex: 0, value 163400.659256, ChartDataEntry, xIndex: 1, value 187068.443587, ChartDataEntry, xIndex: 2, value 277395.375557, ChartDataEntry, xIndex: 3, value 133373.871463, ChartDataEntry, xIndex: 4, value 132363.776504]

Try this data

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

No branches or pull requests

2 participants