Skip to content

Commit 9d68f92

Browse files
Merge pull request #147 from ignoreintuition/issue-135-gridlines
added grid lines
2 parents f39aae5 + fadc176 commit 9d68f92

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/components/chartExample.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ export default {
8989
enabled: true,
9090
height: 25,
9191
width: 50
92+
},
93+
grid: {
94+
enabled: true,
95+
gridTicks: 25
9296
}
9397
},
9498
lineGraphData: {

src/v-chart-plugin.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ const Chart = {
5555
* @memberOf Chart
5656
*/
5757
drawGrid(cs) {
58+
if (this.chartData.grid && this.chartData.grid.enabled === true) {
5859
const grid = {
5960
x: [],
6061
y: []
6162
}
62-
for (let i = this.header; i < (this.height - this.header) * .80; i += 100) {
63+
for (let i = this.header; i < (this.height - this.header) * .80; i += this.gridTicks) {
6364
grid.y.push(i);
6465
}
6566
d3.select(`#${this.chartData.selector}`)
@@ -73,6 +74,7 @@ const Chart = {
7374
.attr('y2', d => d)
7475
.style('stroke', '#D3D3D3')
7576
.style('stroke-width', 1)
77+
}
7678
},
7779
/**
7880
* Remove x and y axes
@@ -273,6 +275,17 @@ const Chart = {
273275
width() {
274276
return this.chartData.width || 200;
275277
},
278+
/**
279+
* Grid Tick getter function
280+
* @memberOf Chart
281+
* @returns {number} gridTicks
282+
*/
283+
gridTicks() {
284+
if (this.chartData.grid && this.chartData.grid.gridTicks != null) {
285+
return this.chartData.grid.gridTicks;
286+
}
287+
return 100;
288+
},
276289
/**
277290
* Get the maxium value for metric
278291
* @memberOf Chart

0 commit comments

Comments
 (0)