Skip to content

Commit 0f718ac

Browse files
committed
Update box and whiskers in JS SDK
1 parent 6a8b9ae commit 0f718ac

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

js/src/charts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export type BoxAndWhiskerData = {
9595
median: number
9696
third_quartile: number
9797
max: number
98+
outliers: number[]
9899
}
99100

100101
export type BoxAndWhiskerChart = Chart2D & {

js/tests/charts/boxAndWhisker.test.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ data = {
1717
# Create figure and axis
1818
fig, ax = plt.subplots(figsize=(10, 6))
1919
20-
# Plot box plot
21-
ax.boxplot(data.values(), labels=data.keys())
22-
2320
# Customize plot
2421
ax.set_title('Exam Scores Distribution')
2522
ax.set_xlabel('Class')
@@ -52,12 +49,11 @@ plt.show()
5249
const bars = chart.elements
5350
expect(bars.length).toBe(3)
5451

55-
bars.forEach((bar: any) => {
56-
expect(typeof bar.min).toBe('number')
57-
expect(typeof bar.first_quartile).toBe('number')
58-
expect(typeof bar.median).toBe('number')
59-
expect(typeof bar.third_quartile).toBe('number')
60-
expect(typeof bar.max).toBe('number')
61-
expect(typeof bar.label).toBe('string')
62-
})
52+
expect(bars.map((bar) => bar.label)).toEqual(['Class A', 'Class B', 'Class C'])
53+
expect(bars.map((bar) => bar.outliers)).toEqual([[], [76], []])
54+
expect(bars.map((bar) => bar.min)).toEqual([78, 84, 75])
55+
expect(bars.map((bar) => bar.first_quartile)).toEqual([85, 84.75, 79])
56+
expect(bars.map((bar) => bar.median)).toEqual([88, 88, 82])
57+
expect(bars.map((bar) => bar.third_quartile)).toEqual([90, 90.5, 86])
58+
expect(bars.map((bar) => bar.max)).toEqual([92, 95, 88])
6359
})

0 commit comments

Comments
 (0)