@domoinc/multiline-chart
Version:
MultiLineChart - Domo Widget
62 lines (54 loc) • 2.19 kB
JavaScript
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
// Domo Careted Rectangle with rounded corners: This function returns a path element
// that is a function of the parameters of the input width, height, radius, caret, x, y
// if x and y are not sent in then the function will assume 0 and if other elemnt is
// missing it will assume the default // 100, 50, 5, 10,0,0))
//
// Example:
// var tooltip_group = svg.append('g')
// var bubble = tooltip_group.append('path')
// .attr('d', d3.DomoCaretRect(100, 50, 5, 10, 0, 0))
// var bubble_text = tooltip_group.append('text')
// .attr('transform', 'tranlate(0, -25)')
// .style("text-anchor", "middle")
// .text('Sample')
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
d3.DomoCaretRect = function (width, height, radius, caret, x, y){
//**********************************************************************************
// Generation Function: This function returns a rounded Rect with a caret on the
// bottom, it is used to create the pop up bubble
//**********************************************************************************
if(x === undefined){
x = 0;
}
if(y === undefined){
y = 0;
}
if(width === undefined){
width = 100;
}
if(height === undefined){
height = 50;
}
if(radius === undefined){
radius = 5;
}
if(caret === undefined){
caret = 10;
}
return "M" + (x) + "," + (y) +
"l" + ""+ -caret/2 + " " + -(caret/2) +
"h" + ((radius) - (width/2 - (caret)/2)) +
"a" + radius + "," + radius + " 0 0 1 " + -radius +"," + -radius +
"v" + (-height + (2*radius)) +
"a" + radius + "," + radius + " 0 0 1 " + radius +"," + -radius +
"h" + (width - (2*radius)) +
"a" + radius + "," + radius + " 0 0 1 " + radius +"," + radius +
"v" + (height - (2*radius)) +
"a" + radius + "," + radius + " 0 0 1 " + -radius +"," + radius +
"h" + ((radius) - (width/2 - (caret)/2)) +
"l" + ""+ -caret/2 + " " + (caret/2) +
"z";
}