Skip to content

How to set logarithmic coordinates as a runtime option? #447

Answered by pkolaczk
pkolaczk asked this question in Q&A
Discussion options

You must be logged in to vote

I think I've found a solution:

enum YSpec {
    Linear(RangedCoordf32),
    Log(LogCoord<f32>)
}

impl Ranged for YSpec {
    type FormatOption = DefaultFormatting;
    type ValueType = f32;

    fn map(&self, value: &Self::ValueType, limit: (i32, i32)) -> i32 {
        match self {
            YSpec::Linear(range) => range.map(value, limit),
            YSpec::Log(range) => range.map(value, limit),
        }
    }

    fn key_points<Hint: KeyPointHint>(&self, hint: Hint) -> Vec<Self::ValueType> {
        match self {
            YSpec::Linear(range) => range.key_points(hint),
            YSpec::Log(range) => range.key_points(hint)
        }
    }

    fn range(&self) -> Range<Self::Value…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by pkolaczk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant