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
13d543f0
Commit
13d543f0
authored
Jul 07, 2016
by
Evgeny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make grid thing out more flexible
parent
6cea1c00
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
28 deletions
+86
-28
c3.js
c3.js
+43
-14
c3.min.js
c3.min.js
+0
-0
c3.axis.js
src/c3.axis.js
+8
-4
grid.js
src/grid.js
+35
-10
No files found.
c3.js
View file @
13d543f0
...
@@ -3864,10 +3864,11 @@
...
@@ -3864,10 +3864,11 @@
xgridData
=
$$
.
generateGridData
(
config
.
grid_x_type
,
$$
.
x
),
xgridData
=
$$
.
generateGridData
(
config
.
grid_x_type
,
$$
.
x
),
tickOffset
=
$$
.
isCategorized
()
?
$$
.
xAxis
.
tickOffset
()
:
0
;
tickOffset
=
$$
.
isCategorized
()
?
$$
.
xAxis
.
tickOffset
()
:
0
;
var
thinOutCoef
=
$$
.
getXThinOutCoef
;
if
(
$$
.
shouldThinOutXGrid
()
){
if
(
thinOutCoef
>
1
){
xgridData
=
xgridData
.
filter
(
function
(
v
,
i
){
xgridData
=
xgridData
.
filter
(
function
(
v
,
i
){
return
i
%
2
==
0
;
return
i
%
thinOutCoef
==
0
;
});
});
}
}
...
@@ -3897,9 +3898,11 @@
...
@@ -3897,9 +3898,11 @@
var
$$
=
this
,
config
=
$$
.
config
,
var
$$
=
this
,
config
=
$$
.
config
,
gridValues
=
$$
.
yAxis
.
tickValues
()
||
$$
.
y
.
ticks
(
config
.
grid_y_ticks
);
gridValues
=
$$
.
yAxis
.
tickValues
()
||
$$
.
y
.
ticks
(
config
.
grid_y_ticks
);
if
(
$$
.
shouldThinOutYGrid
()){
var
thinOutCoef
=
$$
.
getYThinOutCoef
()
if
(
thinOutCoef
>
1
){
gridValues
=
gridValues
.
filter
(
function
(
v
,
i
){
gridValues
=
gridValues
.
filter
(
function
(
v
,
i
){
return
i
%
2
==
0
;
return
i
%
thinOutCoef
==
0
;
});
});
}
}
...
@@ -4074,24 +4077,46 @@
...
@@ -4074,24 +4077,46 @@
}
}
}
}
c3_chart_internal_fn
.
shouldThinOutXGrid
=
function
(){
c3_chart_internal_fn
.
getXThinOutCoef
=
function
(){
var
$$
=
this
,
config
=
$$
.
config
;
var
$$
=
this
,
config
=
$$
.
config
;
var
cv
;
if
(
config
.
axis_rotated
){
if
(
config
.
axis_rotated
){
return
$$
.
getCurrentHeight
()
<=
300
;
cv
=
$$
.
getCurrentHeight
();
}
else
{
cv
=
$$
.
getCurrentWidth
();
}
if
(
cv
<=
150
){
return
3
;
}
else
if
(
cv
<=
300
){
return
2
;
}
else
{
}
else
{
return
$$
.
getCurrentWidth
()
<=
300
;
return
1
;
}
}
};;
};;
c3_chart_internal_fn
.
shouldThinOutYGrid
=
function
(){
c3_chart_internal_fn
.
getYThinOutCoef
=
function
(){
var
$$
=
this
,
config
=
$$
.
config
;
var
$$
=
this
,
config
=
$$
.
config
;
var
cv
;
if
(
config
.
axis_rotated
){
if
(
config
.
axis_rotated
){
return
$$
.
getCurrentWidth
()
<=
300
;
cv
=
$$
.
getCurrentWidth
()
;
}
else
{
}
else
{
return
$$
.
getCurrentHeight
()
<=
300
;
cv
=
$$
.
getCurrentHeight
();
}
if
(
cv
<=
150
){
return
3
;
}
else
if
(
cv
<=
300
){
return
2
;
}
else
{
return
1
;
}
}
};
};
c3_chart_internal_fn
.
initTooltip
=
function
()
{
c3_chart_internal_fn
.
initTooltip
=
function
()
{
...
@@ -8254,16 +8279,20 @@
...
@@ -8254,16 +8279,20 @@
switch
(
orient
){
switch
(
orient
){
case
"bottom"
:
case
"bottom"
:
case
"top"
:
case
"top"
:
if
(
$$
.
shouldThinOutXGrid
()){
if
(
$$
.
config
.
grid_x_show
){
var
coef
=
$$
.
getXThinOutCoef
();
line
.
style
(
'display'
,
function
(
d
,
i
){
line
.
style
(
'display'
,
function
(
d
,
i
){
return
i
%
2
==
0
?
'block'
:
'none'
;
return
i
%
coef
==
0
?
'block'
:
'none'
;
});
});
}
}
case
"left"
:
case
"left"
:
case
"right"
:
case
"right"
:
if
(
$$
.
shouldThinOutYGrid
()){
if
(
$$
.
config
.
grid_y_show
){
var
coef
=
$$
.
getYThinOutCoef
();
line
.
style
(
'display'
,
function
(
d
,
i
){
line
.
style
(
'display'
,
function
(
d
,
i
){
return
i
%
2
==
0
?
'block'
:
'none'
;
return
i
%
coef
==
0
?
'block'
:
'none'
;
});
});
}
}
}
}
...
...
c3.min.js
View file @
13d543f0
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/c3.axis.js
View file @
13d543f0
...
@@ -222,16 +222,20 @@ function c3_axis(d3, params, $$) {
...
@@ -222,16 +222,20 @@ function c3_axis(d3, params, $$) {
switch
(
orient
){
switch
(
orient
){
case
"bottom"
:
case
"bottom"
:
case
"top"
:
case
"top"
:
if
(
$$
.
shouldThinOutXGrid
()){
if
(
$$
.
config
.
grid_x_show
){
var
coef
=
$$
.
getXThinOutCoef
();
line
.
style
(
'display'
,
function
(
d
,
i
){
line
.
style
(
'display'
,
function
(
d
,
i
){
return
i
%
2
==
0
?
'block'
:
'none'
;
return
i
%
coef
==
0
?
'block'
:
'none'
;
});
});
}
}
case
"left"
:
case
"left"
:
case
"right"
:
case
"right"
:
if
(
$$
.
shouldThinOutYGrid
()){
if
(
$$
.
config
.
grid_y_show
){
var
coef
=
$$
.
getYThinOutCoef
();
line
.
style
(
'display'
,
function
(
d
,
i
){
line
.
style
(
'display'
,
function
(
d
,
i
){
return
i
%
2
==
0
?
'block'
:
'none'
;
return
i
%
coef
==
0
?
'block'
:
'none'
;
});
});
}
}
}
}
...
...
src/grid.js
View file @
13d543f0
...
@@ -32,10 +32,11 @@ c3_chart_internal_fn.updateXGrid = function (withoutUpdate) {
...
@@ -32,10 +32,11 @@ c3_chart_internal_fn.updateXGrid = function (withoutUpdate) {
xgridData
=
$$
.
generateGridData
(
config
.
grid_x_type
,
$$
.
x
),
xgridData
=
$$
.
generateGridData
(
config
.
grid_x_type
,
$$
.
x
),
tickOffset
=
$$
.
isCategorized
()
?
$$
.
xAxis
.
tickOffset
()
:
0
;
tickOffset
=
$$
.
isCategorized
()
?
$$
.
xAxis
.
tickOffset
()
:
0
;
var
thinOutCoef
=
$$
.
getXThinOutCoef
;
if
(
$$
.
shouldThinOutXGrid
()
){
if
(
thinOutCoef
>
1
){
xgridData
=
xgridData
.
filter
(
function
(
v
,
i
){
xgridData
=
xgridData
.
filter
(
function
(
v
,
i
){
return
i
%
2
==
0
;
return
i
%
thinOutCoef
==
0
;
});
});
}
}
...
@@ -65,9 +66,11 @@ c3_chart_internal_fn.updateYGrid = function () {
...
@@ -65,9 +66,11 @@ c3_chart_internal_fn.updateYGrid = function () {
var
$$
=
this
,
config
=
$$
.
config
,
var
$$
=
this
,
config
=
$$
.
config
,
gridValues
=
$$
.
yAxis
.
tickValues
()
||
$$
.
y
.
ticks
(
config
.
grid_y_ticks
);
gridValues
=
$$
.
yAxis
.
tickValues
()
||
$$
.
y
.
ticks
(
config
.
grid_y_ticks
);
if
(
$$
.
shouldThinOutYGrid
()){
var
thinOutCoef
=
$$
.
getYThinOutCoef
()
if
(
thinOutCoef
>
1
){
gridValues
=
gridValues
.
filter
(
function
(
v
,
i
){
gridValues
=
gridValues
.
filter
(
function
(
v
,
i
){
return
i
%
2
==
0
;
return
i
%
thinOutCoef
==
0
;
});
});
}
}
...
@@ -242,22 +245,44 @@ c3_chart_internal_fn.removeGridLines = function (params, forX) {
...
@@ -242,22 +245,44 @@ c3_chart_internal_fn.removeGridLines = function (params, forX) {
}
}
}
}
c3_chart_internal_fn
.
shouldThinOutXGrid
=
function
(){
c3_chart_internal_fn
.
getXThinOutCoef
=
function
(){
var
$$
=
this
,
config
=
$$
.
config
;
var
$$
=
this
,
config
=
$$
.
config
;
var
cv
;
if
(
config
.
axis_rotated
){
if
(
config
.
axis_rotated
){
return
$$
.
getCurrentHeight
()
<=
300
;
cv
=
$$
.
getCurrentHeight
();
}
else
{
cv
=
$$
.
getCurrentWidth
();
}
if
(
cv
<=
150
){
return
3
;
}
else
if
(
cv
<=
300
){
return
2
;
}
else
{
}
else
{
return
$$
.
getCurrentWidth
()
<=
300
;
return
1
;
}
}
};;
};;
c3_chart_internal_fn
.
shouldThinOutYGrid
=
function
(){
c3_chart_internal_fn
.
getYThinOutCoef
=
function
(){
var
$$
=
this
,
config
=
$$
.
config
;
var
$$
=
this
,
config
=
$$
.
config
;
var
cv
;
if
(
config
.
axis_rotated
){
if
(
config
.
axis_rotated
){
return
$$
.
getCurrentWidth
()
<=
300
;
cv
=
$$
.
getCurrentWidth
();
}
else
{
cv
=
$$
.
getCurrentHeight
();
}
if
(
cv
<=
150
){
return
3
;
}
else
if
(
cv
<=
300
){
return
2
;
}
else
{
}
else
{
return
$$
.
getCurrentHeight
()
<=
300
;
return
1
;
}
}
};
};
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