Browse Source

WIP for gauge handling.

pull/254/head
Brandon Bernal 11 years ago
parent
commit
2327ad1c7c
  1. 25
      c3.js

25
c3.js

@ -17,6 +17,9 @@
chartArc: 'c3-chart-arc', chartArc: 'c3-chart-arc',
chartArcs: 'c3-chart-arcs', chartArcs: 'c3-chart-arcs',
chartArcsTitle: 'c3-chart-arcs-title', chartArcsTitle: 'c3-chart-arcs-title',
gaugeArc: 'c3-gauge-arc',
gaugeArcs: 'c3-gauge-arcs',
gaugeArcsTitle: 'c3-gauge-arcs-title',
selectedCircle: 'c3-selected-circle', selectedCircle: 'c3-selected-circle',
selectedCircles: 'c3-selected-circles', selectedCircles: 'c3-selected-circles',
eventRect: 'c3-event-rect', eventRect: 'c3-event-rect',
@ -227,6 +230,13 @@
__pie_onmouseover = getConfig(['pie', 'onmouseover'], function () {}), __pie_onmouseover = getConfig(['pie', 'onmouseover'], function () {}),
__pie_onmouseout = getConfig(['pie', 'onmouseout'], function () {}); __pie_onmouseout = getConfig(['pie', 'onmouseout'], function () {});
// gauge
var __gauge_label_show = getConfig(['gauge', 'label', 'show'], true),
__gauge_label_format = getConfig(['gauge', 'label', 'format']),
__gauge_onclick = getConfig(['gauge', 'onclick'], function () {}),
__gauge_onmouseover = getConfig(['gauge', 'onmouseover'], function () {}),
__gauge_onmouseout = getConfig(['gauge', 'onmouseout'], function () {});
// donut // donut
var __donut_label_show = getConfig(['donut', 'label', 'show'], true), var __donut_label_show = getConfig(['donut', 'label', 'show'], true),
__donut_label_format = getConfig(['donut', 'label', 'format']), __donut_label_format = getConfig(['donut', 'label', 'format']),
@ -415,7 +425,7 @@
function updateRadius() { function updateRadius() {
radiusExpanded = height / 2; radiusExpanded = height / 2;
radius = radiusExpanded * 0.95; radius = radiusExpanded * 0.95;
innerRadius = hasDonutType(c3.data.targets) ? radius * 0.6 : 0; innerRadius = hasDonutType(c3.data.targets) || hasGaugeType(c3.data.targets) ? radius * 0.6 : 0;
} }
function getSvgLeft() { function getSvgLeft() {
var leftAxisClass = __axis_rotated ? CLASS.axisX : CLASS.axisY, var leftAxisClass = __axis_rotated ? CLASS.axisX : CLASS.axisY,
@ -1972,11 +1982,14 @@
function hasPieType(targets) { function hasPieType(targets) {
return hasType(targets, 'pie'); return hasType(targets, 'pie');
} }
function hasGaugeType(targets) {
return hasType(targets, 'gauge');
}
function hasDonutType(targets) { function hasDonutType(targets) {
return hasType(targets, 'donut'); return hasType(targets, 'donut');
} }
function hasArcType(targets) { function hasArcType(targets) {
return hasPieType(targets) || hasDonutType(targets); return hasPieType(targets) || hasDonutType(targets) || hasGaugeType(targets);
} }
function isLineType(d) { function isLineType(d) {
var id = (typeof d === 'string') ? d : d.id; var id = (typeof d === 'string') ? d : d.id;
@ -2006,12 +2019,16 @@
var id = (typeof d === 'string') ? d : d.id; var id = (typeof d === 'string') ? d : d.id;
return __data_types[id] === 'pie'; return __data_types[id] === 'pie';
} }
function isGaugeType(d) {
var id = (typeof d === 'string') ? d : d.id;
return __data_types[id] === 'gauge';
}
function isDonutType(d) { function isDonutType(d) {
var id = (typeof d === 'string') ? d : d.id; var id = (typeof d === 'string') ? d : d.id;
return __data_types[id] === 'donut'; return __data_types[id] === 'donut';
} }
function isArcType(d) { function isArcType(d) {
return isPieType(d) || isDonutType(d); return isPieType(d) || isDonutType(d) || isGaugeType(d);
} }
/* not used /* not used
function lineData(d) { function lineData(d) {
@ -3414,7 +3431,7 @@
.text(textForArcLabel) .text(textForArcLabel)
.style("opacity", function (d) { return isTargetToShow(d.data.id) && isArcType(d.data) ? 1 : 0; }); .style("opacity", function (d) { return isTargetToShow(d.data.id) && isArcType(d.data) ? 1 : 0; });
main.select('.' + CLASS.chartArcsTitle) main.select('.' + CLASS.chartArcsTitle)
.style("opacity", hasDonutType(c3.data.targets) ? 1 : 0); .style("opacity", hasDonutType(c3.data.targets) || hasGaugeType(c3.data.targets) ? 1 : 0);
// subchart // subchart
if (__subchart_show) { if (__subchart_show) {

Loading…
Cancel
Save