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
c42899d0
Commit
c42899d0
authored
Nov 13, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix y axis timeseries - #703
parent
0e37a5b2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
37 deletions
+53
-37
c3.js
c3.js
+13
-14
c3.min.js
c3.min.js
+0
-0
axis-spec.js
spec/axis-spec.js
+27
-9
axis.js
src/axis.js
+6
-6
config.js
src/config.js
+2
-4
core.js
src/core.js
+4
-3
scale.js
src/scale.js
+1
-1
No files found.
c3.js
View file @
c42899d0
...
...
@@ -657,9 +657,6 @@
c3_chart_internal_fn
.
isTimeSeries
=
function
()
{
return
this
.
config
.
axis_x_type
===
'timeseries'
;
};
c3_chart_internal_fn
.
isYaxisTimeSeries
=
function
()
{
return
this
.
config
.
axis_y_type
===
'timeseries'
;
};
c3_chart_internal_fn
.
isCategorized
=
function
()
{
return
this
.
config
.
axis_x_type
.
indexOf
(
'categor'
)
>=
0
;
};
...
...
@@ -668,6 +665,10 @@
return
!
$$
.
isTimeSeries
()
&&
(
config
.
data_x
||
notEmpty
(
config
.
data_xs
));
};
c3_chart_internal_fn
.
isTimeSeriesY
=
function
()
{
return
this
.
config
.
axis_y_type
===
'timeseries'
;
};
c3_chart_internal_fn
.
getTranslate
=
function
(
target
)
{
var
$$
=
this
,
config
=
$$
.
config
,
x
,
y
;
if
(
target
===
'main'
)
{
...
...
@@ -1008,10 +1009,8 @@
axis_y_tick_outer
:
true
,
axis_y_tick_values
:
null
,
axis_y_tick_count
:
undefined
,
axis_y_ticks
:
{},
axis_y_ticks_time
:
{},
axis_y_ticks_time_value
:
undefined
,
axis_y_ticks_time_interval
:
undefined
,
axis_y_tick_time_value
:
undefined
,
axis_y_tick_time_interval
:
undefined
,
axis_y_padding
:
{},
axis_y_default
:
undefined
,
axis_y2_show
:
false
,
...
...
@@ -1164,7 +1163,7 @@
return
scale
;
};
c3_chart_internal_fn
.
getY
=
function
(
min
,
max
,
domain
)
{
var
scale
=
this
.
getScale
(
min
,
max
,
this
.
is
YaxisTimeSeries
());
var
scale
=
this
.
getScale
(
min
,
max
,
this
.
is
TimeSeriesY
());
if
(
domain
)
{
scale
.
domain
(
domain
);
}
return
scale
;
};
...
...
@@ -3989,14 +3988,14 @@
return
axis
;
};
c3_chart_internal_fn
.
getYAxis
=
function
(
scale
,
orient
,
tickFormat
,
tickValues
,
withOuterTick
)
{
var
axisParams
=
{
withOuterTick
:
withOuterTick
};
if
(
this
.
isYaxisTimeSeries
())
{
var
timeValue
=
this
.
config
.
axis_y_ticks_time_value
;
var
timeInterval
=
this
.
config
.
axis_y_ticks_time_interval
;
return
c3_axis
(
this
.
d3
,
axisParams
).
scale
(
scale
).
orient
(
orient
).
tickFormat
(
tickFormat
).
ticks
(
this
.
d3
.
time
[
timeValue
],
timeInterval
);
var
axisParams
=
{
withOuterTick
:
withOuterTick
},
axis
=
c3_axis
(
this
.
d3
,
axisParams
).
scale
(
scale
).
orient
(
orient
).
tickFormat
(
tickFormat
);
if
(
this
.
isTimeSeriesY
())
{
axis
.
ticks
(
this
.
d3
.
time
[
this
.
config
.
axis_y_tick_time_value
],
this
.
config
.
axis_y_tick_time_interval
);
}
else
{
return
c3_axis
(
this
.
d3
,
axisParams
).
scale
(
scale
).
orient
(
orient
).
tickFormat
(
tickFormat
)
.
tickValues
(
tickValues
);
axis
.
tickValues
(
tickValues
);
}
return
axis
;
};
c3_chart_internal_fn
.
getAxisId
=
function
(
id
)
{
var
config
=
this
.
config
;
...
...
c3.min.js
View file @
c42899d0
This source diff could not be displayed because it is too large. You can
view the blob
instead.
spec/axis-spec.js
View file @
c42899d0
...
...
@@ -98,16 +98,10 @@ describe('c3 chart axis', function () {
y
:
{
type
:
'timeseries'
,
tick
:
{
values
:
null
,
count
:
undefined
,
},
ticks
:
{
time
:
{
value
:
'seconds'
,
interval
:
30
time
:
{
}
}
,
}
,
}
}
}
};
...
...
@@ -130,6 +124,30 @@ describe('c3 chart axis', function () {
prevValue
=
d
;
});
});
it
(
'should update args to set axis.y.time'
,
function
()
{
args
.
axis
.
y
.
tick
.
time
=
{
value
:
'seconds'
,
interval
:
60
};
expect
(
true
).
toBeTruthy
();
});
it
(
'should have 4 ticks on y axis'
,
function
()
{
var
ticksSize
=
d3
.
select
(
'.c3-axis-y'
).
selectAll
(
'g.tick'
).
size
();
expect
(
ticksSize
).
toBe
(
4
);
// the count starts at initial value and increments by the set interval
});
it
(
'should have specified 60 second intervals'
,
function
()
{
var
prevValue
;
d3
.
select
(
'.c3-axis-y'
).
selectAll
(
'g.tick'
).
each
(
function
(
d
,
i
)
{
if
(
i
!==
0
)
{
var
result
=
d
-
prevValue
;
expect
(
result
).
toEqual
(
60000
);
// expressed in milliseconds
}
prevValue
=
d
;
});
});
});
describe
(
'axis.x.tick.width'
,
function
()
{
...
...
src/axis.js
View file @
c42899d0
...
...
@@ -64,14 +64,14 @@ c3_chart_internal_fn.getXAxis = function (scale, orient, tickFormat, tickValues,
return
axis
;
};
c3_chart_internal_fn
.
getYAxis
=
function
(
scale
,
orient
,
tickFormat
,
tickValues
,
withOuterTick
)
{
var
axisParams
=
{
withOuterTick
:
withOuterTick
};
if
(
this
.
isYaxisTimeSeries
())
{
var
timeValue
=
this
.
config
.
axis_y_ticks_time_value
;
var
timeInterval
=
this
.
config
.
axis_y_ticks_time_interval
;
return
c3_axis
(
this
.
d3
,
axisParams
).
scale
(
scale
).
orient
(
orient
).
tickFormat
(
tickFormat
).
ticks
(
this
.
d3
.
time
[
timeValue
],
timeInterval
);
var
axisParams
=
{
withOuterTick
:
withOuterTick
},
axis
=
c3_axis
(
this
.
d3
,
axisParams
).
scale
(
scale
).
orient
(
orient
).
tickFormat
(
tickFormat
);
if
(
this
.
isTimeSeriesY
())
{
axis
.
ticks
(
this
.
d3
.
time
[
this
.
config
.
axis_y_tick_time_value
],
this
.
config
.
axis_y_tick_time_interval
);
}
else
{
return
c3_axis
(
this
.
d3
,
axisParams
).
scale
(
scale
).
orient
(
orient
).
tickFormat
(
tickFormat
)
.
tickValues
(
tickValues
);
axis
.
tickValues
(
tickValues
);
}
return
axis
;
};
c3_chart_internal_fn
.
getAxisId
=
function
(
id
)
{
var
config
=
this
.
config
;
...
...
src/config.js
View file @
c42899d0
...
...
@@ -110,10 +110,8 @@ c3_chart_internal_fn.getDefaultConfig = function () {
axis_y_tick_outer
:
true
,
axis_y_tick_values
:
null
,
axis_y_tick_count
:
undefined
,
axis_y_ticks
:
{},
axis_y_ticks_time
:
{},
axis_y_ticks_time_value
:
undefined
,
axis_y_ticks_time_interval
:
undefined
,
axis_y_tick_time_value
:
undefined
,
axis_y_tick_time_interval
:
undefined
,
axis_y_padding
:
{},
axis_y_default
:
undefined
,
axis_y2_show
:
false
,
...
...
src/core.js
View file @
c42899d0
...
...
@@ -652,9 +652,6 @@ c3_chart_internal_fn.updateAndRedraw = function (options) {
c3_chart_internal_fn
.
isTimeSeries
=
function
()
{
return
this
.
config
.
axis_x_type
===
'timeseries'
;
};
c3_chart_internal_fn
.
isYaxisTimeSeries
=
function
()
{
return
this
.
config
.
axis_y_type
===
'timeseries'
;
};
c3_chart_internal_fn
.
isCategorized
=
function
()
{
return
this
.
config
.
axis_x_type
.
indexOf
(
'categor'
)
>=
0
;
};
...
...
@@ -663,6 +660,10 @@ c3_chart_internal_fn.isCustomX = function () {
return
!
$$
.
isTimeSeries
()
&&
(
config
.
data_x
||
notEmpty
(
config
.
data_xs
));
};
c3_chart_internal_fn
.
isTimeSeriesY
=
function
()
{
return
this
.
config
.
axis_y_type
===
'timeseries'
;
};
c3_chart_internal_fn
.
getTranslate
=
function
(
target
)
{
var
$$
=
this
,
config
=
$$
.
config
,
x
,
y
;
if
(
target
===
'main'
)
{
...
...
src/scale.js
View file @
c42899d0
...
...
@@ -39,7 +39,7 @@ c3_chart_internal_fn.getX = function (min, max, domain, offset) {
return
scale
;
};
c3_chart_internal_fn
.
getY
=
function
(
min
,
max
,
domain
)
{
var
scale
=
this
.
getScale
(
min
,
max
,
this
.
is
YaxisTimeSeries
());
var
scale
=
this
.
getScale
(
min
,
max
,
this
.
is
TimeSeriesY
());
if
(
domain
)
{
scale
.
domain
(
domain
);
}
return
scale
;
};
...
...
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