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
d56a4039
Commit
d56a4039
authored
Nov 18, 2015
by
Evgeny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add colorPattern updater
parent
75082c29
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
2 deletions
+50
-2
c3.js
c3.js
+12
-1
api.color-spec.js
spec/api.color-spec.js
+26
-0
api.color.js
src/api.color.js
+12
-0
color.js
src/color.js
+0
-1
No files found.
c3.js
View file @
d56a4039
...
...
@@ -6058,7 +6058,6 @@
else
{
if
(
ids
.
indexOf
(
id
)
<
0
)
{
ids
.
push
(
id
);
}
color
=
pattern
[
ids
.
indexOf
(
id
)
%
pattern
.
length
];
colors
[
id
]
=
color
;
}
return
callback
instanceof
Function
?
callback
(
color
,
d
)
:
color
;
};
...
...
@@ -7646,6 +7645,18 @@
return
$$
.
color
(
id
);
// more patterns
};
c3_chart_fn
.
colorPattern
=
function
(
pattern
){
var
$$
=
this
.
internal
;
if
(
!
pattern
){
return
$$
.
config
.
color_pattern
;
}
$$
.
config
.
color_pattern
=
pattern
;
$$
.
color
=
$$
.
generateColor
();
};
c3_chart_fn
.
x
=
function
(
x
)
{
var
$$
=
this
.
internal
;
if
(
arguments
.
length
)
{
...
...
spec/api.color-spec.js
0 → 100644
View file @
d56a4039
describe
(
"c3 chart"
,
function
(){
'use strict'
;
var
chart
;
var
args
=
{
data
:
{
columns
:
[
[
'data1'
,
30
,
200
,
100
,
400
,
150
,
250
],
[
'data2'
,
5000
,
2000
,
1000
,
4000
,
1500
,
2500
]
]
}
};
beforeEach
(
function
(
done
)
{
chart
=
window
.
initChart
(
chart
,
args
,
done
);
});
describe
(
"colorPattern"
,
function
(){
it
(
"should update pattern"
,
function
(){
chart
.
colorPattern
([
'#fff'
,
'#000'
,
'#fff'
,
'#fff'
]);
expect
(
chart
.
color
(
"data1"
)).
toBe
(
"#fff"
);
expect
(
chart
.
color
(
"data2"
)).
toBe
(
"#000"
);
});
});
});
src/api.color.js
View file @
d56a4039
...
...
@@ -3,3 +3,15 @@ c3_chart_fn.color = function (id) {
var
$$
=
this
.
internal
;
return
$$
.
color
(
id
);
// more patterns
};
c3_chart_fn
.
colorPattern
=
function
(
pattern
){
var
$$
=
this
.
internal
;
if
(
!
pattern
){
return
$$
.
config
.
color_pattern
;
}
$$
.
config
.
color_pattern
=
pattern
;
$$
.
color
=
$$
.
generateColor
();
};
src/color.js
View file @
d56a4039
...
...
@@ -20,7 +20,6 @@ c3_chart_internal_fn.generateColor = function () {
else
{
if
(
ids
.
indexOf
(
id
)
<
0
)
{
ids
.
push
(
id
);
}
color
=
pattern
[
ids
.
indexOf
(
id
)
%
pattern
.
length
];
colors
[
id
]
=
color
;
}
return
callback
instanceof
Function
?
callback
(
color
,
d
)
:
color
;
};
...
...
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