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
d26da94a
Commit
d26da94a
authored
May 23, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify color.values to color.threshold
parent
52ba1080
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
16 deletions
+20
-16
c3.js
c3.js
+15
-15
chart_arc_gauge.html
htdocs/samples/chart_arc_gauge.html
+5
-1
No files found.
c3.js
View file @
d26da94a
...
@@ -170,7 +170,7 @@
...
@@ -170,7 +170,7 @@
// color
// color
var
__color_pattern
=
getConfig
([
'color'
,
'pattern'
],
[]),
var
__color_pattern
=
getConfig
([
'color'
,
'pattern'
],
[]),
__color_
values
=
getConfig
([
'color'
,
'values'
],
[]
);
__color_
threshold
=
getConfig
([
'color'
,
'threshold'
],
{}
);
// legend
// legend
var
__legend_show
=
getConfig
([
'legend'
,
'show'
],
true
),
var
__legend_show
=
getConfig
([
'legend'
,
'show'
],
true
),
...
@@ -294,7 +294,7 @@
...
@@ -294,7 +294,7 @@
name
=
d
[
i
].
name
;
name
=
d
[
i
].
name
;
value
=
valueFormat
(
d
[
i
].
value
,
d
[
i
].
ratio
,
d
[
i
].
id
,
d
[
i
].
index
);
value
=
valueFormat
(
d
[
i
].
value
,
d
[
i
].
ratio
,
d
[
i
].
id
,
d
[
i
].
index
);
bgcolor
=
(
__gauge_style
===
'arc'
&&
__color_values
)
?
levelColor
(
d
[
i
].
value
)
:
color
(
d
[
i
].
id
);
bgcolor
=
levelColor
?
levelColor
(
d
[
i
].
value
)
:
color
(
d
[
i
].
id
);
text
+=
"<tr class='"
+
CLASS
.
tooltipName
+
"-"
+
d
[
i
].
id
+
"'>"
;
text
+=
"<tr class='"
+
CLASS
.
tooltipName
+
"-"
+
d
[
i
].
id
+
"'>"
;
text
+=
"<td class='name'><span style='background-color:"
+
bgcolor
+
"'></span>"
+
name
+
"</td>"
;
text
+=
"<td class='name'><span style='background-color:"
+
bgcolor
+
"'></span>"
+
name
+
"</td>"
;
...
@@ -325,7 +325,7 @@
...
@@ -325,7 +325,7 @@
var
defaultColorPattern
=
d3
.
scale
.
category10
().
range
(),
var
defaultColorPattern
=
d3
.
scale
.
category10
().
range
(),
color
=
generateColor
(
__data_colors
,
notEmpty
(
__color_pattern
)
?
__color_pattern
:
defaultColorPattern
,
__data_color
),
color
=
generateColor
(
__data_colors
,
notEmpty
(
__color_pattern
)
?
__color_pattern
:
defaultColorPattern
,
__data_color
),
levelColor
=
generateLevelColor
(
__color_pattern
,
__color_values
)
;
levelColor
=
notEmpty
(
__color_threshold
)
?
generateLevelColor
(
__color_pattern
,
__color_threshold
)
:
null
;
var
timeFormat
=
__axis_x_localtime
?
d3
.
time
.
format
:
d3
.
time
.
format
.
utc
,
var
timeFormat
=
__axis_x_localtime
?
d3
.
time
.
format
:
d3
.
time
.
format
.
utc
,
defaultTimeFormat
=
timeFormat
.
multi
([
defaultTimeFormat
=
timeFormat
.
multi
([
...
@@ -2229,20 +2229,20 @@
...
@@ -2229,20 +2229,20 @@
};
};
}
}
function
generateLevelColor
(
_colors
,
_values
)
{
function
generateLevelColor
(
colors
,
threshold
)
{
var
colors
=
_colors
,
var
asValue
=
threshold
.
unit
===
'value'
,
levels
=
_values
;
values
=
threshold
.
values
&&
threshold
.
values
.
length
?
threshold
.
values
:
[],
max
=
threshold
.
max
||
100
;
return
function
(
value
)
{
return
function
(
value
)
{
for
(
var
a
=
1
;
a
<
levels
.
length
;
a
++
)
{
var
i
,
v
,
color
=
colors
[
colors
.
length
-
1
];
if
(
levels
[
0
]
===
'percentage'
&&
((
value
/
__gauge_max
)
*
100
)
<
levels
[
a
]
)
{
for
(
i
=
0
;
i
<
values
.
length
;
i
++
)
{
return
colors
[
a
-
1
]
;
v
=
asValue
?
value
:
(
value
*
100
/
max
)
;
}
if
(
v
<
values
[
i
])
{
if
(
levels
[
0
]
===
'whole'
&&
value
<
levels
[
a
])
{
color
=
colors
[
i
];
return
colors
[
a
-
1
]
;
break
;
}
}
}
}
return
color
s
[
colors
.
length
-
1
]
;
return
color
;
};
};
}
}
...
@@ -3751,7 +3751,7 @@
...
@@ -3751,7 +3751,7 @@
})
})
.
attr
(
"transform"
,
withTransform
?
"scale(1)"
:
""
)
.
attr
(
"transform"
,
withTransform
?
"scale(1)"
:
""
)
.
style
(
"fill"
,
function
(
d
)
{
.
style
(
"fill"
,
function
(
d
)
{
return
(
__gauge_style
===
'arc'
&&
__color_values
)
?
levelColor
(
d
.
data
.
values
[
0
].
value
)
:
color
(
d
.
data
.
id
);
return
levelColor
?
levelColor
(
d
.
data
.
values
[
0
].
value
)
:
color
(
d
.
data
.
id
);
})
// Where gauge reading color would receive customization.
})
// Where gauge reading color would receive customization.
.
style
(
"opacity"
,
1
)
.
style
(
"opacity"
,
1
)
.
call
(
endall
,
function
()
{
.
call
(
endall
,
function
()
{
...
...
htdocs/samples/chart_arc_gauge.html
View file @
d26da94a
...
@@ -38,7 +38,11 @@
...
@@ -38,7 +38,11 @@
},
},
color
:
{
color
:
{
pattern
:
[
'#FF0000'
,
'#F6C600'
,
'#60B044'
],
// the three color levels for the percentage values.
pattern
:
[
'#FF0000'
,
'#F6C600'
,
'#60B044'
],
// the three color levels for the percentage values.
values
:
[
'percentage'
,
30
,
60
,
90
]
// alternate first value is 'value'
threshold
:
{
// unit: 'value', // percentage is default
// max: 200, // 100 is default
values
:
[
30
,
60
,
90
]
// alternate first value is 'value'
}
}
}
});
});
...
...
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