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

Shouldn't scaleDateTime() work by default with Instant? #174

Closed
AndreiKingsley opened this issue Apr 11, 2023 · 4 comments
Closed

Shouldn't scaleDateTime() work by default with Instant? #174

AndreiKingsley opened this issue Apr 11, 2023 · 4 comments
Assignees

Comments

@AndreiKingsley
Copy link
Contributor

We can use Instant as the data type, but we need to add scaleDatetime() to format the axis correctly. Why don't we do this automatically when we have Instant as a data type? Including in the case of yMin, middle etc. It's also a bit strange that the public api lacks something like scaleColorDatetime, but we can implement it with

Scale(Aes.COLOR, otherOptions = Options(
        mapOf(
            Option.Scale.DATE_TIME to true
        ))
)
@AndreiKingsley AndreiKingsley changed the title Shouldn't scaleDateTime work by default with Instant? Shouldn't scaleDateTime() work by default with Instant? Apr 11, 2023
@IKupriyanov-HORIS IKupriyanov-HORIS self-assigned this Apr 12, 2023
@IKupriyanov-HORIS
Copy link
Collaborator

Hi!
Sorry, the issue description is kinda unclear. May I clarify it? Are you talking about the plot legend that uses numbers as labels instead of formatted date/time?

Like in this example:

%use lets-plot
import java.time.Instant.parse

val instants = listOf(
    "2021-01-01T00:00:00Z",
    "2021-02-23T00:00:00Z",
    "2021-04-03T00:00:00Z",
    "2021-05-04T00:00:00Z",
    "2021-10-05T00:00:00Z"
).map(::parse)

val daysData = mapOf<String, Any>(
    "days" to instants,
    "val" to (1..instants.size)
)

val p = letsPlot(daysData) + geomBar() { x = "days"; color = "days" }
p

Actual result:
image

And you expected this?
image

Am I correct?

@AndreiKingsley
Copy link
Contributor Author

Yes!

@AndreiKingsley
Copy link
Contributor Author

Also i want axis formatting when i use, for example, error bar:
`val instants = listOf(
"2021-01-01T00:00:00Z",
"2021-01-01T00:04:00Z",
"2021-01-01T00:00:00Z",
"2021-01-01T00:00:00Z",
"2021-01-01T00:00:00Z",
).map(::parse)
val instants2 = listOf(
"2021-01-01T00:05:00Z",
"2021-01-01T00:05:00Z",
"2021-01-01T00:05:00Z",
"2021-01-01T00:05:00Z",
"2021-01-01T00:05:00Z",
).map(::parse)
val daysData = mapOf<String, Any>(
"t1" to instants,
"t2" to instants2,
"val" to (1..instants.size)
)

val p = letsPlot(daysData) + geomErrorBar(stat = Stat.identity) {
x = "val";
ymin = "t1"
ymax = "t2"
}
p`
gives
image
but I expect y date-time formatting

@alshan
Copy link
Collaborator

alshan commented May 10, 2023

Fixed in LPK v4.4.0

@alshan alshan closed this as completed May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants