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() {
6
6
7
7
functionPlot ( {
8
8
target : '#description-sample' ,
9
- x : { grid : true } ,
10
- y : { domain : [ - 1 , 9 ] , grid : true } ,
9
+ y : { domain : [ - 1 , 9 ] } ,
10
+ grid : true ,
11
11
tip : {
12
12
renderer : function ( ) { }
13
13
} ,
@@ -119,7 +119,7 @@ function onSiteDependenciesLoaded() {
119
119
/**
120
120
* ### Grid
121
121
*
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.
123
123
*/
124
124
functionPlot ( {
125
125
target : '#grid' ,
@@ -142,14 +142,9 @@ function onSiteDependenciesLoaded() {
142
142
*/
143
143
functionPlot ( {
144
144
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 ,
153
148
data : [ { fn : 'cos(x)' } ]
154
149
} )
155
150
@@ -279,13 +274,12 @@ function onSiteDependenciesLoaded() {
279
274
target : '#logarithmic' ,
280
275
x : {
281
276
type : 'log' ,
282
- domain : [ 0.01 , 1 ] ,
283
- grid : true
277
+ domain : [ 0.01 , 1 ]
284
278
} ,
285
279
y : {
286
- domain : [ - 100 , 100 ] ,
287
- grid : true
280
+ domain : [ - 100 , 100 ]
288
281
} ,
282
+ grid : true ,
289
283
data : [
290
284
{
291
285
fn : '1/x * cos(1/x)' ,
@@ -950,8 +944,8 @@ function onSiteDependenciesLoaded() {
950
944
*/
951
945
functionPlot ( {
952
946
target : '#vector' ,
953
- x : { domain : [ - 3 , 8 ] , grid : true } ,
954
- y : { grid : true } ,
947
+ x : { domain : [ - 3 , 8 ] } ,
948
+ grid : true ,
955
949
data : [
956
950
{
957
951
vector : [ 2 , 1 ] ,
Original file line number Diff line number Diff line change 49
49
}
50
50
]
51
51
})</ 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({
53
53
target: '#grid',
54
54
x: {
55
55
label: 'real',
64
64
< p > Set < code > position: 'sticky'</ code > on an axis to keep it centered
65
65
in the screen and constrained to the viewport on pan and zoom.</ p > </ div > < div class ="code "> < pre > < code class ="javascript "> functionPlot({
66
66
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,
75
70
data: [{ fn: 'cos(x)' }]
76
71
})</ 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 >
77
72
< p > The domains of both axes can be changed with the following configurations:</ p >
167
162
target: '#logarithmic',
168
163
x: {
169
164
type: 'log',
170
- domain: [0.01, 1],
171
- grid: true
165
+ domain: [0.01, 1]
172
166
},
173
167
y: {
174
- domain: [-100, 100],
175
- grid: true
168
+ domain: [-100, 100]
176
169
},
170
+ grid: true,
177
171
data: [
178
172
{
179
173
fn: '1/x * cos(1/x)',
673
667
< li > < code > graphType: 'polyline'</ code > to render a nice segment from < code > offset</ code > to < code > offset + vector</ code > </ li >
674
668
</ ul > </ div > < div class ="code "> < pre > < code class ="javascript "> functionPlot({
675
669
target: '#vector',
676
- x: { domain: [-3, 8], grid: true },
677
- y: { grid: true } ,
670
+ x: { domain: [-3, 8] },
671
+ grid: true,
678
672
data: [
679
673
{
680
674
vector: [2, 1],
Original file line number Diff line number Diff line change @@ -286,11 +286,11 @@ export class Chart extends EventEmitter.EventEmitter {
286
286
if ( ! this . meta . xAxis ) {
287
287
this . meta . xAxis = d3AxisBottom ( this . meta . xScale )
288
288
}
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 )
290
290
if ( ! this . meta . yAxis ) {
291
291
this . meta . yAxis = d3AxisLeft ( this . meta . yScale )
292
292
}
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 )
294
294
295
295
this . line = d3Line ( )
296
296
. x ( function ( d ) {
Original file line number Diff line number Diff line change @@ -414,6 +414,11 @@ export interface FunctionPlotOptions {
414
414
*/
415
415
disableZoom ?: boolean
416
416
417
+ /**
418
+ * True to display a grid.
419
+ */
420
+ grid ?: boolean
421
+
417
422
/**
418
423
* The functions to plot
419
424
*/
You can’t perform that action at this time.
0 commit comments