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
ee9abc92
Commit
ee9abc92
authored
Sep 20, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix min/max for Gauge chart - #536
parent
9ee5464e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
12 deletions
+57
-12
c3.js
c3.js
+6
-6
c3.min.js
c3.min.js
+0
-0
chart_gauge.html
htdocs/samples/chart_gauge.html
+45
-0
arc.js
src/arc.js
+6
-6
No files found.
c3.js
View file @
ee9abc92
...
...
@@ -4174,7 +4174,8 @@
c3_chart_internal_fn
.
updateAngle
=
function
(
d
)
{
var
$$
=
this
,
config
=
$$
.
config
,
found
=
false
,
index
=
0
;
found
=
false
,
index
=
0
,
gMin
=
config
.
gauge_min
,
gMax
=
config
.
gauge_max
,
gTic
,
gValue
;
$$
.
pie
(
$$
.
filterTargetsToShow
(
$$
.
data
.
targets
)).
forEach
(
function
(
t
)
{
if
(
!
found
&&
t
.
data
.
id
===
d
.
data
.
id
)
{
found
=
true
;
...
...
@@ -4187,11 +4188,10 @@
d
.
endAngle
=
d
.
startAngle
;
}
if
(
$$
.
isGaugeType
(
d
.
data
))
{
var
gMin
=
config
.
gauge_min
,
gMax
=
config
.
gauge_max
,
gF
=
Math
.
abs
(
gMin
)
+
gMax
,
aTic
=
(
Math
.
PI
)
/
gF
;
d
.
startAngle
=
(
-
1
*
(
Math
.
PI
/
2
))
+
(
aTic
*
Math
.
abs
(
gMin
));
d
.
endAngle
=
d
.
startAngle
+
(
aTic
*
((
d
.
value
>
gMax
)
?
gMax
:
d
.
value
));
gTic
=
(
Math
.
PI
)
/
(
gMax
-
gMin
);
gValue
=
d
.
value
<
gMin
?
0
:
d
.
value
<
gMax
?
d
.
value
-
gMin
:
(
gMax
-
gMin
);
d
.
startAngle
=
-
1
*
(
Math
.
PI
/
2
);
d
.
endAngle
=
d
.
startAngle
+
gTic
*
gValue
;
}
return
found
?
d
:
null
;
};
...
...
c3.min.js
View file @
ee9abc92
This source diff could not be displayed because it is too large. You can
view the blob
instead.
htdocs/samples/chart_gauge.html
View file @
ee9abc92
...
...
@@ -4,6 +4,9 @@
</head>
<body>
<div
id=
"chart"
></div>
<div
id=
"chart1"
></div>
<div
id=
"chart2"
></div>
<div
id=
"chart3"
></div>
<script
src=
"http://d3js.org/d3.v3.min.js"
charset=
"utf-8"
></script>
<script
src=
"/js/c3.js"
></script>
...
...
@@ -40,6 +43,48 @@
}
});
var
chart1
=
c3
.
generate
({
bindto
:
'#chart1'
,
data
:
{
columns
:
[
[
'data'
,
75.0
]
],
type
:
'gauge'
,
},
gauge
:
{
min
:
50
,
max
:
100
}
});
var
chart2
=
c3
.
generate
({
bindto
:
'#chart2'
,
data
:
{
columns
:
[
[
'data'
,
0.0
]
],
type
:
'gauge'
,
},
gauge
:
{
min
:
-
100
,
max
:
100
}
});
var
chart3
=
c3
.
generate
({
bindto
:
'#chart3'
,
data
:
{
columns
:
[
[
'data'
,
-
75.0
]
],
type
:
'gauge'
,
},
gauge
:
{
min
:
-
100
,
max
:
-
50
}
});
var
cycleDemo
=
function
()
{
setTimeout
(
function
()
{
...
...
src/arc.js
View file @
ee9abc92
...
...
@@ -26,7 +26,8 @@ c3_chart_internal_fn.updateArc = function () {
c3_chart_internal_fn
.
updateAngle
=
function
(
d
)
{
var
$$
=
this
,
config
=
$$
.
config
,
found
=
false
,
index
=
0
;
found
=
false
,
index
=
0
,
gMin
=
config
.
gauge_min
,
gMax
=
config
.
gauge_max
,
gTic
,
gValue
;
$$
.
pie
(
$$
.
filterTargetsToShow
(
$$
.
data
.
targets
)).
forEach
(
function
(
t
)
{
if
(
!
found
&&
t
.
data
.
id
===
d
.
data
.
id
)
{
found
=
true
;
...
...
@@ -39,11 +40,10 @@ c3_chart_internal_fn.updateAngle = function (d) {
d
.
endAngle
=
d
.
startAngle
;
}
if
(
$$
.
isGaugeType
(
d
.
data
))
{
var
gMin
=
config
.
gauge_min
,
gMax
=
config
.
gauge_max
,
gF
=
Math
.
abs
(
gMin
)
+
gMax
,
aTic
=
(
Math
.
PI
)
/
gF
;
d
.
startAngle
=
(
-
1
*
(
Math
.
PI
/
2
))
+
(
aTic
*
Math
.
abs
(
gMin
));
d
.
endAngle
=
d
.
startAngle
+
(
aTic
*
((
d
.
value
>
gMax
)
?
gMax
:
d
.
value
));
gTic
=
(
Math
.
PI
)
/
(
gMax
-
gMin
);
gValue
=
d
.
value
<
gMin
?
0
:
d
.
value
<
gMax
?
d
.
value
-
gMin
:
(
gMax
-
gMin
);
d
.
startAngle
=
-
1
*
(
Math
.
PI
/
2
);
d
.
endAngle
=
d
.
startAngle
+
gTic
*
gValue
;
}
return
found
?
d
:
null
;
};
...
...
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