Browse Source

Fix data leble position on Firefox

pull/57/head
Masayuki Tanaka 11 years ago
parent
commit
be9caf62b0
  1. 7
      c3.js
  2. 2
      c3.min.js

7
c3.js

@ -1453,11 +1453,12 @@
return points[0][0] + (points[2][0] - points[0][0]) / 2;
}
}
function getYForText(points, d, that) {
function getYForText(points, d, textElement) {
var box = textElement.getBBox();
if (__axis_rotated) {
return (points[0][0] + points[2][0] + that.offsetHeight * 0.6) / 2;
return (points[0][0] + points[2][0] + box.height * 0.6) / 2;
} else {
return points[2][1] + (d.value < 0 ? that.offsetHeight : isBarType(d) ? -3 : -6);
return points[2][1] + (d.value < 0 ? box.height : isBarType(d) ? -3 : -6);
}
}

2
c3.min.js vendored

@ -30,7 +30,7 @@ a:a.id]}function gd(a){return"pie"===z["string"===typeof a?a:a.id]}function Tb(a
$b);return b}function id(a,b){var c=e.mouse(a),g=e.select(a),k=1*g.attr("cx"),g=1*g.attr("cy");return Math.sqrt(Math.pow(k-c[0],2)+Math.pow(g-c[1],2))<b}function jd(a){var b=e.mouse(a),c=e.select(a);a=1*c.attr("x");var g=1*c.attr("y"),c=1*c.attr("width");return a-10<b[0]&&b[0]<a+c+10&&g-10<b[1]}function Be(a,b){var c;for(c=0;c<b.length;c++)if(b[c].start<a&&a<=b[c].end)return!0;return!1}function ge(a,b){var c=!1;Object.keys(a).forEach(function(g){a[g]===b&&(c=!0)});return c}function Zb(a,b){return Math.pow(m(a.x)-
b[0],2)+Math.pow(D(a.value)-b[1],2)}function kd(a,b,c){Ce(a,b);l.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+c).data([b]).enter().append("circle").attr("class",function(){return"selected-circle selected-circle-"+c}).attr("cx",h?Ga:Fa).attr("cy",h?Fa:Ga).attr("stroke",function(){return I(b.id)}).attr("r",1.4*ab).transition().duration(100).attr("r",ab)}function ac(a,b,c){De(a,b);l.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+c).transition().duration(100).attr("r",
0).remove()}function ld(a,b,c,g){a?kd(b,c,g):ac(b,c,g)}function Ee(){}function md(){}function nd(a,b,c,g){}function bc(a){return a.filter(function(a){return F(a.value)})}function cc(a,b){return(b?l.selectAll(".-circles-"+b):l).selectAll(".-circle"+(F(a)?"-"+a:""))}function dc(a){cc(a).filter(function(){return e.select(this).classed(da)}).classed(da,!1).attr("r",ec)}function od(a,b){var c=pd(a,b);return function(a,b){var d=c(a,b),e=h?1:0,f=h?0:1;return"M "+d[0][e]+","+d[0][f]+" L"+d[1][e]+","+d[1][f]+
" L"+d[2][e]+","+d[2][f]+" L"+d[3][e]+","+d[3][f]+" z"}}function qd(a,b){var c=pd(a,!1),g=b?Fe:Ge;return function(a,b){return g(c(a,b),a,this)}}function Fe(a,b){var c;return h?(c=va(b)?4:6,a[2][1]+c*(0>b.value?-1:1)):a[0][0]+(a[2][0]-a[0][0])/2}function Ge(a,b,c){return h?(a[0][0]+a[2][0]+0.6*c.offsetHeight)/2:a[2][1]+(0>b.value?c.offsetHeight:va(b)?-3:-6)}function pd(a,b){var c=a.__max__+1,g=c?1.2*S.tickOffset()/c:0,d=we(g,c,a,!!b),e=xe(!!b),f=ye(a,!!b),h=b?H:t;return function(a,b){var c=h(a.id)(0),
" L"+d[2][e]+","+d[2][f]+" L"+d[3][e]+","+d[3][f]+" z"}}function qd(a,b){var c=pd(a,!1),g=b?Fe:Ge;return function(a,b){return g(c(a,b),a,this)}}function Fe(a,b){var c;return h?(c=va(b)?4:6,a[2][1]+c*(0>b.value?-1:1)):a[0][0]+(a[2][0]-a[0][0])/2}function Ge(a,b,c){c=c.getBBox();return h?(a[0][0]+a[2][0]+0.6*c.height)/2:a[2][1]+(0>b.value?c.height:va(b)?-3:-6)}function pd(a,b){var c=a.__max__+1,g=c?1.2*S.tickOffset()/c:0,d=we(g,c,a,!!b),e=xe(!!b),f=ye(a,!!b),h=b?H:t;return function(a,b){var c=h(a.id)(0),
l=f(a,b)||c;return[[d(a),l],[d(a),e(a)-(c-l)],[d(a)+g,e(a)-(c-l)],[d(a)+g,l]]}}function He(a,b,c,g){var d,e,f="M",l,n,m,p,q,s=[];if(y(g))for(d=0;d<g.length;d++)s[d]={},w(g[d].start)?s[d].start=a[0].x:s[d].start=C?ta(g[d].start):g[d].start,w(g[d].end)?s[d].end=a[a.length-1].x:s[d].end=C?ta(g[d].end):g[d].end;p=h?function(a){return c(a.value)}:function(a){return b(a.x)};q=h?function(a){return b(a.x)}:function(a){return c(a.value)};g=C?function(a,d,g,k){var e=a.x.getTime();a=d.x-a.x;d=new Date(e+a*(g+
k));return"M"+b(new Date(e+a*g))+" "+c(n(g))+" "+b(d)+" "+c(n(g+k))}:function(a,d,g,k){return"M"+b(l(g))+" "+c(n(g))+" "+b(l(g+k))+" "+c(n(g+k))};for(d=0;d<a.length;d++)if(w(s)||!Be(a[d].x,s))f+=" "+p(a[d])+" "+q(a[d]);else{l=Q(a[d-1].x,a[d].x);n=R(a[d-1].value,a[d].value);e=b(a[d].x)-b(a[d-1].x);m=c(a[d].value)-c(a[d-1].value);e=Math.sqrt(Math.pow(e,2)+Math.pow(m,2));m=2/e;var r=2*m;for(e=m;1>=e;e+=r)f+=g(a[d-1],a[d],e,m)}return f}function fc(a){var b;ub=e.select(ya);if(ub.empty())N.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');
else{ub.html("");f.data.x={};f.data.targets=Wa(a);qa();P();m.domain(e.extent(qb(f.data.targets)));D.domain(ob("y"));aa.domain(ob("y2"));T.domain(m.domain());kb.domain(D.domain());lb.domain(aa.domain());$=m.domain();J.scale(T);ea&&E.scale(m);p=e.select(ya).append("svg").attr("width",q+v+M).attr("height",r+n+pa).on("mouseenter",Ie).on("mouseleave",Je);vb=p.append("defs");vb.append("clipPath").attr("id",gc).append("rect").attr("width",q).attr("height",r);vb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",

Loading…
Cancel
Save