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 three new visual options (title position/font, value font) #190

Merged
merged 1 commit into from Jan 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ JustGage is a handy JavaScript plugin for generating and animating nice & cl

###Update log

######January ?, 2016.
* **titlePosition** - 'above' or 'below'
* **titleFontFamily** - customize font-family for the title
* **valueFontFamily** - customize font-family for the value


######January 5, 2016.
* **donut pointer** - render configurable triangle pointer in donut mode - demo at http://justgage.com/examples/pointer.html

Expand Down
21 changes: 18 additions & 3 deletions justgage.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,22 @@ JustGage = function(config) {
// color of gauge title
titleFontColor: kvLookup('titleFontColor', config, dataset, "#999999"),

// titleFontFamily : string
// color of gauge title
titleFontFamily: kvLookup('titleFontFamily', config, dataset, "sans-serif"),

// titlePosition : string
// 'above' or 'below'
titlePosition: kvLookup('titlePosition', config, dataset, "above"),

// valueFontColor : string
// color of label showing current value
valueFontColor: kvLookup('valueFontColor', config, dataset, "#010101"),

// valueFontFamily : string
// color of label showing current value
valueFontFamily: kvLookup('valueFontFamily', config, dataset, "Arial"),

// symbol : string
// special symbol to show next to value
symbol: kvLookup('symbol', config, dataset, ''),
Expand Down Expand Up @@ -375,11 +386,15 @@ JustGage = function(config) {
// delta
dx = (canvasW - widgetW) / 2;
dy = (canvasH - widgetH) / 2;
if (obj.config.titlePosition === 'below') {
// shift whole thing down
dy -= (widgetH / 6.4);
}

// title
titleFontSize = ((widgetH / 8) > obj.config.titleMinFontSize) ? (widgetH / 10) : obj.config.titleMinFontSize;
titleX = dx + widgetW / 2;
titleY = dy + widgetH / 6.4;
titleY = dy + (obj.config.titlePosition === 'below' ? (widgetH * 1.07) : (widgetH / 6.4));

// value
valueFontSize = ((widgetH / 6.5) > obj.config.valueMinFontSize) ? (widgetH / 6.5) : obj.config.valueMinFontSize;
Expand Down Expand Up @@ -647,7 +662,7 @@ JustGage = function(config) {
obj.txtTitle.attr({
"font-size": obj.params.titleFontSize,
"font-weight": "bold",
"font-family": "Arial",
"font-family": obj.config.titleFontFamily,
"fill": obj.config.titleFontColor,
"fill-opacity": "1"
});
Expand All @@ -658,7 +673,7 @@ JustGage = function(config) {
obj.txtValue.attr({
"font-size": obj.params.valueFontSize,
"font-weight": "bold",
"font-family": "Arial",
"font-family": obj.config.valueFontFamily,
"fill": obj.config.valueFontColor,
"fill-opacity": "0"
});
Expand Down