Coder Social home page Coder Social logo

Comments (10)

lecho avatar lecho commented on July 22, 2024

I like it but adjusting axis height will be a little tricky, right now height for horizontal axis is determined using font's ascent and descent values. For axis with rotated labels we will have to use Pythagorean triangle where hypotenuse is equal to the label's length.

from hellocharts-android.

douglasjunior avatar douglasjunior commented on July 22, 2024

Right.
If we think that the smaller sides are equal. Only with the value of the hypotenuse we can calculate the height.
In our case, the hypotenuse would be the label length.
Something like this:
pythagorean_theorem1

labelLength ^ 2 = smallSide ^ 2 + smallSide ^ 2
labelLength ^ 2 = 2 * ( smallSide ^ 2 )
( labelLength ^ 2 ) / 2 = ( smallSide ^ 2 )
( ( labelLength ^ 2 ) / 2 ) ^ ( 1 / 2 ) = smallSide

newHeight = smallSide
newWidth = smallSide

Example:
screenshot_2014-12-24-09-40-54 - example

What is the method you are using to calculate the length of the label?

from hellocharts-android.

lecho avatar lecho commented on July 22, 2024

Right now AxisRenderer calculates maximum label width based on Axis.maxLabelsChars attribute, so it is the same for all labels in given axis because text measurement tends to be slow: AxisRenderer.java#L233

Label width is also used to determine how many labels should be visible for horizontal axis: AxesRenderer.java#L435
Maybe it will be good idea to introduce different attribute for that, for example labelSeparationCharsNumber or something like that.

from hellocharts-android.

douglasjunior avatar douglasjunior commented on July 22, 2024

If we add the Pythagorean calculation in AxisRenderer.java#L233, would not be enough ?

For the rest of the code would work with the new width normally.

It would only be necessary to use the new height to position the axis name.

from hellocharts-android.

lecho avatar lecho commented on July 22, 2024

If we add the Pythagorean calculation in AxisRenderer.java#L233, would not be enough ?

Yea, I think that should be enough.

It would only be necessary to use the new height to position the axis name.

Yes, new height should be used for axis name baseline(if axis is not inside) and axis label height:
AxesRenderer.java#L296
AxesRenderer.java#L263

from hellocharts-android.

douglasjunior avatar douglasjunior commented on July 22, 2024

I did some testing and found that it is possible to implement
But I found a difficulty with full chart height 😕. Now the chart need to stretch vertically as the label height. (When the label be diagonally)
I think better to wait you look when you can.

from hellocharts-android.

lecho avatar lecho commented on July 22, 2024

Ok, I will have more time next week:)

from hellocharts-android.

lecho avatar lecho commented on July 22, 2024

I had some problems with this but now it should work. Axis has method `Axis.setHasLabelTilted(boolean)', if set to true labels for that axis are rotated by -45 degrees.

device-2015-01-11-205425

from hellocharts-android.

douglasjunior avatar douglasjunior commented on July 22, 2024

Very nice!

I will test tomorrow.

Thanks

from hellocharts-android.

rasik1010 avatar rasik1010 commented on July 22, 2024

can we start chart from right to left side? any idea about this? please help me if any one knows , thank you.

from hellocharts-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.