Browse Source

Can now change legend position

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

8
.gitignore vendored

@ -5,3 +5,11 @@ d3.js
d3.min.js d3.min.js
components components
build 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

6
c3.js

@ -6394,6 +6394,12 @@
$$.hideLegend($$.mapToTargetIds(targetIds)); $$.hideLegend($$.mapToTargetIds(targetIds));
$$.updateAndRedraw({withLegend: true}); $$.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});
};
c3_chart_fn.resize = function (size) { c3_chart_fn.resize = function (size) {
var $$ = this.internal, config = $$.config; var $$ = this.internal, config = $$.config;

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

12
htdocs/samples/api_legend.html

@ -1,12 +1,12 @@
<html> <html>
<head> <head>
<link rel="stylesheet" type="text/css" href="/css/c3.css"> <link rel="stylesheet" type="text/css" href="../css/c3.css">
</head> </head>
<body> <body>
<div id="chart"></div> <div id="chart"></div>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="/js/c3.js"></script> <script src="../js/c3.js"></script>
<script> <script>
var columns = []; var columns = [];
@ -131,6 +131,14 @@
chart.legend.show(); chart.legend.show();
}, 13000); }, 13000);
setTimeout(function () {
chart.legend.position('bottom');
}, 14000);
setTimeout(function () {
chart.legend.position('right');
}, 15000);
</script> </script>
</body> </body>
</html> </html>

6
src/api.legend.js

@ -9,3 +9,9 @@ c3_chart_fn.legend.hide = function (targetIds) {
$$.hideLegend($$.mapToTargetIds(targetIds)); $$.hideLegend($$.mapToTargetIds(targetIds));
$$.updateAndRedraw({withLegend: true}); $$.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