Skip to content

Commit

Permalink
update line width (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
lincent authored Aug 23, 2024
1 parent fe234cd commit ce72c1b
Showing 3 changed files with 45 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -223,13 +223,12 @@ describe('AverageComparisonChart', () => {
testForecastData,
testMeasurementData,
)
expect(
(
result.series.find(
(x) => x.name === 'Measurement',
) as LineSeriesOption
).lineStyle?.width,
).toBe(5)
const lineOptions = result.series.find(
(x) => x.name === 'Measurement',
) as LineSeriesOption

expect(lineOptions.lineStyle?.width).toBe(5)
expect(lineOptions.symbolSize).toBe(5)
})

it('has the correct number of datapoints', async () => {
Original file line number Diff line number Diff line change
@@ -16,14 +16,15 @@ export const forecastLine = (): LineSeriesOption => {
}

export const measurementLine = (
width: number | undefined = 1,
width: number | undefined = 2,
): LineSeriesOption => {
return {
lineStyle: {
width,
type: 'solid',
opacity: 0.5,
},
symbolSize: width,
z: 1,
symbol: 'roundRect',
}
Original file line number Diff line number Diff line change
@@ -352,10 +352,10 @@ describe('Site Measurement Chart', () => {
'the city name',
seriesColorsBySite,
)
expect(
(result.series.find((x) => x.name === 'Forecast') as LineSeriesOption)
.lineStyle?.type,
).toBe('dashed')
const lineOptions = result.series.find(
(x) => x.name === 'Forecast',
) as LineSeriesOption
expect(lineOptions.lineStyle?.type).toBe('dashed')
})

it('to map measurement data correctly', async () => {
@@ -368,9 +368,10 @@ describe('Site Measurement Chart', () => {
'the city name',
seriesColorsBySite,
)
const data = (
result.series.find((x) => x.name === 'Forecast') as LineSeriesOption
).data
const lineOptions = result.series.find(
(x) => x.name === 'Forecast',
) as LineSeriesOption
const data = lineOptions.data
expect(data).toHaveLength(2)
expect(data).toEqual([
['2024-01-01T00:00:00.000Z', '2.0'],
@@ -405,13 +406,26 @@ describe('Site Measurement Chart', () => {
'the city name',
seriesColorsBySite,
)
expect(
(
result.series.find(
(x) => x.name === 'locationA',
) as LineSeriesOption
).lineStyle?.width,
).toBe(1)
const lineOptions = result.series.find(
(x) => x.name === 'locationA',
) as LineSeriesOption
expect(lineOptions.lineStyle?.width).toBe(2)
})

it('symbol size should be correct', async () => {
const result = generateMeasurementChart(
pollutantType,
zoomPercent,
measurementsBySite,
forecastData,
'this is the date',
'the city name',
seriesColorsBySite,
)
const lineOptions = result.series.find(
(x) => x.name === 'locationA',
) as LineSeriesOption
expect(lineOptions.symbolSize).toBe(2)
})

it('line should be blue', async () => {
@@ -439,13 +453,11 @@ describe('Site Measurement Chart', () => {
'the city name',
seriesColorsBySite,
)
expect(
(
result.series.find(
(x) => x.name === 'locationA',
) as LineSeriesOption
).lineStyle?.type,
).toBe('solid')
const lineOptions = result.series.find(
(x) => x.name === 'locationA',
) as LineSeriesOption

expect(lineOptions.lineStyle?.type).toBe('solid')
})

it('to map measurement data correctly', async () => {
@@ -458,9 +470,10 @@ describe('Site Measurement Chart', () => {
'the city name',
seriesColorsBySite,
)
const data = (
result.series.find((x) => x.name === 'locationA') as LineSeriesOption
).data
const lineOptions = result.series.find(
(x) => x.name === 'locationA',
) as LineSeriesOption
const data = lineOptions.data
expect(data).toHaveLength(2)
expect(data).toEqual([
['2024-01-01T01:00:00.000Z', '12.0'],

0 comments on commit ce72c1b

Please sign in to comment.