diff --git a/examples/lineChart.html b/examples/lineChart.html
index 0b3e992..fce10b9 100644
--- a/examples/lineChart.html
+++ b/examples/lineChart.html
@@ -56,12 +56,17 @@ svg {
var chart;
nv.addGraph(function() {
- chart = nv.models.lineChart();
- chart
- .margin({left: 100, bottom: 100})
- .x(function(d,i) { return i })
- .transitionDuration(300)
- ;
+ chart = nv.models.lineChart()
+ .options({
+ margin: {left: 100, bottom: 100},
+ x: function(d,i) { return i},
+ showXAxis: true,
+ showYAxis: true,
+ transitionDuration: 250
+ })
+ ;
+
+ chart.showXAxis(false);
// chart sub-models (ie. xAxis, yAxis, etc) when accessed directly, return themselves, not the parent chart, so need to chain separately
chart.xAxis
@@ -72,8 +77,6 @@ nv.addGraph(function() {
.axisLabel('Voltage (v)')
.tickFormat(d3.format(',.2f'));
- chart.showXAxis(true);
-
d3.select('#chart1 svg')
.datum(sinAndCos())
.call(chart);
diff --git a/src/models/lineChart.js b/src/models/lineChart.js
index 3cb79c6..9ff5a24 100644
--- a/src/models/lineChart.js
+++ b/src/models/lineChart.js
@@ -348,6 +348,8 @@ nv.models.lineChart = function() {
d3.rebind(chart, lines, 'defined', 'isArea', 'x', 'y', 'size', 'xScale', 'yScale', 'xDomain', 'yDomain', 'xRange', 'yRange'
, 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'useVoronoi','id', 'interpolate');
+ chart.options = nv.utils.optionsFunc.bind(chart);
+
chart.margin = function(_) {
if (!arguments.length) return margin;
margin.top = typeof _.top != 'undefined' ? _.top : margin.top;
diff --git a/src/utils.js b/src/utils.js
index 165a589..7b99e1d 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -128,3 +128,25 @@ nv.utils.NaNtoZero = function(n) {
return n;
};
+
+/*
+Snippet of code you can insert into each nv.models.* to give you the ability to
+do things like:
+chart.options({
+ showXAxis: true,
+ tooltips: true
+});
+
+To enable in the chart:
+chart.options = nv.utils.optionsFunc.bind(chart);
+*/
+nv.utils.optionsFunc = function(args) {
+ if (args) {
+ d3.map(args).forEach((function(key,value) {
+ if (typeof this[key] === "function") {
+ this[key](value);
+ }
+ }).bind(this));
+ }
+ return this;
+};
\ No newline at end of file