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
96979be2
Commit
96979be2
authored
Apr 28, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix x axis tick logic - #151
parent
dd3667ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
16 deletions
+15
-16
c3.js
c3.js
+15
-16
c3.min.js
c3.min.js
+0
-0
No files found.
c3.js
View file @
96979be2
...
@@ -578,7 +578,7 @@
...
@@ -578,7 +578,7 @@
//-- Scales --//
//-- Scales --//
function
updateScales
()
{
function
updateScales
()
{
var
xAxisTickFormat
,
forInit
=
!
x
;
var
xAxisTickFormat
,
xAxisTickValues
,
forInit
=
!
x
;
// update edges
// update edges
xMin
=
__axis_rotated
?
1
:
0
;
xMin
=
__axis_rotated
?
1
:
0
;
xMax
=
__axis_rotated
?
height
:
width
;
xMax
=
__axis_rotated
?
height
:
width
;
...
@@ -597,8 +597,9 @@
...
@@ -597,8 +597,9 @@
subY2
=
getY
(
subYMin
,
subYMax
,
forInit
?
undefined
:
subY2
.
domain
());
subY2
=
getY
(
subYMin
,
subYMax
,
forInit
?
undefined
:
subY2
.
domain
());
// update axes
// update axes
xAxisTickFormat
=
getXAxisTickFormat
();
xAxisTickFormat
=
getXAxisTickFormat
();
xAxis
=
getXAxis
(
x
,
xOrient
,
xAxisTickFormat
);
xAxisTickValues
=
__axis_x_tick_values
?
__axis_x_tick_values
:
(
forInit
?
undefined
:
xAxis
.
tickValues
());
subXAxis
=
getXAxis
(
subX
,
subXOrient
,
xAxisTickFormat
);
xAxis
=
getXAxis
(
x
,
xOrient
,
xAxisTickFormat
,
xAxisTickValues
);
subXAxis
=
getXAxis
(
subX
,
subXOrient
,
xAxisTickFormat
,
xAxisTickValues
);
yAxis
=
getYAxis
(
y
,
yOrient
,
__axis_y_tick_format
,
__axis_y_ticks
);
yAxis
=
getYAxis
(
y
,
yOrient
,
__axis_y_tick_format
,
__axis_y_ticks
);
y2Axis
=
getYAxis
(
y2
,
y2Orient
,
__axis_y2_tick_format
,
__axis_y2_ticks
);
y2Axis
=
getYAxis
(
y2
,
y2Orient
,
__axis_y2_tick_format
,
__axis_y2_ticks
);
// Set initialized scales to brush and zoom
// Set initialized scales to brush and zoom
...
@@ -655,11 +656,11 @@
...
@@ -655,11 +656,11 @@
//-- Axes --//
//-- Axes --//
function
getXAxis
(
scale
,
orient
,
tickFormat
)
{
function
getXAxis
(
scale
,
orient
,
tickFormat
,
tickValues
)
{
var
axis
=
(
isCategorized
?
categoryAxis
()
:
d3
.
svg
.
axis
()).
scale
(
scale
).
orient
(
orient
);
var
axis
=
(
isCategorized
?
categoryAxis
()
:
d3
.
svg
.
axis
()).
scale
(
scale
).
orient
(
orient
);
// Set tick
// Set tick
axis
.
tickFormat
(
tickFormat
);
axis
.
tickFormat
(
tickFormat
)
.
tickValues
(
tickValues
)
;
if
(
isCategorized
)
{
if
(
isCategorized
)
{
axis
.
tickCentered
(
__axis_x_tick_centered
);
axis
.
tickCentered
(
__axis_x_tick_centered
);
if
(
isEmpty
(
__axis_x_tick_culling
))
{
if
(
isEmpty
(
__axis_x_tick_culling
))
{
...
@@ -1628,11 +1629,10 @@
...
@@ -1628,11 +1629,10 @@
var
xs
=
d3
.
set
(
d3
.
merge
(
targets
.
map
(
function
(
t
)
{
return
t
.
values
.
map
(
function
(
v
)
{
return
v
.
x
;
});
}))).
values
();
var
xs
=
d3
.
set
(
d3
.
merge
(
targets
.
map
(
function
(
t
)
{
return
t
.
values
.
map
(
function
(
v
)
{
return
v
.
x
;
});
}))).
values
();
return
isTimeSeries
?
xs
.
map
(
function
(
x
)
{
return
new
Date
(
x
);
})
:
xs
.
map
(
function
(
x
)
{
return
+
x
;
});
return
isTimeSeries
?
xs
.
map
(
function
(
x
)
{
return
new
Date
(
x
);
})
:
xs
.
map
(
function
(
x
)
{
return
+
x
;
});
}
}
function
generateTickValues
(
xs
)
{
function
generateTickValues
(
xs
,
tickCount
)
{
var
tickValues
=
xs
,
targetCount
,
start
,
end
,
count
,
interval
,
i
,
tickValue
;
var
tickValues
=
xs
,
targetCount
,
start
,
end
,
count
,
interval
,
i
,
tickValue
;
if
(
__axis_x_tick_count
)
{
if
(
tickCount
)
{
// TODO: need some arguments for __axis_x_tick_count()?
targetCount
=
typeof
tickCount
===
'function'
?
tickCount
()
:
tickCount
;
targetCount
=
typeof
__axis_x_tick_count
===
'function'
?
__axis_x_tick_count
()
:
__axis_x_tick_count
;
// compute ticks according to __axis_x_tick_count
// compute ticks according to __axis_x_tick_count
if
(
targetCount
===
1
)
{
if
(
targetCount
===
1
)
{
tickValues
=
[
xs
[
0
]];
tickValues
=
[
xs
[
0
]];
...
@@ -3162,18 +3162,17 @@
...
@@ -3162,18 +3162,17 @@
x
.
domain
(
brush
.
empty
()
?
orgXDomain
:
brush
.
extent
());
x
.
domain
(
brush
.
empty
()
?
orgXDomain
:
brush
.
extent
());
if
(
__zoom_enabled
)
{
zoom
.
scale
(
x
).
updateScaleExtent
();
}
if
(
__zoom_enabled
)
{
zoom
.
scale
(
x
).
updateScaleExtent
();
}
}
}
// update axis tick values according to options
if
(
!
__axis_x_tick_values
&&
(
__axis_x_tick_fit
||
__axis_x_tick_count
))
{
tickValues
=
generateTickValues
(
mapTargetsToUniqueXs
(
targetsToShow
),
__axis_x_tick_count
);
xAxis
.
tickValues
(
tickValues
);
subXAxis
.
tickValues
(
tickValues
);
}
}
}
y
.
domain
(
getYDomain
(
targetsToShow
,
'y'
));
y
.
domain
(
getYDomain
(
targetsToShow
,
'y'
));
y2
.
domain
(
getYDomain
(
targetsToShow
,
'y2'
));
y2
.
domain
(
getYDomain
(
targetsToShow
,
'y2'
));
// update axis tick values according to options
if
((
__axis_x_tick_fit
||
__axis_x_tick_count
)
&&
targetsToShow
.
length
)
{
tickValues
=
__axis_x_tick_values
?
__axis_x_tick_values
:
generateTickValues
(
mapTargetsToUniqueXs
(
targetsToShow
));
xAxis
.
tickValues
(
tickValues
);
subXAxis
.
tickValues
(
tickValues
);
}
// axes
// axes
transitions
.
axisX
.
call
(
xAxis
);
transitions
.
axisX
.
call
(
xAxis
);
transitions
.
axisY
.
call
(
yAxis
);
transitions
.
axisY
.
call
(
yAxis
);
...
...
c3.min.js
View file @
96979be2
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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