Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
bf29cbb
Test react
Jan 21, 2023
9daf8d1
Add react dom
Jan 21, 2023
e0624a2
Forgot to build
Jan 21, 2023
8814d8c
Pass target via param
Jan 21, 2023
7ee6961
Cleanup
Jan 21, 2023
ab85966
Cleanup
Jan 21, 2023
1823a7e
Minifi
Jan 21, 2023
117e846
Test svg
Jan 21, 2023
a9c6459
Add visx basic chart example
Jan 21, 2023
29d2aac
Use createRoot from react dom
Jan 21, 2023
0f6e6a1
Debugging
Jan 21, 2023
d79f421
Debugging
Jan 21, 2023
3e1da2f
Debugging
Jan 21, 2023
5306c8a
Debugging
Jan 21, 2023
3cef120
Debugging
Jan 21, 2023
ef66ea3
Debugging
Jan 21, 2023
a427b2e
Debugging
Jan 21, 2023
6a945a3
Debugging
Jan 21, 2023
2135e12
Debugging
Jan 21, 2023
cb1e64b
Debugging
Jan 21, 2023
76f7903
Debugging
Jan 21, 2023
7686742
Debugging
Jan 21, 2023
41498e8
Attempt to add axis
Jan 21, 2023
7470c7f
Attempt to add axis
Jan 21, 2023
d3f6db9
Add vite local testing server
Jan 21, 2023
3f3f1b5
Build
Jan 21, 2023
2056cdb
Move index to top level
Jan 21, 2023
2954df3
Fix path
Jan 21, 2023
64557fc
Fix serve command
Jan 21, 2023
28416b4
Rename line chart to d3 line chart
Jan 21, 2023
b09c3a7
Move render function to component
Jan 21, 2023
0799bec
Abstractions
Jan 21, 2023
2e29e81
Cleanup
Jan 21, 2023
887eaff
Move index to root
Jan 21, 2023
f2baa24
Move charts to library
Jan 21, 2023
453754f
Change build command to build lib
Jan 21, 2023
3000d67
Build lib
Jan 21, 2023
7cc4389
Simplify rendering
Jan 21, 2023
10fb190
Add tailwind
Jan 21, 2023
21bbf48
Detect width with react-use
Jan 21, 2023
1511edd
Add curve lib
Jan 21, 2023
b9a9a05
Render line chart
Jan 21, 2023
a8d4776
Work on axis tick spacing
Jan 21, 2023
f352488
Fix bug
Jan 21, 2023
ee191a6
Don't need margins - parent can set
Jan 21, 2023
937641c
Parameterized props
Jan 21, 2023
b3969bc
Build
Jan 21, 2023
bc86ed1
Two different rendering methods
Jan 21, 2023
d5612b1
Build
Jan 21, 2023
1c67a6b
No minify
Jan 21, 2023
8278db2
Test
Jan 21, 2023
4013850
Test
Jan 21, 2023
258a152
Test
Jan 21, 2023
77216f0
Revert
Jan 21, 2023
fac9a80
Add back render function to test
Jan 21, 2023
09b9e3c
Add separate css file
Jan 21, 2023
bbc16d0
Undo prev; set width via style
Jan 21, 2023
5aa27b6
Back to minify
Jan 21, 2023
b508ba2
Build
Jan 21, 2023
8fb818f
Cleanup
Jan 21, 2023
694dd2c
Cleanup
Jan 21, 2023
090c254
Use visx deps for visx graph, not d3
Jan 21, 2023
0580733
Get rid of manual tick spacing algo, use default
Jan 21, 2023
a4fd5d7
Group data
Jan 22, 2023
f217a86
Group data by z
Jan 22, 2023
42dd1d2
Test vite build
Jan 22, 2023
02de2fb
Test vite build
Jan 22, 2023
b85dc74
Not gonna use vite build right now
Jan 22, 2023
5017ceb
Get rid of react-use, and add method to get local mouse x y relative …
Jan 22, 2023
286ef9b
Get closest DP
Jan 22, 2023
9492975
Render closest DP
Jan 22, 2023
058e3e0
Line and point effects on hover
Jan 22, 2023
9f099a9
Render tooltip
Jan 23, 2023
ca58c00
Render data with tooltip
Jan 23, 2023
1eb67fc
Adjustments
Jan 23, 2023
3120432
Sans serif tooltip
Jan 23, 2023
2d6f04a
Missed title
Jan 23, 2023
6859a0a
Log scale
Jan 23, 2023
b2c643f
Build
Jan 23, 2023
64f7084
Adjust point sizes
Jan 23, 2023
9fc31af
Opacity of bg lines
Jan 23, 2023
b97e936
Opacity of bg lines
Jan 23, 2023
52bacf4
Add back margins
Jan 23, 2023
0967d4c
Endpoint labels
Jan 23, 2023
10b8685
Tweaks
Jan 23, 2023
d0c4038
Build
Jan 23, 2023
3607956
Tweaks
Jan 23, 2023
a6af9c3
Optional getZ
Jan 23, 2023
a8efd56
Hacky tooltip adjustment
Jan 23, 2023
1c87f3d
Hacky tooltip adjustment
Jan 23, 2023
50db3e9
Hacky tooltip adjustment
Jan 23, 2023
d24bde4
Hacky tooltip adjustment
Jan 23, 2023
6c0332e
Hacky tooltip adjustment
Jan 23, 2023
3039104
Resize chart when window size changes
Jan 23, 2023
5de7299
Add a key
Jan 23, 2023
01ab901
Add ability to turn off points or lines
Jan 23, 2023
32ca0bd
y scale type
Jan 23, 2023
e5f3d84
Index code
Jan 23, 2023
a6fa12d
chart domains
Jan 23, 2023
909452e
show endpoint labels flag
Jan 23, 2023
5c8f1a1
show endpoint labels default to false
Jan 23, 2023
045b5bb
show points when no closest group
Jan 23, 2023
100c323
show points false by default
Jan 23, 2023
da4153f
point opacity param
Jan 23, 2023
c7f7255
y domain param
Jan 23, 2023
9628ad8
x-axis location param
Jan 23, 2023
2dcd077
debugging
Jan 23, 2023
ca78199
debugging
Jan 23, 2023
57f0a94
Fix
Jan 23, 2023
c6fca81
Width parameter
Jan 23, 2023
b24200e
Refactors and add color utils
Jan 23, 2023
ddcdce0
Assign evenly spaced colors to lines
Jan 23, 2023
66bfddd
Color points
Jan 23, 2023
eba2f61
Add edge vs amount won chart to index
Jan 23, 2023
069f99d
Fix coloring points
Jan 23, 2023
e84591f
Fixed x and y in tooltip
Jan 23, 2023
3f33ef2
Format numbers in tooltip
Jan 23, 2023
7a1ccc0
Prepare legend code
Jan 23, 2023
2ec1a2b
Wrap chart in div
Jan 23, 2023
21da04a
Include legend in wrapper div
Jan 23, 2023
c8cd211
Add legend
Jan 23, 2023
f1fd2d0
Better typings for margins
Jan 23, 2023
9d9cf70
Default font styles for div wrapper
Jan 23, 2023
f5810f8
Cleaned legend positioning and styling
Jan 23, 2023
45d26db
Sorted legend by final values
Jan 23, 2023
fa44d98
Build
Jan 23, 2023
d23eb83
Add eslint
Jan 24, 2023
b045fa5
refactor package.json
Jan 24, 2023
7070351
Export to package.json
Jan 24, 2023
36da1b8
Add tsc build script; rename existing to build:esbuild
Jan 24, 2023
080fbd3
Bump npm version
Jan 24, 2023
9702fc2
Bump npm and rebuild with some small changes
Jan 24, 2023
f172c07
improvements to build
Mar 29, 2023
2800025
fix the typecheck, and use nodenext resolution
Mar 29, 2023
2cd2036
bump npm version and publish
Mar 29, 2023
4283ff8
commit build
Mar 29, 2023
d4aaf0c
downgrade @visx/scale because version 3 uses a require, breaking this…
Mar 29, 2023
f21047f
downgrade all visx packages to 2.18
Mar 29, 2023
223ecf1
oops some are only 2.17
Mar 29, 2023
c8480f6
yarn lock
Mar 29, 2023
10ee710
bump version
Mar 29, 2023
9e889d9
we include react in ReactLineChart.tsx because lib consumers think it…
Mar 29, 2023
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tsconfig.tsbuildinfo
yarn-error.log
node_modules

