Skip to content

Commit f2dc132

Browse files
authored
Merge pull request #16 from kibotrel/master
Added an option to set starting point on X axis.
2 parents 06460f3 + ef797e2 commit f2dc132

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ The following properties can be used:
5959
- `style` : _The style of the lines on the graph. Possibilites include
6060
`lines` (default), `points` and `linespoints`_
6161
- `nokey` : _Disables the graph key_
62+
- `x_begin` : _Specifies the starting point along X axis on the graph_
6263

6364
The following example shows these in use:
6465

@@ -71,7 +72,8 @@ plot({
7172
logscale: true,
7273
xlabel: 'time',
7374
ylabel: 'length of string',
74-
format: 'pdf'
75+
format: 'pdf',
76+
x_begin: 0
7577
});
7678
```
7779

plotter.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ function plot(options) {
160160
options.style = 'lines'; /* Default to lines */
161161
}
162162

163+
if (!options.x_begin) {
164+
options.x_begin = 0
165+
}
166+
163167
/* Apply moving averages and maximums */
164168
if (options.moving_avg) {
165169
options.data = apply_moving_filter(options.data, moving_average, options.moving_avg);
@@ -211,7 +215,7 @@ function plot(options) {
211215
/* Print out the data */
212216
for (i = 0; i < series.length; i += 1) { /* For each series */
213217
for (key in options.data[series[i]]) {
214-
gnuplot.stdin.write(key + ' ' + options.data[series[i]][key] + '\n');
218+
gnuplot.stdin.write(parseInt(options.x_begin) + parseInt(key) + ' ' + options.data[series[i]][key] + '\n');
215219
}
216220
/* Terminate the data */
217221
gnuplot.stdin.write('e\n');

0 commit comments

Comments
 (0)