File tree Expand file tree Collapse file tree 4 files changed +27
-34
lines changed
Expand file tree Collapse file tree 4 files changed +27
-34
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ function onSiteDependenciesLoaded() {
66
77 functionPlot ( {
88 target : '#description-sample' ,
9- x : { grid : true } ,
10- y : { domain : [ - 1 , 9 ] , grid : true } ,
9+ y : { domain : [ - 1 , 9 ] } ,
10+ grid : true ,
1111 tip : {
1212 renderer : function ( ) { }
1313 } ,
@@ -119,7 +119,7 @@ function onSiteDependenciesLoaded() {
119119 /**
120120 * ### Grid
121121 *
122- * Set `grid: true` in the axis objects to draw a grid.
122+ * Set `grid: true` in the top level object or the axis objects to draw a grid.
123123 */
124124 functionPlot ( {
125125 target : '#grid' ,
@@ -142,14 +142,9 @@ function onSiteDependenciesLoaded() {
142142 */
143143 functionPlot ( {
144144 target : '#sticky' ,
145- x : {
146- position : 'sticky' ,
147- grid : true
148- } ,
149- y : {
150- position : 'sticky' ,
151- grid : true
152- } ,
145+ x : { position : 'sticky' } ,
146+ y : { position : 'sticky' } ,
147+ grid : true ,
153148 data : [ { fn : 'cos(x)' } ]
154149 } )
155150
@@ -279,13 +274,12 @@ function onSiteDependenciesLoaded() {
279274 target : '#logarithmic' ,
280275 x : {
281276 type : 'log' ,
282- domain : [ 0.01 , 1 ] ,
283- grid : true
277+ domain : [ 0.01 , 1 ]
284278 } ,
285279 y : {
286- domain : [ - 100 , 100 ] ,
287- grid : true
280+ domain : [ - 100 , 100 ]
288281 } ,
282+ grid : true ,
289283 data : [
290284 {
291285 fn : '1/x * cos(1/x)' ,
@@ -950,8 +944,8 @@ function onSiteDependenciesLoaded() {
950944 */
951945 functionPlot ( {
952946 target : '#vector' ,
953- x : { domain : [ - 3 , 8 ] , grid : true } ,
954- y : { grid : true } ,
947+ x : { domain : [ - 3 , 8 ] } ,
948+ grid : true ,
955949 data : [
956950 {
957951 vector : [ 2 , 1 ] ,
Original file line number Diff line number Diff line change 4949 }
5050 ]
5151})</ code > </ pre > </ div > </ div > < div class ="col-md-6 center-block demos "> < span class ="graph " id ="quadratic-with-options "> </ span > </ div > </ div > </ div > </ div > < div class ="example "> < div class ="container "> < div class ="row "> < div class ="col-md-6 "> < div class ="comment "> < h3 > Grid</ h3 >
52- < p > Set < code > grid: true</ code > in the axis objects to draw a grid.</ p > </ div > < div class ="code "> < pre > < code class ="javascript "> functionPlot({
52+ < p > Set < code > grid: true</ code > in the top level object or the axis objects to draw a grid.</ p > </ div > < div class ="code "> < pre > < code class ="javascript "> functionPlot({
5353 target: '#grid',
5454 x: {
5555 label: 'real',
6464< p > Set < code > position: 'sticky'</ code > on an axis to keep it centered
6565in the screen and constrained to the viewport on pan and zoom.</ p > </ div > < div class ="code "> < pre > < code class ="javascript "> functionPlot({
6666 target: '#sticky',
67- x: {
68- position: 'sticky',
69- grid: true
70- },
71- y: {
72- position: 'sticky',
73- grid: true
74- },
67+ x: { position: 'sticky' },
68+ y: { position: 'sticky' },
69+ grid: true,
7570 data: [{ fn: 'cos(x)' }]
7671})</ code > </ pre > </ div > </ div > < div class ="col-md-6 center-block demos "> < span class ="graph " id ="sticky "> </ span > </ div > </ div > </ div > </ div > < div class ="example "> < div class ="container "> < div class ="row "> < div class ="col-md-6 "> < div class ="comment "> < h3 > Domain</ h3 >
7772< p > The domains of both axes can be changed with the following configurations:</ p >
167162 target: '#logarithmic',
168163 x: {
169164 type: 'log',
170- domain: [0.01, 1],
171- grid: true
165+ domain: [0.01, 1]
172166 },
173167 y: {
174- domain: [-100, 100],
175- grid: true
168+ domain: [-100, 100]
176169 },
170+ grid: true,
177171 data: [
178172 {
179173 fn: '1/x * cos(1/x)',
673667< li > < code > graphType: 'polyline'</ code > to render a nice segment from < code > offset</ code > to < code > offset + vector</ code > </ li >
674668</ ul > </ div > < div class ="code "> < pre > < code class ="javascript "> functionPlot({
675669 target: '#vector',
676- x: { domain: [-3, 8], grid: true },
677- y: { grid: true } ,
670+ x: { domain: [-3, 8] },
671+ grid: true,
678672 data: [
679673 {
680674 vector: [2, 1],
Original file line number Diff line number Diff line change @@ -286,11 +286,11 @@ export class Chart extends EventEmitter.EventEmitter {
286286 if ( ! this . meta . xAxis ) {
287287 this . meta . xAxis = d3AxisBottom ( this . meta . xScale )
288288 }
289- this . meta . xAxis . tickSize ( this . options . x . grid ? - this . meta . height : 0 ) . tickFormat ( formatter )
289+ this . meta . xAxis . tickSize ( this . options . grid || this . options . x . grid ? - this . meta . height : 0 ) . tickFormat ( formatter )
290290 if ( ! this . meta . yAxis ) {
291291 this . meta . yAxis = d3AxisLeft ( this . meta . yScale )
292292 }
293- this . meta . yAxis . tickSize ( this . options . y . grid ? - this . meta . width : 0 ) . tickFormat ( formatter )
293+ this . meta . yAxis . tickSize ( this . options . grid || this . options . y . grid ? - this . meta . width : 0 ) . tickFormat ( formatter )
294294
295295 this . line = d3Line ( )
296296 . x ( function ( d ) {
Original file line number Diff line number Diff line change @@ -414,6 +414,11 @@ export interface FunctionPlotOptions {
414414 */
415415 disableZoom ?: boolean
416416
417+ /**
418+ * True to display a grid.
419+ */
420+ grid ?: boolean
421+
417422 /**
418423 * The functions to plot
419424 */
You can’t perform that action at this time.
0 commit comments