mirror of https://github.com/masayuki0812/c3.git
Quite good looking graph derived from d3.js
http://c3js.org
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.7 KiB
42 lines
1.7 KiB
c3_chart_internal_fn.getYFormat = function (forArc) { |
|
var $$ = this, |
|
formatForY = forArc && !$$.hasType('gauge') ? $$.defaultArcValueFormat : $$.yFormat, |
|
formatForY2 = forArc && !$$.hasType('gauge') ? $$.defaultArcValueFormat : $$.y2Format; |
|
return function (v, ratio, id) { |
|
var format = $$.axis.getId(id) === 'y2' ? formatForY2 : formatForY; |
|
return format.call($$, v, ratio); |
|
}; |
|
}; |
|
c3_chart_internal_fn.yFormat = function (v) { |
|
var $$ = this, config = $$.config, |
|
format = config.axis_y_tick_format ? config.axis_y_tick_format : $$.defaultValueFormat; |
|
return format(v); |
|
}; |
|
c3_chart_internal_fn.y2Format = function (v) { |
|
var $$ = this, config = $$.config, |
|
format = config.axis_y2_tick_format ? config.axis_y2_tick_format : $$.defaultValueFormat; |
|
return format(v); |
|
}; |
|
c3_chart_internal_fn.defaultValueFormat = function (v) { |
|
return isValue(v) ? +v : ""; |
|
}; |
|
c3_chart_internal_fn.defaultArcValueFormat = function (v, ratio) { |
|
return (ratio * 100).toFixed(1) + '%'; |
|
}; |
|
c3_chart_internal_fn.dataLabelFormat = function (targetId) { |
|
var $$ = this, data_labels = $$.config.data_labels, |
|
format, defaultFormat = function (v) { return isValue(v) ? +v : ""; }; |
|
// find format according to axis id |
|
if (typeof data_labels.format === 'function') { |
|
format = data_labels.format; |
|
} else if (typeof data_labels.format === 'object') { |
|
if (data_labels.format[targetId]) { |
|
format = data_labels.format[targetId] === true ? defaultFormat : data_labels.format[targetId]; |
|
} else { |
|
format = function () { return ''; }; |
|
} |
|
} else { |
|
format = defaultFormat; |
|
} |
|
return format; |
|
};
|
|
|