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 // generate transform to flow
if (!options.flow.orgDataCount) { // if empty if (!options.flow.orgDataCount) { // if empty
if (isTimeSeries) { if (c3.data.targets[0].values.length !== 1) {
if (c3.data.targets[0].values.length !== 1) { translateX = x(orgDomain[0]) - x(domain[0]);
translateX = x(orgDomain[0]) - x(domain[0]); } else {
} else { if (isTimeSeries) {
flowStart = getValueOnIndex(c3.data.targets[0].values, 0); flowStart = getValueOnIndex(c3.data.targets[0].values, 0);
flowEnd = getValueOnIndex(c3.data.targets[0].values, c3.data.targets[0].values.length - 1); flowEnd = getValueOnIndex(c3.data.targets[0].values, c3.data.targets[0].values.length - 1);
translateX = x(flowStart.x) - x(flowEnd.x); 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 { } else {
translateX = diffDomain(domain) / 2; 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 src="/js/c3.js"></script>
<script> <script>
var padding = {}, chart, generate = function () { return c3.generate({ var padding = {}, types = {}, chart, generate = function () { return c3.generate({
data: { data: {
columns: [ columns: [
['data1'], ['data1'],
['data2'], ['data2'],
], ],
types: { types: types,
data2: 'area',
data3: 'bar',
},
labels: true labels: true
}, },
bar: { bar: {
@ -205,11 +202,21 @@
run(); run();
// Test for no padding
setTimeout(function () { setTimeout(function () {
padding = {left: 0, right: 0}; padding = {left: 0, right: 0};
run(); run();
}, 22000); }, 22000);
// Test for other chart types
setTimeout(function () {
types = {
data2: 'area',
data3: 'bar',
};
run();
}, 45000);
</script> </script>
</body> </body>
</html> </html>

15
htdocs/samples/api_flow_timeseries.html

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

Loading…
Cancel
Save