Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
c3-closed
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
charts
c3-closed
Commits
a02c6757
Commit
a02c6757
authored
Mar 26, 2016
by
Дмитрий Никулин
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for 3 different marker types
parent
6635776d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
6 deletions
+72
-6
Gruntfile.coffee
Gruntfile.coffee
+1
-0
config.js
src/config.js
+1
-0
marker.js
src/marker.js
+64
-0
shape.line.js
src/shape.line.js
+6
-6
No files found.
Gruntfile.coffee
View file @
a02c6757
...
...
@@ -35,6 +35,7 @@ module.exports = (grunt) ->
'src/size.js'
,
'src/shape.js'
,
'src/shape.line.js'
,
'src/marker.js'
,
'src/shape.bar.js'
,
'src/stacked.js'
,
'src/text.js'
,
...
...
src/config.js
View file @
a02c6757
...
...
@@ -151,6 +151,7 @@ c3_chart_internal_fn.getDefaultConfig = function () {
// line
line_connectNull
:
false
,
line_step_type
:
'step'
,
marker_types
:
undefined
,
// bar
bar_width
:
undefined
,
bar_width_ratio
:
0.6
,
...
...
src/marker.js
0 → 100644
View file @
a02c6757
var
marker_fn
=
(
function
()
{
function
create
(
name
){
return
d3
.
select
(
document
.
createElementNS
(
"http://www.w3.org/2000/svg"
,
name
));
}
function
pt
(
point
){
if
(
isNaN
(
point
.
x
+
point
.
y
))
return
''
;
return
point
.
x
+
','
+
point
.
y
;
}
function
buildPath
(
points
){
var
path
=
''
;
for
(
var
i
=
0
;
i
<
points
.
length
;
i
++
){
path
+=
(
points
[
i
].
action
||
'L'
)
+
pt
(
points
[
i
]);
}
return
path
;
}
return
{
circle
:
function
(
size
){
return
create
(
'circle'
).
attr
(
'r'
,
size
/
2
);
},
rhombus
:
function
(
size
){
var
marker
=
create
(
'path'
);
// height/width ratio
var
ratio
=
1
;
size
/=
2
;
var
path
=
buildPath
([
{
action
:
'M'
,
x
:
0
,
y
:
size
},
{
action
:
'L'
,
x
:
size
/
ratio
,
y
:
0
},
{
action
:
'L'
,
x
:
0
,
y
:
-
size
},
{
action
:
'L'
,
x
:
-
size
/
ratio
,
y
:
0
},
{
action
:
'Z'
}
]);
marker
.
attr
(
'd'
,
path
)
.
style
(
'stroke'
,
'none'
);
return
marker
;
},
square
:
function
(
size
){
var
marker
=
create
(
'rect'
);
marker
.
attr
(
'width'
,
size
)
.
attr
(
'height'
,
size
)
.
attr
(
'x'
,
-
size
/
2
)
.
attr
(
'y'
,
-
size
/
2
);
return
marker
;
}
};
})();
c3_chart_internal_fn
.
getMarker
=
function
(
d
,
i
){
var
$$
=
this
;
if
(
!
$$
.
config
.
marker_types
||
!
$$
.
config
.
marker_types
[
d
.
id
]){
return
marker_fn
.
circle
(
$$
.
pointR
(
d
,
i
));
}
return
marker_fn
[
$$
.
config
.
marker_types
[
d
.
id
]](
$$
.
pointR
(
d
,
i
),
$$
.
color
(
d
,
i
)).
node
();
};
\ No newline at end of file
src/shape.line.js
View file @
a02c6757
...
...
@@ -294,9 +294,8 @@ c3_chart_internal_fn.updateCircle = function () {
var
$$
=
this
;
$$
.
mainCircle
=
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
circles
).
selectAll
(
'.'
+
CLASS
.
circle
)
.
data
(
$$
.
lineOrScatterData
.
bind
(
$$
));
$$
.
mainCircle
.
enter
().
append
(
"circle"
)
$$
.
mainCircle
.
enter
().
append
(
$$
.
getMarker
.
bind
(
$$
)
)
.
attr
(
"class"
,
$$
.
classCircle
.
bind
(
$$
))
.
attr
(
"r"
,
$$
.
pointR
.
bind
(
$$
))
.
style
(
"fill"
,
$$
.
color
);
$$
.
mainCircle
.
style
(
"opacity"
,
$$
.
initialOpacityForCircle
.
bind
(
$$
));
...
...
@@ -308,11 +307,12 @@ c3_chart_internal_fn.redrawCircle = function (cx, cy, withTransition) {
(
withTransition
?
this
.
mainCircle
.
transition
()
:
this
.
mainCircle
)
.
style
(
'opacity'
,
this
.
opacityForCircle
.
bind
(
this
))
.
style
(
"fill"
,
this
.
color
)
.
attr
(
"cx"
,
cx
)
.
attr
(
"cy"
,
cy
),
.
attr
(
'transform'
,
function
(
d
,
i
){
return
'translate('
+
cx
(
d
,
i
)
+
' '
+
cy
(
d
,
i
)
+
')'
;
}),
(
withTransition
?
selectedCircles
.
transition
()
:
selectedCircles
)
.
attr
(
"
c
x"
,
cx
)
.
attr
(
"
c
y"
,
cy
)
.
attr
(
"x"
,
cx
)
.
attr
(
"y"
,
cy
)
];
};
c3_chart_internal_fn
.
circleX
=
function
(
d
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment