Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an option to set starting point on X axis. #16

Merged
merged 1 commit into from
Nov 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The following properties can be used:
- `style` : _The style of the lines on the graph. Possibilites include
`lines` (default), `points` and `linespoints`_
- `nokey` : _Disables the graph key_
- `x_begin` : _Specifies the starting point along X axis on the graph_

The following example shows these in use:

Expand All @@ -71,7 +72,8 @@ plot({
logscale: true,
xlabel: 'time',
ylabel: 'length of string',
format: 'pdf'
format: 'pdf',
x_begin: 0
});
```

Expand Down
6 changes: 5 additions & 1 deletion plotter.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ function plot(options) {
options.style = 'lines'; /* Default to lines */
}

if (!options.x_begin) {
options.x_begin = 0
}

/* Apply moving averages and maximums */
if (options.moving_avg) {
options.data = apply_moving_filter(options.data, moving_average, options.moving_avg);
Expand Down Expand Up @@ -211,7 +215,7 @@ function plot(options) {
/* Print out the data */
for (i = 0; i < series.length; i += 1) { /* For each series */
for (key in options.data[series[i]]) {
gnuplot.stdin.write(key + ' ' + options.data[series[i]][key] + '\n');
gnuplot.stdin.write(parseInt(options.x_begin) + parseInt(key) + ' ' + options.data[series[i]][key] + '\n');
}
/* Terminate the data */
gnuplot.stdin.write('e\n');
Expand Down