.DS_Store
73 changes: 73 additions & 0 deletions build/lib/D3LineChart.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import * as d3 from "d3";
export declare const make: <T>(data: T[], { x, y, z, marginTop, marginRight, marginBottom, marginLeft, width, height, xType, xDomain, xRange, yType, yDomain, yRange, lineColor, strokeLinecap, strokeLinejoin, strokeWidth, strokeOpacity, xFormat, yFormat, xLabel, yLabel, xAxisOffset, drawLine, drawPoints, pointRadius, pointFillColor, pointFillOpacity, pointStrokeColor, pointStrokeOpacity, color, mixBlendMode, }: {
/** given datapoint, returns the (temporal) x-value */
readonly x: (p: T) => number;
/** given datapoint, returns the (quantitative) y-value */
readonly y: (p: T) => number;
/** given datapoint, returns the (categorical) z-value */
readonly z: (p: T) => number | string;
/** top margin (px) */
readonly marginTop: number;
/** right margin (px) */
readonly marginRight: number;
/** bottom margin (px) */
readonly marginBottom: number;
/** left margin (px) */
readonly marginLeft: number;
/** outer width of chart (px) */
readonly width: number;
/** outer height of chart (px) */
readonly height: number;
/**
* Function to return the x-scale type. Valid scales
* are ones with the `tickFormat` property.
*/
readonly xType: (domain: Iterable<d3.NumberValue>, range: Iterable<number>) => d3.AxisScale<Date | d3.NumberValue>;
/** x domain min and max */
readonly xDomain?: readonly [number, number];
/** x range min and max */
readonly xRange: readonly [number, number];
/**
* Function to return the y-scale type. Valid scales
* are ones with the `tickFormat` property.
*/
readonly yType: (domain: Iterable<d3.NumberValue>, range: Iterable<number>) => d3.AxisScale<Date | d3.NumberValue>;
/** y domain min and max */
readonly yDomain?: readonly [number, number];
/** y range min and max */
readonly yRange: readonly [number, number];
/** stroke color of line */
readonly lineColor: string;
/** stroke line cap of the line */
readonly strokeLinecap: string;
/** stroke line join of the line */
readonly strokeLinejoin: string;
/** stroke width of line (px) */
readonly strokeWidth: number;
/** stroke opacity of line */
readonly strokeOpacity: number;
/** a format specifier string for the x-axis */
readonly xFormat: string;
/** a format specifier string for the y-axis */
readonly yFormat: string;
/** x-axis label */
readonly xLabel: string;
/** y-axis label */
readonly yLabel: string;
/** the y value at which to render the x axis (useful for log scales that don't have y=0) */
readonly xAxisOffset: number;
/** whether to draw the lines connecting data points */
readonly drawLine: boolean;
/** whether to draw the data points */
readonly drawPoints: boolean;
/** point radius */
readonly pointRadius: number;
readonly pointFillColor: string;
readonly pointFillOpacity: number;
readonly pointStrokeColor: string;
readonly pointStrokeOpacity: number;
/** stroke color of line, as a constant or a function of z */
readonly color: string;
/** blend mode of lines */
readonly mixBlendMode: string;
}) => SVGSVGElement;
228 changes: 228 additions & 0 deletions build/lib/D3LineChart.js

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions build/lib/ReactLineChart.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/// <reference types="react" />
interface Margins {
top: number;
right: number;
bottom: number;
left: number;
}
export interface ChartProps<T> {
data: T[];
getX: (p: T) => number;
getY: (p: T) => number;
getZ?: (p: T) => string;
xAxisLabel?: string;
yAxisLabel?: string;
height: number;
width?: number;
margins?: Partial<Margins>;
axisWidth?: number;
axisColor?: string;
pointRadius?: number;
pointOpacity?: number;
lineWidth?: number;
showPoints?: boolean;
showLines?: boolean;
showEndpointLabels?: boolean;
chartType?: "linear" | "log";
yDomain?: [number, number];
xAxisLocation?: number;
}
export declare const Chart: <T>(props: ChartProps<T>) => JSX.Element;
export declare const render: <T>(props: ChartProps<T>) => (target: HTMLElement) => void;
export {};
Loading