diff --git a/src/chart.ts b/src/chart.ts index e07a5b3..9464621 100644 --- a/src/chart.ts +++ b/src/chart.ts @@ -513,7 +513,7 @@ export class Chart extends EventEmitter.EventEmitter { .enter() .append('path') .attr('class', 'y origin') - .attr('stroke', 'black') + .attr('stroke', 'currentColor') .attr('opacity', 0.2) yOrigin.merge(yOriginEnter).attr('d', this.line) } @@ -533,7 +533,7 @@ export class Chart extends EventEmitter.EventEmitter { .enter() .append('path') .attr('class', 'x origin') - .attr('stroke', 'black') + .attr('stroke', 'currentColor') .attr('opacity', 0.2) xOrigin.merge(xOriginEnter).attr('d', this.line) } @@ -674,12 +674,7 @@ export class Chart extends EventEmitter.EventEmitter { canvas.selectAll('.y.axis path, .y.axis line').attr('transform', 'translate(' + -xTranslation + ',0)') } - canvas - .selectAll('.axis path, .axis line') - .attr('fill', 'none') - .attr('stroke', 'black') - .attr('shape-rendering', 'crispedges') - .attr('opacity', 0.1) + canvas.selectAll('.axis path, .axis line').attr('stroke', 'currentColor').attr('opacity', 0.2) } private syncOptions() { diff --git a/src/datum-defaults.test.ts b/src/datum-defaults.test.ts new file mode 100644 index 0000000..db049c6 --- /dev/null +++ b/src/datum-defaults.test.ts @@ -0,0 +1,54 @@ +import { describe, expect, it } from '@jest/globals' +import { FunctionPlotDatum } from './types.js' +import datumDefaults from '../src/datum-defaults.js' + +describe('datumDefaults', () => { + it('should assign a random ID if one is not provided', () => { + const datum: FunctionPlotDatum = {} + const result = datumDefaults(datum) + expect(result.id).toBeDefined() + }) + + it('should default graphType to "interval" if not provided', () => { + const datum: FunctionPlotDatum = {} + const result = datumDefaults(datum) + expect(result.graphType).toBe('interval') + }) + + it('should default sampler to "builtIn" if graphType is not "interval"', () => { + const datum: FunctionPlotDatum = { graphType: 'polyline' } + const result = datumDefaults(datum) + expect(result.sampler).toBe('builtIn') + }) + + it('should default sampler to "interval" if graphType is "interval"', () => { + const datum: FunctionPlotDatum = { graphType: 'interval' } + const result = datumDefaults(datum) + expect(result.sampler).toBe('interval') + }) + + it('should default fnType to "linear" if graphType is "polyline", "interval", or "scatter"', () => { + let datum: FunctionPlotDatum = { graphType: 'polyline' } + let result = datumDefaults(datum) + expect(result.fnType).toBe('linear') + + datum = { graphType: 'interval' } + result = datumDefaults(datum) + expect(result.fnType).toBe('linear') + + datum = { graphType: 'scatter' } + result = datumDefaults(datum) + expect(result.fnType).toBe('linear') + }) + + it('should not modify the datum if all defaults are already set', () => { + const datum: FunctionPlotDatum = { + id: 'test', + graphType: 'polyline', + sampler: 'builtIn', + fnType: 'linear' + } + const result = datumDefaults(datum) + expect(result).toEqual(datum) + }) +}) diff --git a/src/samplers/interval.ts b/src/samplers/interval.ts index 38dc012..a8bfc6c 100644 --- a/src/samplers/interval.ts +++ b/src/samplers/interval.ts @@ -12,7 +12,6 @@ import { SamplerParams, IntervalSamplerResult, IntervalSamplerResultGroup, Sampl async function asyncInterval1d({ d, - xAxis, range, nSamples, nGroups, diff --git a/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-a-grid-1-snap.png b/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-a-grid-1-snap.png index 73b3388..f8feb9f 100644 Binary files a/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-a-grid-1-snap.png and b/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-a-grid-1-snap.png differ diff --git a/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-an-x-2-graph-1-snap.png b/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-an-x-2-graph-1-snap.png index d4bc23f..e699658 100644 Binary files a/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-an-x-2-graph-1-snap.png and b/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-an-x-2-graph-1-snap.png differ diff --git a/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-logarithmic-scales-1-snap.png b/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-logarithmic-scales-1-snap.png index 06829b9..c3d1641 100644 Binary files a/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-logarithmic-scales-1-snap.png and b/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-logarithmic-scales-1-snap.png differ diff --git a/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-with-additional-options-1-snap.png b/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-with-additional-options-1-snap.png index 02508cc..18c8b54 100644 Binary files a/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-with-additional-options-1-snap.png and b/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-with-additional-options-1-snap.png differ diff --git a/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-with-sticky-axes-1-snap.png b/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-with-sticky-axes-1-snap.png index c379d61..be46563 100644 Binary files a/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-with-sticky-axes-1-snap.png and b/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-with-sticky-axes-1-snap.png differ diff --git a/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-x-2-async-1-snap.png b/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-x-2-async-1-snap.png index be5a78e..a0dd2ef 100644 Binary files a/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-x-2-async-1-snap.png and b/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-should-render-x-2-async-1-snap.png differ diff --git a/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-update-the-graph-using-multiple-renders-1-snap.png b/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-update-the-graph-using-multiple-renders-1-snap.png index d4bc23f..e699658 100644 Binary files a/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-update-the-graph-using-multiple-renders-1-snap.png and b/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-update-the-graph-using-multiple-renders-1-snap.png differ diff --git a/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-update-the-graph-using-multiple-renders-2-snap.png b/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-update-the-graph-using-multiple-renders-2-snap.png index 8c2bd04..807ea9d 100644 Binary files a/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-update-the-graph-using-multiple-renders-2-snap.png and b/test/e2e/__image_snapshots__/graphs-test-ts-function-plot-update-the-graph-using-multiple-renders-2-snap.png differ