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
a8cf26f8
Commit
a8cf26f8
authored
Feb 27, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bar chart with normal axis - #44
parent
a2137e8a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
12 deletions
+19
-12
c3.js
c3.js
+19
-12
c3.min.js
c3.min.js
+0
-0
No files found.
c3.js
View file @
a8cf26f8
...
@@ -398,8 +398,10 @@
...
@@ -398,8 +398,10 @@
if
(
isCategorized
)
{
if
(
isCategorized
)
{
axis
.
categories
(
__axis_x_categories
).
tickCentered
(
__axis_x_tick_centered
);
axis
.
categories
(
__axis_x_categories
).
tickCentered
(
__axis_x_tick_centered
);
}
else
{
}
else
{
// TODO: fix
axis
.
tickOffset
=
function
()
{
axis
.
tickOffset
=
function
()
{
return
0
;
};
var
base
=
__axis_rotated
?
height
:
width
;
return
((
base
*
getXDomainRatio
())
/
getMaxDataCount
())
/
2
;
};
}
}
return
axis
;
return
axis
;
...
@@ -594,10 +596,21 @@
...
@@ -594,10 +596,21 @@
function
getXDomainMax
(
targets
)
{
function
getXDomainMax
(
targets
)
{
return
d3
.
max
(
targets
,
function
(
t
)
{
return
d3
.
max
(
t
.
values
,
function
(
v
)
{
return
v
.
x
;
});
});
return
d3
.
max
(
targets
,
function
(
t
)
{
return
d3
.
max
(
t
.
values
,
function
(
v
)
{
return
v
.
x
;
});
});
}
}
function
getXDomainPadding
(
targets
,
domain
)
{
var
firstX
=
domain
[
0
],
lastX
=
domain
[
1
],
diff
=
Math
.
abs
(
firstX
-
lastX
),
padding
;
if
(
isCategorized
)
{
padding
=
0
;
}
else
if
(
hasBarType
(
targets
))
{
padding
=
(
diff
/
(
getMaxDataCount
()
-
1
))
/
2
;
}
else
{
padding
=
diff
*
0.01
;
}
return
padding
;
}
function
getXDomain
(
targets
)
{
function
getXDomain
(
targets
)
{
var
xDomain
=
[
getXDomainMin
(
targets
),
getXDomainMax
(
targets
)],
var
xDomain
=
[
getXDomainMin
(
targets
),
getXDomainMax
(
targets
)],
firstX
=
xDomain
[
0
],
lastX
=
xDomain
[
1
],
firstX
=
xDomain
[
0
],
lastX
=
xDomain
[
1
],
padding
=
isCategorized
?
0
:
Math
.
abs
(
firstX
-
lastX
)
*
0.01
,
padding
=
getXDomainPadding
(
targets
,
xDomain
)
,
min
=
isTimeSeries
?
new
Date
(
firstX
.
getTime
()
-
padding
)
:
firstX
-
padding
,
min
=
isTimeSeries
?
new
Date
(
firstX
.
getTime
()
-
padding
)
:
firstX
-
padding
,
max
=
isTimeSeries
?
new
Date
(
lastX
.
getTime
()
+
padding
)
:
lastX
+
padding
;
max
=
isTimeSeries
?
new
Date
(
lastX
.
getTime
()
+
padding
)
:
lastX
+
padding
;
return
[
min
,
max
];
return
[
min
,
max
];
...
@@ -1050,14 +1063,8 @@
...
@@ -1050,14 +1063,8 @@
return
offset
;
return
offset
;
};
};
}
}
function
getBarW
(
axis
,
barTargetsNum
,
isSub
)
{
function
getBarW
(
axis
,
barTargetsNum
)
{
var
barW
;
return
barTargetsNum
?
(
axis
.
tickOffset
()
*
2
*
0.6
)
/
barTargetsNum
:
0
;
if
(
isCategorized
)
{
barW
=
barTargetsNum
?
(
axis
.
tickOffset
()
*
2
*
0.6
)
/
barTargetsNum
:
0
;
}
else
{
barW
=
(((
__axis_rotated
?
height
:
width
)
*
getXDomainRatio
(
isSub
))
/
(
getMaxDataCount
()
-
1
))
*
0.6
;
}
return
barW
;
}
}
//-- Type --//
//-- Type --//
...
@@ -1321,7 +1328,7 @@
...
@@ -1321,7 +1328,7 @@
var
drawBar
=
function
(
barIndices
,
isSub_
)
{
var
drawBar
=
function
(
barIndices
,
isSub_
)
{
var
barTargetsNum
=
barIndices
.
__max__
+
1
,
var
barTargetsNum
=
barIndices
.
__max__
+
1
,
isSub
=
arguments
.
length
>
1
?
isSub_
:
true
,
isSub
=
arguments
.
length
>
1
?
isSub_
:
true
,
barW
=
getBarW
(
xAxis
,
barTargetsNum
,
!!
isSub
),
barW
=
getBarW
(
xAxis
,
barTargetsNum
),
x
=
getBarX
(
barW
,
barTargetsNum
,
barIndices
,
!!
isSub
),
x
=
getBarX
(
barW
,
barTargetsNum
,
barIndices
,
!!
isSub
),
y
=
getBarY
(
!!
isSub
),
y
=
getBarY
(
!!
isSub
),
barOffset
=
getBarOffset
(
barIndices
,
!!
isSub
),
barOffset
=
getBarOffset
(
barIndices
,
!!
isSub
),
...
...
c3.min.js
View file @
a8cf26f8
This diff is collapsed.
Click to expand it.
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