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
31a67df5
Commit
31a67df5
authored
Dec 06, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept category name as x value for grid lines - #800
parent
716a2c5c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
4 deletions
+64
-4
c3.js
c3.js
+8
-2
c3.min.js
c3.min.js
+0
-0
grid-spec.js
spec/grid-spec.js
+48
-0
core.js
src/core.js
+8
-2
No files found.
c3.js
View file @
31a67df5
...
...
@@ -738,8 +738,14 @@
return
d
?
this
.
x
(
d
.
x
)
:
null
;
};
c3_chart_internal_fn
.
xv
=
function
(
d
)
{
var
$$
=
this
;
return
Math
.
ceil
(
$$
.
x
(
$$
.
isTimeSeries
()
?
$$
.
parseDate
(
d
.
value
)
:
d
.
value
));
var
$$
=
this
,
value
=
d
.
value
;
if
(
$$
.
isTimeSeries
())
{
value
=
$$
.
parseDate
(
d
.
value
);
}
else
if
(
$$
.
isCategorized
()
&&
typeof
d
.
value
===
'string'
)
{
value
=
$$
.
config
.
axis_x_categories
.
indexOf
(
d
.
value
);
}
return
Math
.
ceil
(
$$
.
x
(
value
));
};
c3_chart_internal_fn
.
yv
=
function
(
d
)
{
var
$$
=
this
,
...
...
c3.min.js
View file @
31a67df5
This source diff could not be displayed because it is too large. You can
view the blob
instead.
spec/grid-spec.js
View file @
31a67df5
...
...
@@ -80,4 +80,52 @@ describe('c3 chart grid', function () {
});
});
describe
(
'x grid lines'
,
function
()
{
describe
(
'on category axis'
,
function
()
{
it
(
'should update args'
,
function
()
{
args
=
{
data
:
{
x
:
'x'
,
columns
:
[
[
'x'
,
'a'
,
'b'
,
'c'
,
'd'
],
[
'data1'
,
30
,
200
,
100
,
400
],
]
},
axis
:
{
x
:
{
type
:
'category'
}
},
grid
:
{
x
:
{
lines
:
[
{
value
:
3
,
text
:
'Label 3'
},
{
value
:
'a'
,
text
:
'Label a'
}
]
}
}
};
expect
(
true
).
toBeTruthy
();
});
it
(
'should show x grid lines'
,
function
()
{
var
lines
=
chart
.
internal
.
main
.
selectAll
(
'.c3-xgrid-lines .c3-xgrid-line'
),
expectedX1
=
[
515
,
74
],
expectedText
=
[
'Label 3'
,
'Label a'
];
lines
.
each
(
function
(
id
,
i
)
{
var
line
=
d3
.
select
(
this
),
l
=
line
.
select
(
'line'
),
t
=
line
.
select
(
'text'
);
expect
(
+
l
.
attr
(
'x1'
)).
toBeCloseTo
(
expectedX1
[
i
],
-
1
);
expect
(
t
.
text
()).
toBe
(
expectedText
[
i
]);
});
});
});
});
});
src/core.js
View file @
31a67df5
...
...
@@ -733,8 +733,14 @@ c3_chart_internal_fn.xx = function (d) {
return
d
?
this
.
x
(
d
.
x
)
:
null
;
};
c3_chart_internal_fn
.
xv
=
function
(
d
)
{
var
$$
=
this
;
return
Math
.
ceil
(
$$
.
x
(
$$
.
isTimeSeries
()
?
$$
.
parseDate
(
d
.
value
)
:
d
.
value
));
var
$$
=
this
,
value
=
d
.
value
;
if
(
$$
.
isTimeSeries
())
{
value
=
$$
.
parseDate
(
d
.
value
);
}
else
if
(
$$
.
isCategorized
()
&&
typeof
d
.
value
===
'string'
)
{
value
=
$$
.
config
.
axis_x_categories
.
indexOf
(
d
.
value
);
}
return
Math
.
ceil
(
$$
.
x
(
value
));
};
c3_chart_internal_fn
.
yv
=
function
(
d
)
{
var
$$
=
this
,
...
...
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