Browse Source

Can now change legend position

pull/763/head
CallumVass 10 years ago
parent
commit
7b5f1a04fd
  1. 8
      .gitignore
  2. 812
      c3.js
  3. 2
      c3.min.js
  4. 6755
      htdocs/js/c3.js
  5. 6
      htdocs/js/c3.min.js
  6. 272
      htdocs/samples/api_legend.html
  7. 6
      src/api.legend.js

8
.gitignore vendored

@ -5,3 +5,11 @@ d3.js
d3.min.js
components
build
.idea/.name
.idea/c3.iml
.idea/encodings.xml
.idea/misc.xml
.idea/modules.xml
.idea/scopes/scope_settings.xml
.idea/vcs.xml
.idea/workspace.xml

812
c3.js

File diff suppressed because it is too large Load Diff

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

6755
htdocs/js/c3.js

File diff suppressed because it is too large Load Diff

6
htdocs/js/c3.min.js vendored

File diff suppressed because one or more lines are too long

272
htdocs/samples/api_legend.html

@ -1,136 +1,144 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="/css/c3.css">
</head>
<body>
<div id="chart"></div>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="/js/c3.js"></script>
<script>
var columns = [];
for (var i = 0; i < 5; i++ ) {
columns[i] = ['datahogehogeohgeohoge' + i, 10 * i, 20 * i, 30 * i];
<head>
<link rel="stylesheet" type="text/css" href="../css/c3.css">
</head>
<body>
<div id="chart"></div>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="../js/c3.js"></script>
<script>
var columns = [];
for (var i = 0; i < 5; i++ ) {
columns[i] = ['datahogehogeohgeohoge' + i, 10 * i, 20 * i, 30 * i];
}
var chart = c3.generate({
data: {
columns: columns,
},
axis: {
x: {
type: 'category'
}
var chart = c3.generate({
data: {
columns: columns,
},
axis: {
x: {
type: 'category'
}
}
});
setTimeout(function () {
chart.legend.hide();
}, 1000);
setTimeout(function () {
chart = c3.generate({
data: {
columns: columns,
},
axis: {
x: {
type: 'category'
}
});
setTimeout(function () {
chart.legend.hide();
}, 1000);
setTimeout(function () {
chart = c3.generate({
data: {
columns: columns,
},
axis: {
x: {
type: 'category'
}
},
legend: {
position: 'right'
}
});
}, 2000);
setTimeout(function () {
chart.legend.hide();
}, 3000);
setTimeout(function () {
chart = c3.generate({
data: {
columns: columns,
},
axis: {
rotated: true
}
});
}, 4000);
setTimeout(function () {
chart.legend.hide();
}, 5000);
setTimeout(function () {
chart = c3.generate({
data: {
columns: columns,
},
legend: {
position: 'right'
},
axis: {
rotated: true
}
});
}, 6000);
setTimeout(function () {
chart.legend.hide();
}, 7000);
setTimeout(function () {
chart = c3.generate({
data: {
columns: columns,
},
legend: {
show: false
}
});
}, 8000);
setTimeout(function () {
chart.legend.show();
}, 9000);
setTimeout(function () {
chart = c3.generate({
data: {
columns: columns,
},
legend: {
show: false
},
axis: {
rotated: true
}
});
}, 10000);
setTimeout(function () {
chart.legend.show();
}, 11000);
setTimeout(function () {
chart = c3.generate({
data: {
columns: columns,
},
legend: {
position: 'right',
show: false
}
});
}, 12000);
setTimeout(function () {
chart.legend.show();
}, 13000);
</script>
</body>
},
legend: {
position: 'right'
}
});
}, 2000);
setTimeout(function () {
chart.legend.hide();
}, 3000);
setTimeout(function () {
chart = c3.generate({
data: {
columns: columns,
},
axis: {
rotated: true
}
});
}, 4000);
setTimeout(function () {
chart.legend.hide();
}, 5000);
setTimeout(function () {
chart = c3.generate({
data: {
columns: columns,
},
legend: {
position: 'right'
},
axis: {
rotated: true
}
});
}, 6000);
setTimeout(function () {
chart.legend.hide();
}, 7000);
setTimeout(function () {
chart = c3.generate({
data: {
columns: columns,
},
legend: {
show: false
}
});
}, 8000);
setTimeout(function () {
chart.legend.show();
}, 9000);
setTimeout(function () {
chart = c3.generate({
data: {
columns: columns,
},
legend: {
show: false
},
axis: {
rotated: true
}
});
}, 10000);
setTimeout(function () {
chart.legend.show();
}, 11000);
setTimeout(function () {
chart = c3.generate({
data: {
columns: columns,
},
legend: {
position: 'right',
show: false
}
});
}, 12000);
setTimeout(function () {
chart.legend.show();
}, 13000);
setTimeout(function () {
chart.legend.position('bottom');
}, 14000);
setTimeout(function () {
chart.legend.position('right');
}, 15000);
</script>
</body>
</html>

6
src/api.legend.js

@ -9,3 +9,9 @@ c3_chart_fn.legend.hide = function (targetIds) {
$$.hideLegend($$.mapToTargetIds(targetIds));
$$.updateAndRedraw({withLegend: true});
};
c3_chart_fn.legend.position = function (position) {
var $$ = this.internal;
$$.config.legend_position = position;
$$.isLegendRight = $$.config.legend_position === 'right';
$$.updateAndRedraw({withLegend: true});
};

Loading…
Cancel
Save