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
Evgeny
c3-closed
Commits
3ed0373e
Commit
3ed0373e
authored
Oct 22, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix edge of step chart on category axis - #566
parent
6bebdb24
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
26 deletions
+86
-26
c3.js
c3.js
+43
-13
c3.min.js
c3.min.js
+0
-0
data.js
src/data.js
+24
-0
shape.js
src/shape.js
+5
-2
shape.line.js
src/shape.line.js
+14
-11
No files found.
c3.js
View file @
3ed0373e
...
...
@@ -1726,6 +1726,30 @@
yIndex
=
config
.
axis_rotated
?
0
:
1
;
return
Math
.
pow
(
$$
.
x
(
data
.
x
)
-
pos
[
xIndex
],
2
)
+
Math
.
pow
(
yScale
(
data
.
value
)
-
pos
[
yIndex
],
2
);
};
c3_chart_internal_fn
.
convertValuesToStep
=
function
(
values
)
{
var
converted
=
[].
concat
(
values
),
i
;
if
(
!
this
.
isCategorized
())
{
return
values
;
}
for
(
i
=
values
.
length
+
1
;
0
<
i
;
i
--
)
{
converted
[
i
]
=
converted
[
i
-
1
];
}
converted
[
0
]
=
{
x
:
converted
[
0
].
x
-
1
,
value
:
converted
[
0
].
value
,
id
:
converted
[
0
].
id
};
converted
[
values
.
length
+
1
]
=
{
x
:
converted
[
values
.
length
].
x
+
1
,
value
:
converted
[
values
.
length
].
value
,
id
:
converted
[
values
.
length
].
id
};
return
converted
;
};
c3_chart_internal_fn
.
convertUrlToData
=
function
(
url
,
mimeType
,
keys
,
done
)
{
var
$$
=
this
,
type
=
mimeType
?
mimeType
:
'csv'
;
...
...
@@ -2489,9 +2513,12 @@
var
scale
=
isSub
?
$$
.
getSubYScale
(
d
.
id
)
:
$$
.
getYScale
(
d
.
id
),
y0
=
scale
(
0
),
offset
=
y0
;
targets
.
forEach
(
function
(
t
)
{
var
values
=
$$
.
isStepType
(
d
)
?
$$
.
convertValuesToStep
(
t
.
values
)
:
t
.
values
;
if
(
t
.
id
===
d
.
id
||
indices
[
t
.
id
]
!==
indices
[
d
.
id
])
{
return
;
}
if
(
targetIds
.
indexOf
(
t
.
id
)
<
targetIds
.
indexOf
(
d
.
id
)
&&
t
.
values
[
i
].
value
*
d
.
value
>=
0
)
{
offset
+=
scale
(
t
.
values
[
i
].
value
)
-
y0
;
if
(
targetIds
.
indexOf
(
t
.
id
)
<
targetIds
.
indexOf
(
d
.
id
))
{
if
(
values
[
i
].
value
*
d
.
value
>=
0
)
{
offset
+=
scale
(
values
[
i
].
value
)
-
y0
;
}
}
});
return
offset
;
...
...
@@ -2594,18 +2621,19 @@
line
=
config
.
axis_rotated
?
line
.
x
(
yValue
).
y
(
xValue
)
:
line
.
x
(
xValue
).
y
(
yValue
);
if
(
!
config
.
line_connectNull
)
{
line
=
line
.
defined
(
function
(
d
)
{
return
d
.
value
!=
null
;
});
}
return
function
(
d
)
{
var
data
=
config
.
line_connectNull
?
$$
.
filterRemoveNull
(
d
.
values
)
:
d
.
values
,
var
values
=
config
.
line_connectNull
?
$$
.
filterRemoveNull
(
d
.
values
)
:
d
.
values
,
x
=
isSub
?
$$
.
x
:
$$
.
subX
,
y
=
yScaleGetter
.
call
(
$$
,
d
.
id
),
x0
=
0
,
y0
=
0
,
path
;
if
(
$$
.
isLineType
(
d
))
{
if
(
config
.
data_regions
[
d
.
id
])
{
path
=
$$
.
lineWithRegions
(
data
,
x
,
y
,
config
.
data_regions
[
d
.
id
]);
path
=
$$
.
lineWithRegions
(
values
,
x
,
y
,
config
.
data_regions
[
d
.
id
]);
}
else
{
path
=
line
.
interpolate
(
$$
.
getInterpolate
(
d
))(
data
);
if
(
$$
.
isStepType
(
d
))
{
values
=
$$
.
convertValuesToStep
(
values
);
}
path
=
line
.
interpolate
(
$$
.
getInterpolate
(
d
))(
values
);
}
}
else
{
if
(
data
[
0
])
{
x0
=
x
(
data
[
0
].
x
);
y0
=
y
(
data
[
0
].
value
);
if
(
values
[
0
])
{
x0
=
x
(
values
[
0
].
x
);
y0
=
y
(
values
[
0
].
value
);
}
path
=
config
.
axis_rotated
?
"M "
+
y0
+
" "
+
x0
:
"M "
+
x0
+
" "
+
y0
;
}
...
...
@@ -2757,13 +2785,15 @@
}
return
function
(
d
)
{
var
data
=
config
.
line_connectNull
?
$$
.
filterRemoveNull
(
d
.
values
)
:
d
.
values
,
x0
=
0
,
y0
=
0
,
path
;
var
values
=
config
.
line_connectNull
?
$$
.
filterRemoveNull
(
d
.
values
)
:
d
.
values
,
x0
=
0
,
y0
=
0
,
path
;
if
(
$$
.
isAreaType
(
d
))
{
path
=
area
.
interpolate
(
$$
.
getInterpolate
(
d
))(
data
);
if
(
$$
.
isStepType
(
d
))
{
values
=
$$
.
convertValuesToStep
(
values
);
}
path
=
area
.
interpolate
(
$$
.
getInterpolate
(
d
))(
values
);
}
else
{
if
(
data
[
0
])
{
x0
=
$$
.
x
(
data
[
0
].
x
);
y0
=
$$
.
getYScale
(
d
.
id
)(
data
[
0
].
value
);
if
(
values
[
0
])
{
x0
=
$$
.
x
(
values
[
0
].
x
);
y0
=
$$
.
getYScale
(
d
.
id
)(
values
[
0
].
value
);
}
path
=
config
.
axis_rotated
?
"M "
+
y0
+
" "
+
x0
:
"M "
+
x0
+
" "
+
y0
;
}
...
...
c3.min.js
View file @
3ed0373e
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/data.js
View file @
3ed0373e
...
...
@@ -302,3 +302,27 @@ c3_chart_internal_fn.dist = function (data, pos) {
yIndex
=
config
.
axis_rotated
?
0
:
1
;
return
Math
.
pow
(
$$
.
x
(
data
.
x
)
-
pos
[
xIndex
],
2
)
+
Math
.
pow
(
yScale
(
data
.
value
)
-
pos
[
yIndex
],
2
);
};
c3_chart_internal_fn
.
convertValuesToStep
=
function
(
values
)
{
var
converted
=
[].
concat
(
values
),
i
;
if
(
!
this
.
isCategorized
())
{
return
values
;
}
for
(
i
=
values
.
length
+
1
;
0
<
i
;
i
--
)
{
converted
[
i
]
=
converted
[
i
-
1
];
}
converted
[
0
]
=
{
x
:
converted
[
0
].
x
-
1
,
value
:
converted
[
0
].
value
,
id
:
converted
[
0
].
id
};
converted
[
values
.
length
+
1
]
=
{
x
:
converted
[
values
.
length
].
x
+
1
,
value
:
converted
[
values
.
length
].
value
,
id
:
converted
[
values
.
length
].
id
};
return
converted
;
};
src/shape.js
View file @
3ed0373e
...
...
@@ -38,9 +38,12 @@ c3_chart_internal_fn.getShapeOffset = function (typeFilter, indices, isSub) {
var
scale
=
isSub
?
$$
.
getSubYScale
(
d
.
id
)
:
$$
.
getYScale
(
d
.
id
),
y0
=
scale
(
0
),
offset
=
y0
;
targets
.
forEach
(
function
(
t
)
{
var
values
=
$$
.
isStepType
(
d
)
?
$$
.
convertValuesToStep
(
t
.
values
)
:
t
.
values
;
if
(
t
.
id
===
d
.
id
||
indices
[
t
.
id
]
!==
indices
[
d
.
id
])
{
return
;
}
if
(
targetIds
.
indexOf
(
t
.
id
)
<
targetIds
.
indexOf
(
d
.
id
)
&&
t
.
values
[
i
].
value
*
d
.
value
>=
0
)
{
offset
+=
scale
(
t
.
values
[
i
].
value
)
-
y0
;
if
(
targetIds
.
indexOf
(
t
.
id
)
<
targetIds
.
indexOf
(
d
.
id
))
{
if
(
values
[
i
].
value
*
d
.
value
>=
0
)
{
offset
+=
scale
(
values
[
i
].
value
)
-
y0
;
}
}
});
return
offset
;
...
...
src/shape.line.js
View file @
3ed0373e
...
...
@@ -74,18 +74,19 @@ c3_chart_internal_fn.generateDrawLine = function (lineIndices, isSub) {
line
=
config
.
axis_rotated
?
line
.
x
(
yValue
).
y
(
xValue
)
:
line
.
x
(
xValue
).
y
(
yValue
);
if
(
!
config
.
line_connectNull
)
{
line
=
line
.
defined
(
function
(
d
)
{
return
d
.
value
!=
null
;
});
}
return
function
(
d
)
{
var
data
=
config
.
line_connectNull
?
$$
.
filterRemoveNull
(
d
.
values
)
:
d
.
values
,
var
values
=
config
.
line_connectNull
?
$$
.
filterRemoveNull
(
d
.
values
)
:
d
.
values
,
x
=
isSub
?
$$
.
x
:
$$
.
subX
,
y
=
yScaleGetter
.
call
(
$$
,
d
.
id
),
x0
=
0
,
y0
=
0
,
path
;
if
(
$$
.
isLineType
(
d
))
{
if
(
config
.
data_regions
[
d
.
id
])
{
path
=
$$
.
lineWithRegions
(
data
,
x
,
y
,
config
.
data_regions
[
d
.
id
]);
path
=
$$
.
lineWithRegions
(
values
,
x
,
y
,
config
.
data_regions
[
d
.
id
]);
}
else
{
path
=
line
.
interpolate
(
$$
.
getInterpolate
(
d
))(
data
);
if
(
$$
.
isStepType
(
d
))
{
values
=
$$
.
convertValuesToStep
(
values
);
}
path
=
line
.
interpolate
(
$$
.
getInterpolate
(
d
))(
values
);
}
}
else
{
if
(
data
[
0
])
{
x0
=
x
(
data
[
0
].
x
);
y0
=
y
(
data
[
0
].
value
);
if
(
values
[
0
])
{
x0
=
x
(
values
[
0
].
x
);
y0
=
y
(
values
[
0
].
value
);
}
path
=
config
.
axis_rotated
?
"M "
+
y0
+
" "
+
x0
:
"M "
+
x0
+
" "
+
y0
;
}
...
...
@@ -237,13 +238,15 @@ c3_chart_internal_fn.generateDrawArea = function (areaIndices, isSub) {
}
return
function
(
d
)
{
var
data
=
config
.
line_connectNull
?
$$
.
filterRemoveNull
(
d
.
values
)
:
d
.
values
,
x0
=
0
,
y0
=
0
,
path
;
var
values
=
config
.
line_connectNull
?
$$
.
filterRemoveNull
(
d
.
values
)
:
d
.
values
,
x0
=
0
,
y0
=
0
,
path
;
if
(
$$
.
isAreaType
(
d
))
{
path
=
area
.
interpolate
(
$$
.
getInterpolate
(
d
))(
data
);
if
(
$$
.
isStepType
(
d
))
{
values
=
$$
.
convertValuesToStep
(
values
);
}
path
=
area
.
interpolate
(
$$
.
getInterpolate
(
d
))(
values
);
}
else
{
if
(
data
[
0
])
{
x0
=
$$
.
x
(
data
[
0
].
x
);
y0
=
$$
.
getYScale
(
d
.
id
)(
data
[
0
].
value
);
if
(
values
[
0
])
{
x0
=
$$
.
x
(
values
[
0
].
x
);
y0
=
$$
.
getYScale
(
d
.
id
)(
values
[
0
].
value
);
}
path
=
config
.
axis_rotated
?
"M "
+
y0
+
" "
+
x0
:
"M "
+
x0
+
" "
+
y0
;
}
...
...
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