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

Add a function to allow the min/max values to be formated #1354

Merged

Conversation

EspadaV8
Copy link
Contributor

It would be nice to be able to append/prepend things to the min and max values. Currently the only way to do this is with some JS to inject the text after the gauge graph has been rendered. This adds in a format function similar to the label format function.

I wasn't sure, but with PR do you want the concatenated and minified JS included as well?

@nym
Copy link

nym commented Sep 8, 2015

Seems like overkill to have a custom formatter for the max/min, when the center (current) value already has a formatter. Nevertheless, this would solve my issue of not being able to put a $ before the min+max labels on the Gauge.

@nym
Copy link

nym commented Sep 8, 2015

Maybe a good compromise is to use the default formatter unless a custom one is provided.

@EspadaV8
Copy link
Contributor Author

EspadaV8 commented Sep 9, 2015

Default formatter as in the label.format function? Wouldn't that potentially cause more issues? Where people don't want the gauge labels to be formatted at all but do want the middle one formatted. It would also change existing gauges.

And yeah, it probably is overkill to have the isMax parameter, but could possibly useful for some people. As a bit of a strained example

min: -100,
max: 100
minmaxformat: function (value, isMax) {
   return (isMax) ? "$" + value : "-$" + value.substr(1);
}

Would allow the labels to be -$100 and $100 instead of $-100 and $100 (true, in this example you could check for the - in the value, but that might not be possible in all cases).

@jkusa
Copy link

jkusa commented Apr 8, 2016

👍 to this feature

@aendra-rininsland
Copy link
Member

aendra-rininsland commented May 2, 2016

@EspadaV8 Looks good to me. Thanks for the documentation! 👍 💯

Will be happy to add it, but could you please write a unit test? All new features must have at least one test.

Please also rebase against master.

Nicely done on not adding the build/minified files, please don't add them.

Thank you!

@aendra-rininsland aendra-rininsland added this to the 0.4.12 milestone May 2, 2016
@aendra-rininsland aendra-rininsland added RTBC waiting on submitter R-needs-tests Request for changes: The PR needs tests labels May 2, 2016
@aendra-rininsland
Copy link
Member

Also, not entirely convince gauge.minmaxformat is the most intuitive API. Maybe gauge.label.extents, so it's in the label namespace like the main label?

@EspadaV8
Copy link
Contributor Author

Hi @Aendrew sorry for the delay in replying. I'll try and get this updated shortly.

@EspadaV8 EspadaV8 force-pushed the feature/gauge-min-max-formater branch 2 times, most recently from 8737c41 to 8223963 Compare May 20, 2016 00:13
@codecov-io
Copy link

codecov-io commented May 20, 2016

Current coverage is 64.09% (diff: 100%)

Merging #1354 into master will increase coverage by 0.04%

@@             master      #1354   diff @@
==========================================
  Files             1          1          
  Lines          4400       4406     +6   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           2818       2824     +6   
  Misses         1582       1582          
  Partials          0          0          

Powered by Codecov. Last update 223404a...508a797

@EspadaV8 EspadaV8 force-pushed the feature/gauge-min-max-formater branch from 78eece7 to b629979 Compare May 20, 2016 00:23
@kenbier
Copy link

kenbier commented Oct 18, 2016

any chance this can get merged? @Aendrew @EspadaV8

I'd be willing to chip in on tests if this is otherwise good to merge.

@EspadaV8
Copy link
Contributor Author

@kenbier I'm not sure if I need to do anything but I'd be happy to fix anything up if it needs it before merging.

@kenbier
Copy link

kenbier commented Oct 18, 2016

@EspadaV8 Would you mind adding tests then? According to the reviewer's comments and labels thats all that is necessary.

Will be happy to add it, but could you please write a unit test? All new features must have at least one test.

I could really use this feature :)

@EspadaV8
Copy link
Contributor Author

Ah, I completely missed that. I'll see if I can add one in, sure.

@kenbier
Copy link

kenbier commented Oct 18, 2016

@EspadaV8 No worries. Also, you'll be asked to squash your commits and rebase against master after you add the test.

@EspadaV8 EspadaV8 force-pushed the feature/gauge-min-max-formater branch from b629979 to 508a797 Compare October 18, 2016 05:45
@EspadaV8
Copy link
Contributor Author

Added new test, rebased and squashed. I've no idea if the test is any good but it passes so hopefully it'll do 😄 I just copied the first test and added what I needed.

@aendra-rininsland aendra-rininsland removed R-needs-tests Request for changes: The PR needs tests waiting on submitter labels Oct 18, 2016
@aendra-rininsland
Copy link
Member

This looks like it's good to merge. Thanks @EspadaV8! :shipit:

@aendra-rininsland aendra-rininsland merged commit 955fdd6 into c3js:master Oct 18, 2016
@EspadaV8 EspadaV8 deleted the feature/gauge-min-max-formater branch October 18, 2016 10:03
@EspadaV8
Copy link
Contributor Author

You're welcome. Glad it painless 😄

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

Successfully merging this pull request may close these issues.

6 participants