Browse Source

Fix bug for flow with indexed data

pull/310/head
Masayuki Tanaka 11 years ago
parent
commit
d313e586e0
  1. 12
      c3.js
  2. 4
      c3.min.js
  3. 17
      htdocs/samples/api_flow.html
  4. 15
      htdocs/samples/api_flow_timeseries.html

12
c3.js

@ -4053,17 +4053,13 @@
// generate transform to flow
if (!options.flow.orgDataCount) { // if empty
if (isTimeSeries) {
if (c3.data.targets[0].values.length !== 1) {
translateX = x(orgDomain[0]) - x(domain[0]);
} else {
if (c3.data.targets[0].values.length !== 1) {
translateX = x(orgDomain[0]) - x(domain[0]);
} else {
if (isTimeSeries) {
flowStart = getValueOnIndex(c3.data.targets[0].values, 0);
flowEnd = getValueOnIndex(c3.data.targets[0].values, c3.data.targets[0].values.length - 1);
translateX = x(flowStart.x) - x(flowEnd.x);
}
} else {
if (c3.data.targets[0].values.length !== 1) {
translateX = (domain[0] - orgDomain[0] >= 1 ? x(orgDomain[0]) : 0) - x(flowEnd.x);
} else {
translateX = diffDomain(domain) / 2;
}

4
c3.min.js vendored

File diff suppressed because one or more lines are too long

17
htdocs/samples/api_flow.html

@ -15,16 +15,13 @@
<script src="/js/c3.js"></script>
<script>
var padding = {}, chart, generate = function () { return c3.generate({
var padding = {}, types = {}, chart, generate = function () { return c3.generate({
data: {
columns: [
['data1'],
['data2'],
],
types: {
data2: 'area',
data3: 'bar',
},
types: types,
labels: true
},
bar: {
@ -205,11 +202,21 @@
run();
// Test for no padding
setTimeout(function () {
padding = {left: 0, right: 0};
run();
}, 22000);
// Test for other chart types
setTimeout(function () {
types = {
data2: 'area',
data3: 'bar',
};
run();
}, 45000);
</script>
</body>
</html>

15
htdocs/samples/api_flow_timeseries.html

@ -9,7 +9,7 @@
<script src="/js/c3.js"></script>
<script>
var padding = {};
var padding = {}, types = {};
var generate = function () { return c3.generate({
data: {
@ -23,10 +23,7 @@
// ['data2', 310, 400, 200, 100, 450, 150],
// ['data3', 310, 400, 200, 100, null, 150],
],
types: {
data2: 'area',
data3: 'bar',
},
types: types,
// labels: true
},
bar: {
@ -163,6 +160,14 @@
run();
}, 25000);
setTimeout(function () {
types = {
data2: 'area',
data3: 'bar',
}
run();
}, 50000);
</script>
</body>
</html>

Loading…
Cancel
Save