Commit e65b7a62 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Add arc.title option

parent 4a6304c4
...@@ -70,6 +70,12 @@ text { ...@@ -70,6 +70,12 @@ text {
stroke-width: 2px; stroke-width: 2px;
} }
/*-- Arc --*/
.chart-arcs-title {
font-size: 1.3em;
}
/*-- Focus --*/ /*-- Focus --*/
.target.focused path.-line { .target.focused path.-line {
......
...@@ -123,7 +123,8 @@ ...@@ -123,7 +123,8 @@
__point_onunselected = getConfig(['point', 'onunselected'], function () {}); __point_onunselected = getConfig(['point', 'onunselected'], function () {});
// arc // arc
var __arc_label_fomat = getConfig(['arc', 'label', 'format'], function (d, ratio) { return ratio.toFixed(1) + "%"; }); var __arc_label_fomat = getConfig(['arc', 'label', 'format'], function (d, ratio) { return (100 * ratio).toFixed(1) + "%"; }),
__arc_title = getConfig(['arc', 'title'], "");
// region - region to change style // region - region to change style
var __regions = getConfig(['regions'], []); var __regions = getConfig(['regions'], []);
...@@ -442,9 +443,11 @@ ...@@ -442,9 +443,11 @@
} }
return translate; return translate;
} }
function getArcRatio(d) {
return (d.endAngle - d.startAngle) / (Math.PI * 2);
}
function textForArcLable(d) { function textForArcLable(d) {
var ratio = 100 * (d.endAngle - d.startAngle) / (Math.PI * 2); return __arc_label_fomat(d, getArcRatio(d));
return __arc_label_fomat(d, ratio);
} }
function expandArc(targetId, withoutFadeOut) { function expandArc(targetId, withoutFadeOut) {
var target = svg.selectAll('.chart-arc.target' + (targetId ? '-' + targetId : '')), var target = svg.selectAll('.chart-arc.target' + (targetId ? '-' + targetId : '')),
...@@ -453,7 +456,12 @@ ...@@ -453,7 +456,12 @@
.transition().duration(50) .transition().duration(50)
.attr("d", svgArcExpanded) .attr("d", svgArcExpanded)
.transition().duration(100) .transition().duration(100)
.attr("d", svgArcExpandedSub); .attr("d", svgArcExpandedSub)
.each(function (d) {
if (isDountType(d.data)) {
// callback here
}
});
if (!withoutFadeOut) { if (!withoutFadeOut) {
noneTargets.style("opacity", 0.3); noneTargets.style("opacity", 0.3);
} }
...@@ -1069,9 +1077,16 @@ ...@@ -1069,9 +1077,16 @@
var id = (typeof d === 'string') ? d : d.id; var id = (typeof d === 'string') ? d : d.id;
return __data_types[id] === 'scatter'; return __data_types[id] === 'scatter';
} }
function isArcType(d) { function isPieType(d) {
var id = (typeof d === 'string') ? d : d.id; var id = (typeof d === 'string') ? d : d.id;
return __data_types[id] === 'pie' || __data_types[id] === 'dount'; return __data_types[id] === 'pie';
}
function isDountType(d) {
var id = (typeof d === 'string') ? d : d.id;
return __data_types[id] === 'dount';
}
function isArcType(d) {
return isPieType(d) || isDountType(d);
} }
/* not used /* not used
function lineData(d) { function lineData(d) {
...@@ -1581,7 +1596,11 @@ ...@@ -1581,7 +1596,11 @@
// Define g for arc chart area // Define g for arc chart area
main.select(".chart").append("g") main.select(".chart").append("g")
.attr("class", "chart-arcs") .attr("class", "chart-arcs")
.attr("transform", translate.arc); .attr("transform", translate.arc)
.append('text')
.attr('class', 'chart-arcs-title')
.style("text-anchor", "middle")
.text(__arc_title);
if (__zoom_enabled) { // TODO: __zoom_privileged here? if (__zoom_enabled) { // TODO: __zoom_privileged here?
// if zoom privileged, insert rect to forefront // if zoom privileged, insert rect to forefront
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
// ["versicolor", 40], // ["versicolor", 40],
// ["virginica", 50], // ["virginica", 50],
], ],
// type : 'pie',
type : 'dount', type : 'dount',
}, },
axis: { axis: {
...@@ -40,7 +39,8 @@ ...@@ -40,7 +39,8 @@
arc: { arc: {
label: { label: {
format: function (d, ratio) { return ""; } format: function (d, ratio) { return ""; }
} },
title: "Iris Petal Width"
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment