Compare commits
148 Commits
svg-versio
...
main
Author | SHA1 | Date |
---|---|---|
Coin de Gamma | 348a289f1a | 2 months ago |
glitch4347 | 17a2fdf94e | 2 months ago |
Coin de Gamma | dc89f6cbb9 | 2 months ago |
glitch4347 | 547c15c0b6 | 2 months ago |
glitch4347 | 32d122ba4d | 2 months ago |
glitch4347 | 9c165f4e1f | 2 months ago |
Coin de Gamma | ec2bd27acd | 2 months ago |
glitch4347 | 815144d209 | 2 months ago |
glitch4347 | 1a80ca2cab | 2 months ago |
Coin de Gamma | ee08db2f54 | 2 months ago |
glitch4347 | 884fed6582 | 2 months ago |
glitch4347 | 8aca72ce04 | 2 months ago |
Coin de Gamma | c62a1c386f | 2 months ago |
glitch4347 | de6237891c | 2 months ago |
rozetko | 7bcd0d298a | 3 months ago |
rozetko | ee2f02be96 | 3 months ago |
rozetko | 456b888fe1 | 4 months ago |
rozetko | a34c0574e4 | 4 months ago |
rozetko | 73dbf0ea67 | 4 months ago |
rozetko | ff5973b106 | 4 months ago |
rozetko | 878e86d849 | 4 months ago |
vargburz | 1e8f8d0cb3 | 4 months ago |
rozetko | 39412e5f65 | 4 months ago |
rozetko | 37da147343 | 4 months ago |
glitch4347 | 0dac1c390e | 4 months ago |
glitch4347 | 07f454fe51 | 4 months ago |
vargburz | 88d6b2b24a | 4 months ago |
glitch4347 | 837004c2ad | 4 months ago |
glitch4347 | e46c7bdfb6 | 4 months ago |
rozetko | ee7a57685f | 5 months ago |
rozetko | 963011b274 | 5 months ago |
glitch4347 | 283f0995e8 | 5 months ago |
rozetko | 19689a68cd | 5 months ago |
glitch4347 | 79b759569f | 5 months ago |
glitch4347 | d66da50c1a | 5 months ago |
glitch4347 | d9d1b5e501 | 5 months ago |
Coin de Gamma | b8cd14e4b8 | 5 months ago |
glitch4347 | e470d58611 | 5 months ago |
glitch4347 | 26d5956c17 | 5 months ago |
glitch4347 | 43241bbcb7 | 5 months ago |
glitch4347 | 82fc9a10f1 | 5 months ago |
rozetko | 57ae85c20e | 5 months ago |
glitch4347 | 98e4e42fc4 | 5 months ago |
glitch4347 | 6fbf833150 | 5 months ago |
glitch4347 | a0e27d5efd | 5 months ago |
glitch4347 | 727f8cac86 | 5 months ago |
glitch4347 | 869488d405 | 5 months ago |
glitch4347 | d97b0e9b0c | 5 months ago |
glitch4347 | 11ab01a7d2 | 5 months ago |
glitch4347 | 326c666435 | 5 months ago |
rozetko | 33cf970d5f | 5 months ago |
glitch4347 | 03a562c0d2 | 5 months ago |
glitch4347 | 38b6eb2326 | 5 months ago |
rozetko | af9aaf6d82 | 5 months ago |
glitch4347 | bf679019fc | 5 months ago |
glitch4347 | 86099c57b3 | 5 months ago |
glitch4347 | 9a6c5cd7f4 | 5 months ago |
glitch4347 | aadcd013bf | 5 months ago |
glitch4347 | a5c737fa81 | 5 months ago |
rozetko | c451df6e3b | 5 months ago |
rozetko | 3ff6f7b8e8 | 5 months ago |
glitch4347 | 1d1a34f9bf | 5 months ago |
glitch4347 | 8346bceedf | 5 months ago |
vargburz | 1ca84c53f8 | 5 months ago |
vargburz | 85793a7965 | 5 months ago |
vargburz | 7e4a895e93 | 5 months ago |
glitch4347 | f1c3ef6f1d | 5 months ago |
rozetko | 6a0ea4303e | 5 months ago |
glitch4347 | 08b128ea91 | 5 months ago |
glitch4347 | f1582fc610 | 5 months ago |
glitch4347 | e98997995f | 5 months ago |
rozetko | e809046098 | 5 months ago |
glitch4347 | 833780105a | 6 months ago |
glitch4347 | 2e156ad46b | 6 months ago |
vargburz | f100af0ee8 | 6 months ago |
vargburz | 927855ad45 | 6 months ago |
glitch4347 | a6841a83b0 | 6 months ago |
glitch4347 | 5c39f741ff | 6 months ago |
rozetko | a9f5d074ce | 11 months ago |
rozetko | e3d261aa30 | 11 months ago |
rozetko | 4dc9c5290d | 11 months ago |
vargburz | d3597763c5 | 1 year ago |
Alexander Velikiy | 517c014629 | 1 year ago |
vargburz | d763d8591b | 1 year ago |
vargburz | 7d9f38fa3c | 1 year ago |
Alexander Velikiy | 60904493dd | 1 year ago |
vargburz | 903817cb9c | 1 year ago |
vargburz | 8825f8b0ba | 2 years ago |
Eugene Petukhov | db30589898 | 2 years ago |
Eugene Petukhov | f701b29bab | 2 years ago |
vargburz | b7c6bb7fd8 | 2 years ago |
rozetko | fa632d35a9 | 2 years ago |
rozetko | a448f62fc9 | 2 years ago |
rozetko | cf5722484a | 2 years ago |
rozetko | 49c5c3d462 | 2 years ago |
vargburz | 0a04633b43 | 2 years ago |
vargburz | dd6485bef5 | 2 years ago |
vargburz | b0b2b48f4d | 2 years ago |
vargburz | b082e71822 | 2 years ago |
vargburz | c93bcddee4 | 2 years ago |
vargburz | 7cc885e2c7 | 2 years ago |
vargburz | 550ca9a807 | 2 years ago |
vargburz | 15587d9bfa | 2 years ago |
Alexander Velikiy | 9bf20c4169 | 2 years ago |
vargburz | b65b04c574 | 2 years ago |
vargburz | 70966b323f | 2 years ago |
vargburz | ca3dc0b8f1 | 2 years ago |
vargburz | f9d505fd92 | 2 years ago |
vargburz | 463bce47c6 | 2 years ago |
vargburz | f593206a98 | 2 years ago |
vargburz | e7248806b0 | 2 years ago |
rozetko | 88074bc683 | 2 years ago |
rozetko | b79b590efb | 2 years ago |
rozetko | cafa719a66 | 2 years ago |
rozetko | 998a13c1ba | 2 years ago |
rozetko | 38d0c11bfc | 2 years ago |
rozetko | 1eec6ba665 | 2 years ago |
rozetko | a5e6654742 | 2 years ago |
rozetko | f2369e2745 | 2 years ago |
rozetko | 4586ea94f9 | 2 years ago |
rozetko | 012434093c | 2 years ago |
rozetko | 7e4dc84f45 | 2 years ago |
vargburz | 22da5ce798 | 2 years ago |
Alexander Velikiy | 521a4adc25 | 2 years ago |
vargburz | 13dc3f8abe | 2 years ago |
vargburz | c9931aba33 | 2 years ago |
rozetko | 323d4c677e | 2 years ago |
rozetko | 45965dd825 | 2 years ago |
rozetko | a47cb94980 | 2 years ago |
rozetko | 0817073ef8 | 2 years ago |
vargburz | 788374111b | 2 years ago |
Alexander Velikiy | a488abacbd | 2 years ago |
vargburz | be30b9e9f8 | 2 years ago |
rozetko | 85436b735a | 2 years ago |
rozetko | 45cf408bb8 | 2 years ago |
rozetko | 76e9ff78cf | 2 years ago |
rozetko | 4c970950e2 | 2 years ago |
dv4mp1r3 | 6dce9d17eb | 2 years ago |
dv4mp1r3 | ce7b3df610 | 2 years ago |
dv4mp1r3 | 847a3bce56 | 2 years ago |
dv4mp1r3 | bbfea95deb | 2 years ago |
dv4mp1r3 | 9db0d99511 | 2 years ago |
dv4mp1r3 | e72cd8e319 | 2 years ago |
Alexander Velikiy | b23918fcf9 | 2 years ago |
vargburz | d6be304cb0 | 2 years ago |
vargburz | 55ee802dec | 2 years ago |
vargburz | 923fd31263 | 2 years ago |
vargburz | 4b9174414f | 2 years ago |
37 changed files with 5033 additions and 8321 deletions
@ -1 +1,10 @@
|
||||
node_modules |
||||
dist |
||||
|
||||
# yarn |
||||
.yarn/* |
||||
!.yarn/patches |
||||
!.yarn/plugins |
||||
!.yarn/releases |
||||
!.yarn/sdks |
||||
!.yarn/versions |
||||
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,3 @@
|
||||
nodeLinker: node-modules |
||||
|
||||
yarnPath: .yarn/releases/yarn-3.2.1.cjs |
@ -1,2 +1,43 @@
|
||||
# Chartwerk Line Pod |
||||
## Including |
||||
|
||||
### Browser |
||||
|
||||
#### Script tag |
||||
```html |
||||
<script src="https://unpkg.com/@chartwerk/line-pod@latest/dist/index.dev.js" type="text/javascript"></script> |
||||
``` |
||||
|
||||
#### Example |
||||
```html |
||||
<div id="line-chart" class="chart-block" style="width: 100%; height: 400px;"></div> |
||||
|
||||
<script src="https://unpkg.com/@chartwerk/line-pod@latest/dist/index.dev.js" type="text/javascript"></script> |
||||
<script> |
||||
new LinePod(document.getElementById('yourDivId', yourData, yourOptions)).render(); |
||||
</script> |
||||
``` |
||||
|
||||
#### Other examples |
||||
* [Basic](https://code.corpglory.net/chartwerk/line-pod/src/branch/main/examples/basic.html) |
||||
* [Live](https://code.corpglory.net/chartwerk/line-pod/src/branch/main/examples/live.html) |
||||
* [Vertical](https://code.corpglory.net/chartwerk/line-pod/src/branch/main/examples/vertical.html) |
||||
* [Segments](https://code.corpglory.net/chartwerk/line-pod/src/branch/main/examples/segments.html) |
||||
* [Markers](https://code.corpglory.net/chartwerk/line-pod/src/branch/main/examples/markers.html) |
||||
|
||||
### Development |
||||
|
||||
If you want to link `core` then clone it to same directory and then run |
||||
|
||||
``` |
||||
yarn link ../core |
||||
``` |
||||
|
||||
but don't add `resolutions` logic to `package.json` |
||||
|
||||
then run |
||||
|
||||
``` |
||||
yarn install |
||||
yarn dev |
||||
``` |
@ -1,100 +0,0 @@
|
||||
import { ChartwerkPod, TickOrientation, TimeFormat } from '@chartwerk/core'; |
||||
import { LineTimeSerie, LineOptions, Mode } from './types'; |
||||
export declare class LinePod extends ChartwerkPod<LineTimeSerie, LineOptions> { |
||||
lineGenerator: any; |
||||
constructor(_el: HTMLElement, _series?: LineTimeSerie[], _options?: LineOptions); |
||||
renderMetrics(): void; |
||||
clearAllMetrics(): void; |
||||
initLineGenerator(): void; |
||||
appendData(data: [number, number][], shouldRerender?: boolean): void; |
||||
_renderDots(datapoints: number[][], serieIdx: number): void; |
||||
_renderLines(datapoints: number[][], serieIdx: number): void; |
||||
_renderMetric(datapoints: number[][], metricOptions: { |
||||
color: string; |
||||
confidence: number; |
||||
target: string; |
||||
mode: Mode; |
||||
serieIdx: number; |
||||
renderDots: boolean; |
||||
renderLines: boolean; |
||||
}): void; |
||||
updateCrosshair(): void; |
||||
appendCrosshairCircles(): void; |
||||
appendCrosshairCircle(serieIdx: number): void; |
||||
renderSharedCrosshair(values: { |
||||
x?: number; |
||||
y?: number; |
||||
}): void; |
||||
hideSharedCrosshair(): void; |
||||
moveCrosshairLine(xPosition: number, yPosition: number): void; |
||||
moveCrosshairCircle(xPosition: number, yPosition: number, serieIdx: number): void; |
||||
hideCrosshairCircle(serieIdx: number): void; |
||||
getClosestDatapoint(serie: LineTimeSerie, xValue: number, yValue: number): [number, number]; |
||||
getClosestIndex(datapoints: [number, number][], xValue: number, yValue: number): number; |
||||
getValueInterval(columnIdx: number): number | undefined; |
||||
onMouseMove(): void; |
||||
findAndHighlightDatapoints(xValue: number, yValue: number): { |
||||
value: [number, number]; |
||||
color: string; |
||||
label: string; |
||||
}[]; |
||||
isOutOfRange(closestDatapoint: [number, number], xValue: number, yValue: number, useOutOfRange?: boolean): boolean; |
||||
onMouseOver(): void; |
||||
onMouseOut(): void; |
||||
protected zoomOut(): void; |
||||
} |
||||
export declare const VueChartwerkLinePod: { |
||||
render(createElement: any): any; |
||||
mixins: { |
||||
props: { |
||||
id: { |
||||
type: StringConstructor; |
||||
required: boolean; |
||||
}; |
||||
series: { |
||||
type: ArrayConstructor; |
||||
required: boolean; |
||||
default: () => any[]; |
||||
}; |
||||
options: { |
||||
type: ObjectConstructor; |
||||
required: boolean; |
||||
default: () => {}; |
||||
}; |
||||
}; |
||||
watch: { |
||||
id(): void; |
||||
series(): void; |
||||
options(): void; |
||||
}; |
||||
mounted(): void; |
||||
destroyed(): void; |
||||
methods: { |
||||
render(): void; |
||||
renderSharedCrosshair(values: { |
||||
x?: number; |
||||
y?: number; |
||||
}): void; |
||||
hideSharedCrosshair(): void; |
||||
onPanningRescale(event: any): void; |
||||
renderChart(): void; |
||||
appendEvents(): void; |
||||
zoomIn(range: any): void; |
||||
zoomOut(centers: any): void; |
||||
mouseMove(evt: any): void; |
||||
mouseOut(): void; |
||||
onLegendClick(idx: any): void; |
||||
panningEnd(range: any): void; |
||||
panning(range: any): void; |
||||
contextMenu(evt: any): void; |
||||
sharedCrosshairMove(event: any): void; |
||||
renderEnd(): void; |
||||
}; |
||||
}[]; |
||||
methods: { |
||||
render(): void; |
||||
renderSharedCrosshair(values: any): void; |
||||
hideSharedCrosshair(): void; |
||||
}; |
||||
}; |
||||
export { LineTimeSerie, LineOptions, Mode, TickOrientation, TimeFormat }; |
File diff suppressed because one or more lines are too long
@ -1,18 +0,0 @@
|
||||
import { TimeSerie, Options } from '@chartwerk/core'; |
||||
declare type LineTimeSerieParams = { |
||||
confidence: number; |
||||
mode: Mode; |
||||
maxLength: number; |
||||
renderDots: boolean; |
||||
renderLines: boolean; |
||||
useOutOfRange: boolean; |
||||
dashArray: string; |
||||
class: string; |
||||
}; |
||||
export declare enum Mode { |
||||
STANDARD = "Standard", |
||||
CHARGE = "Charge" |
||||
} |
||||
export declare type LineTimeSerie = TimeSerie & Partial<LineTimeSerieParams>; |
||||
export declare type LineOptions = Options; |
||||
export {}; |
@ -0,0 +1,42 @@
|
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> |
||||
<meta content="utf-8" http-equiv="encoding"> |
||||
|
||||
<script src="../dist/index.dev.js" type="text/javascript"></script> |
||||
</head> |
||||
<body> |
||||
<div id="chart" style="width: 100%; height: 500px;"></div> |
||||
|
||||
<script type="text/javascript"> |
||||
const startTime = 1701790172908; |
||||
const timeSerieData = [5, 6, 3, 7, 5, 6, 8, 4, 5, 6, 4, 3, 5, 7, 8] |
||||
.map((el, idx) => [startTime + idx * 1000, el]); |
||||
// TODO: make this one-dimensinal data when implemented |
||||
const markersData1 = [3, 6, 9].map(el => [startTime + el * 1000]); |
||||
const markersData2 = [4, 11].map(el => [startTime + el * 1000]); |
||||
let options = { |
||||
renderLegend: false, |
||||
axis: { |
||||
y: { range: [0, 10] }, |
||||
x: { format: 'time' } |
||||
}, |
||||
} |
||||
var pod = new LinePod( |
||||
document.getElementById('chart'), |
||||
[ |
||||
{ datapoints: timeSerieData, color: 'black' }, |
||||
], |
||||
options, |
||||
{ |
||||
series: [ |
||||
{ data: markersData1, color: 'red' }, |
||||
{ data: markersData2, color: 'blue' }, |
||||
] |
||||
} |
||||
); |
||||
pod.render(); |
||||
</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,47 @@
|
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> |
||||
<meta content="utf-8" http-equiv="encoding"> |
||||
|
||||
<script src="../dist/index.dev.js" type="text/javascript"></script> |
||||
</head> |
||||
<body> |
||||
<div id="chart" style="width: 100%; height: 500px;"></div> |
||||
|
||||
<script type="text/javascript"> |
||||
const startTime = 1701790172908; |
||||
const timeSerieData = [5, 6, 3, 7, 5, 6, 8, 4, 5, 6, 4, 3, 5, 7, 8] |
||||
.map((el, idx) => [startTime + idx * 1000, el]); |
||||
// TODO: make this one-dimensinal data when implemented |
||||
const markersData = [3, 6, 9].map(el => [ |
||||
startTime + el * 1000, |
||||
{ el } |
||||
]); |
||||
let options = { |
||||
renderLegend: false, |
||||
axis: { |
||||
y: { range: [0, 10] }, |
||||
x: { format: 'time' } |
||||
}, |
||||
} |
||||
var pod = new LinePod( |
||||
document.getElementById('chart'), |
||||
[ |
||||
{ datapoints: timeSerieData, color: 'black' }, |
||||
], |
||||
options, |
||||
{ |
||||
series: [ |
||||
{ data: markersData, color: 'red' }, |
||||
], |
||||
events: { |
||||
onMouseMove: (el) => { console.log(el); }, |
||||
onMouseOut: () => { console.log('mouse out'); } |
||||
} |
||||
} |
||||
); |
||||
pod.render(); |
||||
</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> |
||||
<meta content="utf-8" http-equiv="encoding"> |
||||
<script src="../dist/index.dev.js" type="text/javascript"></script> |
||||
</head> |
||||
<body> |
||||
<div id="chart" style="width: 50%; height: 500px;"></div> |
||||
<script type="text/javascript"> |
||||
const startTime = 1590590148; |
||||
const data = Array.from( |
||||
{ length: 20 }, |
||||
(el, idx) => [startTime + idx * 10000, Math.floor(Math.random() * 30)] |
||||
); |
||||
let options = { |
||||
renderLegend: false, usePanning: false, |
||||
axis: { y: { range: [0, 50] } }, |
||||
zoomEvents: { mouse: { |
||||
zoom: { isActive: false }, |
||||
pan: { isActive: false }, |
||||
} }, |
||||
eventsCallbacks: { mouseClick: console.log } |
||||
} |
||||
var pod = new LinePod( |
||||
document.getElementById('chart'), |
||||
[{ datapoints: data }], |
||||
options |
||||
); |
||||
pod.render(); |
||||
</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> |
||||
<meta content="utf-8" http-equiv="encoding"> |
||||
<script src="../dist/index.dev.js" type="text/javascript"></script> |
||||
</head> |
||||
<body> |
||||
<div id="chart" style="width: 50%; height: 500px;"></div> |
||||
<script type="text/javascript"> |
||||
const startTime = 1590590148; |
||||
const data = Array.from( |
||||
{ length: 20 }, |
||||
(el, idx) => [startTime + idx * 10000, Math.floor(Math.random() * 30)] |
||||
); |
||||
let options = { |
||||
renderLegend: false, usePanning: false, |
||||
axis: { y: { range: [0, 50] } }, |
||||
eventsCallbacks: { mouseMove: console.log } |
||||
} |
||||
var pod = new LinePod( |
||||
document.getElementById('chart'), |
||||
[{ datapoints: data }], |
||||
options |
||||
); |
||||
pod.render(); |
||||
</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> |
||||
<meta content="utf-8" http-equiv="encoding"> |
||||
|
||||
<script src="../dist/index.dev.js" type="text/javascript"></script> |
||||
</head> |
||||
<body> |
||||
<div id="chart" style="width: 100%; height: 500px;"></div> |
||||
|
||||
<script type="text/javascript"> |
||||
const startTime = 1701790172908; |
||||
const timeSerieData = [5, 6, 3, 7, 5, 6, 8, 4, 5, 6, 4, 3, 5, 7, 8] |
||||
.map((el, idx) => [startTime + idx * 1000, el]); |
||||
const segmentsData = [3, 6, 9].map(el => [startTime + el * 1000, startTime + (el + 1) * 1000]); |
||||
let options = { |
||||
renderLegend: false, |
||||
axis: { |
||||
y: { range: [0, 10] }, |
||||
x: { format: 'time' } |
||||
}, |
||||
} |
||||
var pod = new LinePod( |
||||
document.getElementById('chart'), |
||||
[ |
||||
{ datapoints: timeSerieData, color: 'black' }, |
||||
], |
||||
options, |
||||
[], |
||||
[ |
||||
{ data: segmentsData, color:'#FFE545' } |
||||
] |
||||
); |
||||
pod.render(); |
||||
</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> |
||||
<meta content="utf-8" http-equiv="encoding"> |
||||
<script src="../dist/index.dev.js" type="text/javascript"></script> |
||||
</head> |
||||
<body> |
||||
<div id="chart" style="width: 50%; height: 500px;"></div> |
||||
<script type="text/javascript"> |
||||
const startTime = 1590590148; |
||||
const data = Array.from( |
||||
{ length: 20 }, |
||||
(el, idx) => [startTime + idx * 10000, Math.floor(Math.random() * 30)] |
||||
); |
||||
let options = { |
||||
renderLegend: false, usePanning: false, |
||||
axis: { y: { range: [0, 50] } }, |
||||
zoomEvents: { mouse: { |
||||
zoom: { isActive: true, orientation: "horizontal" }, |
||||
pan: { isActive: false }, |
||||
}}, |
||||
events: { |
||||
zoomOut: function(centers, ranges) { |
||||
console.log('zoomOut', centers, ranges); |
||||
} |
||||
} |
||||
} |
||||
var pod = new LinePod( |
||||
document.getElementById('chart'), |
||||
[{ datapoints: data }], |
||||
options |
||||
); |
||||
pod.render(); |
||||
</script> |
||||
</body> |
||||
</html> |
@ -1,32 +1,37 @@
|
||||
{ |
||||
"name": "@chartwerk/line-pod", |
||||
"version": "0.4.8", |
||||
"version": "0.6.18", |
||||
"description": "Chartwerk line chart", |
||||
"main": "dist/index.js", |
||||
"files": [ |
||||
"/dist" |
||||
], |
||||
"scripts": { |
||||
"build": "webpack --config build/webpack.prod.conf.js", |
||||
"dev": "webpack --config build/webpack.dev.conf.js", |
||||
"test": "echo \"Error: no test specified\" && exit 1" |
||||
"build": "rm -rf dist && cd react && yarn build && cd .. && webpack --config build/webpack.prod.conf.js && webpack --config build/webpack.dev.conf.js", |
||||
"dev": "webpack --watch --config build/webpack.dev.conf.js", |
||||
"test": "echo \"Error: no test specified\" && exit 1", |
||||
"update-core": "yarn up @chartwerk/core && yarn up @chartwerk/core@latest" |
||||
}, |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://gitlab.com/chartwerk/line-pod.git" |
||||
"url": "http://code.corpglory.net/chartwerk/line-pod.git" |
||||
}, |
||||
"author": "CorpGlory", |
||||
"license": "ISC", |
||||
"dependencies": { |
||||
"@chartwerk/core": "^0.3.4" |
||||
"@chartwerk/core": "^0.6.23" |
||||
}, |
||||
"devDependencies": { |
||||
"@types/d3": "5.16.4", |
||||
"@types/lodash": "^4.14.149", |
||||
"css-loader": "^3.4.2", |
||||
"d3": "5.16.0", |
||||
"lodash": "^4.17.15", |
||||
"style-loader": "^1.1.3", |
||||
"ts-loader": "^6.2.1", |
||||
"typescript": "^3.8.3", |
||||
"webpack": "^4.42.0", |
||||
"webpack-cli": "^3.3.11" |
||||
} |
||||
"copy-webpack-plugin": "^11.0.0", |
||||
"css-loader": "^6.8.1", |
||||
"style-loader": "^3.3.3", |
||||
"ts-loader": "^9.4.3", |
||||
"typescript": "^5.1.3", |
||||
"webpack": "^5.87.0", |
||||
"webpack-cli": "^5.1.4" |
||||
}, |
||||
"packageManager": "yarn@3.2.1", |
||||
"workspaces": [ |
||||
"react/*" |
||||
] |
||||
} |
||||
|
@ -0,0 +1,26 @@
|
||||
const path = require('path'); |
||||
|
||||
module.exports = { |
||||
entry: './src/index.tsx', |
||||
module: { |
||||
rules: [ |
||||
{ |
||||
test: /\.tsx?$/, |
||||
use: 'ts-loader', |
||||
exclude: /node_modules/, |
||||
}, |
||||
], |
||||
}, |
||||
resolve: { |
||||
extensions: ['.tsx', '.ts', '.js'], |
||||
}, |
||||
output: { |
||||
filename: 'index.js', |
||||
path: path.resolve(__dirname, '../dist'), |
||||
libraryTarget: 'umd', |
||||
umdNamedDefine: true, |
||||
}, |
||||
externals: [ |
||||
'@chartwerk/line-pod', 'react' |
||||
] |
||||
}; |
@ -0,0 +1,8 @@
|
||||
const baseWebpackConfig = require('./webpack.base.conf'); |
||||
|
||||
var conf = baseWebpackConfig; |
||||
conf.devtool = 'inline-source-map'; |
||||
conf.mode = 'development'; |
||||
conf.output.filename = 'index.dev.js'; |
||||
|
||||
module.exports = conf; |
@ -0,0 +1,6 @@
|
||||
const baseWebpackConfig = require('./webpack.base.conf'); |
||||
|
||||
var conf = baseWebpackConfig; |
||||
conf.mode = 'production'; |
||||
|
||||
module.exports = baseWebpackConfig; |
@ -0,0 +1,23 @@
|
||||
{ |
||||
"name": "line-pod-react", |
||||
"version": "0.0.1", |
||||
"description": "React wrapper around line-pod", |
||||
"main": "dist/index.js", |
||||
"repository": "http://code.corpglory.net/chartwerk/line-pod.git", |
||||
"author": "CorpGlory Inc.", |
||||
"license": "ISC", |
||||
"scripts": { |
||||
"build": "webpack --config build/webpack.prod.conf.js", |
||||
"dev": "webpack --config build/webpack.dev.conf.js" |
||||
}, |
||||
"dependencies": { |
||||
"@chartwerk/line-pod": "workspace:*", |
||||
"react": "^18.2.0", |
||||
"react-dom": "^18.2.0" |
||||
}, |
||||
"devDependencies": { |
||||
"ts-loader": "^9.5.1", |
||||
"typescript": "^5.4.3", |
||||
"webpack": "^5.87.0" |
||||
} |
||||
} |
@ -0,0 +1,74 @@
|
||||
import { LineTimeSerie, LineOptions, LinePod } from '@chartwerk/line-pod'; |
||||
import { MarkersConf } from '@chartwerk/line-pod/dist/models/marker'; |
||||
import { SegmentSerie } from '@chartwerk/line-pod/dist/models/segment'; |
||||
|
||||
import React, { useEffect, useRef, useState } from 'react'; |
||||
|
||||
import _ from 'lodash'; |
||||
|
||||
|
||||
export type ChartwerkLinePodProps = { |
||||
id?: string; |
||||
series: LineTimeSerie[]; |
||||
options?: LineOptions; |
||||
markersConf?: MarkersConf, |
||||
segments?: SegmentSerie[], |
||||
className?: string; |
||||
} |
||||
|
||||
export function ChartwerkLinePod(props: ChartwerkLinePodProps) { |
||||
|
||||
const [pod, setPod] = useState<LinePod | null>(null); |
||||
const [hack, setHack] = useState<number | null>(null); |
||||
|
||||
const chartRef = useRef(null); |
||||
const chart = chartRef.current; |
||||
|
||||
useEffect(() => { |
||||
// this function will be called on component unmount
|
||||
return () => { |
||||
if(pod === null) { return; } |
||||
// @ts-ignore
|
||||
pod.removeEventListeners(); |
||||
} |
||||
}, []); |
||||
|
||||
useEffect(() => { |
||||
if(chart === null) { return; } |
||||
if(pod === null) { |
||||
const newPod = new LinePod( |
||||
// @ts-ignore
|
||||
chart, |
||||
props.series, |
||||
props.options, |
||||
props.markersConf, |
||||
props.segments |
||||
); |
||||
setPod(newPod); |
||||
newPod.render(); |
||||
} else { |
||||
if(props.markersConf) { |
||||
pod.updateMarkers(props.markersConf); |
||||
} |
||||
if(props.segments) { |
||||
pod.updateSegments(props.segments); |
||||
} |
||||
// TODO: actually it's wrong logic with updates
|
||||
// because it creates new pod anyway
|
||||
pod.updateData(props.series, props.options); |
||||
} |
||||
}, [chart, props.id, props.options, props.markersConf, props.segments]); |
||||
|
||||
// TODO: it's a hack to render the LinePod right after the div appears in DOM
|
||||
setTimeout(() => { |
||||
if(hack === null) { |
||||
setHack(1); |
||||
} |
||||
}, 1); |
||||
|
||||
return ( |
||||
<div id={props.id} className={props.className} ref={chartRef}></div> |
||||
); |
||||
} |
||||
|
||||
export default ChartwerkLinePod; |
@ -0,0 +1,23 @@
|
||||
{ |
||||
"compilerOptions": { |
||||
"target": "es5", |
||||
"rootDir": "./src", |
||||
"module": "esnext", |
||||
"moduleResolution": "node", |
||||
"declaration": true, |
||||
"declarationDir": "dist", |
||||
"allowSyntheticDefaultImports": true, |
||||
"inlineSourceMap": false, |
||||
"sourceMap": true, |
||||
"noEmitOnError": false, |
||||
"emitDecoratorMetadata": false, |
||||
"experimentalDecorators": true, |
||||
"noImplicitReturns": true, |
||||
"noImplicitThis": false, |
||||
"noImplicitUseStrict": false, |
||||
"noImplicitAny": false, |
||||
"noUnusedLocals": false, |
||||
"baseUrl": "./src", |
||||
"jsx": "react" |
||||
} |
||||
} |
@ -0,0 +1,59 @@
|
||||
import { MarkersConf, MarkerSerie } from "../models/marker"; |
||||
import { PodState } from "@chartwerk/core"; |
||||
import { LineTimeSerie, LineOptions } from "../types"; |
||||
|
||||
import d3 from "d3"; |
||||
|
||||
export class Markers { |
||||
// TODO: more semantic name
|
||||
private _d3Holder = null; |
||||
|
||||
constructor(private _markerConf: MarkersConf, private _state: PodState<LineTimeSerie, LineOptions>) { |
||||
|
||||
} |
||||
|
||||
render(metricContainer: d3.Selection<SVGGElement, unknown, null, undefined>) { |
||||
if(this._d3Holder !== null) { |
||||
this._d3Holder.remove(); |
||||
} |
||||
this._d3Holder = metricContainer.append('g').attr('class', 'markers-layer'); |
||||
for (const ms of this._markerConf.series) { |
||||
this.renderSerie(ms); |
||||
} |
||||
} |
||||
|
||||
protected renderSerie(serie: MarkerSerie) { |
||||
serie.data.forEach((d) => { |
||||
let linePosition = this._state.xScale(d[0]) as number; |
||||
this._d3Holder.append('line') |
||||
.attr('class', 'gap-line') |
||||
.attr('stroke', serie.color) |
||||
.attr('stroke-width', '1px') |
||||
.attr('stroke-opacity', '0.3') |
||||
.attr('stroke-dasharray', '4') |
||||
.attr('x1', linePosition) |
||||
.attr('x2', linePosition) |
||||
.attr('y1', 0) |
||||
// @ts-ignore // TODO: remove ignore but boxParams are protected
|
||||
.attr('y2', this._state.boxParams.height) |
||||
.attr('pointer-events', 'none'); |
||||
let circle = this._d3Holder.append('circle') |
||||
.attr('class', 'gap-circle') |
||||
.attr('stroke', serie.color) |
||||
.attr('stroke-width', '2px') |
||||
.attr('r', 4) |
||||
.attr('cx', linePosition) |
||||
.attr('cy', 5) |
||||
|
||||
if(this._markerConf !== undefined) { |
||||
circle |
||||
.attr('pointer-events', 'all') |
||||
.style('cursor', 'pointer') |
||||
.on('mousemove', () => this._markerConf.events.onMouseMove(d)) |
||||
.on('mouseout', () => this._markerConf.events.onMouseOut()) |
||||
} |
||||
|
||||
}); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,45 @@
|
||||
import { SegmentSerie } from "../models/segment"; |
||||
import { PodState } from "@chartwerk/core"; |
||||
import { LineTimeSerie, LineOptions } from "../types"; |
||||
|
||||
import d3 from "d3"; |
||||
|
||||
export class Segments { |
||||
// TODO: more semantic name
|
||||
private _d3Holder = null; |
||||
|
||||
constructor(private _series: SegmentSerie[], private _state: PodState<LineTimeSerie, LineOptions>) { |
||||
} |
||||
|
||||
render(metricContainer: d3.Selection<SVGGElement, unknown, null, undefined>) { |
||||
if(this._d3Holder !== null) { |
||||
this._d3Holder.remove(); |
||||
} |
||||
this._d3Holder = metricContainer.append('g').attr('class', 'markers-layer'); |
||||
for (const s of this._series) { |
||||
this.renderSerie(s); |
||||
} |
||||
} |
||||
|
||||
protected renderSerie(serie: SegmentSerie) { |
||||
serie.data.forEach((d) => { |
||||
// @ts-ignore
|
||||
const startPositionX = this._state.xScale(d[0]) as number; |
||||
// @ts-ignore
|
||||
const endPositionX = this._state.xScale(d[1]) as number; |
||||
const width = endPositionX - startPositionX // Math.max(endPositionX - startPositionX, MIMIMUM_SEGMENT_WIDTH);
|
||||
|
||||
this._d3Holder.append('rect') |
||||
.attr('class', 'segment') |
||||
.attr('x', startPositionX) |
||||
.attr('y', 0) |
||||
.attr('width', width) |
||||
// @ts-ignore // TODO: remove ignore but boxParams are protected
|
||||
.attr('height', this._state.boxParams.height) |
||||
.attr('opacity', 0.3) |
||||
.style('fill', serie.color) |
||||
.style('pointer-events', 'none'); |
||||
}); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,21 @@
|
||||
import { CoreSeries, yAxisOrientation } from '@chartwerk/core'; |
||||
import { LineTimeSerie } from '../types'; |
||||
|
||||
import * as _ from 'lodash'; |
||||
|
||||
|
||||
const LINE_SERIE_DEFAULTS = { |
||||
maxLength: undefined, |
||||
renderDots: false, |
||||
renderLines: true, |
||||
dashArray: '0', |
||||
class: '', |
||||
renderArea: false, |
||||
yOrientation: yAxisOrientation.LEFT, |
||||
}; |
||||
|
||||
export class LineSeries extends CoreSeries<LineTimeSerie> { |
||||
constructor(series: LineTimeSerie[]) { |
||||
super(series, _.clone(LINE_SERIE_DEFAULTS)); |
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
export type MarkerElem = [number, any?]; |
||||
|
||||
export type MarkerSerie = { |
||||
color: string; |
||||
// TODO: make one-dimensional array with only x
|
||||
data: MarkerElem[] // [x, payload] payload is any data for tooltip
|
||||
} |
||||
|
||||
export type MarkersConf = { |
||||
series: MarkerSerie[], |
||||
events?: { |
||||
onMouseMove?: (el: MarkerElem) => void; |
||||
onMouseOut?: () => void; |
||||
} |
||||
} |
@ -0,0 +1,4 @@
|
||||
export type SegmentSerie = { |
||||
color: string; |
||||
data: [number, number, any?][] // [from, to, payload?] payload is any data for tooltip
|
||||
} |
@ -1,18 +1,31 @@
|
||||
import { TimeSerie, Options } from '@chartwerk/core'; |
||||
import { Serie, Options } from '@chartwerk/core'; |
||||
import { AxisRange } from '@chartwerk/core/dist/types'; |
||||
|
||||
type LineTimeSerieParams = { |
||||
confidence: number, |
||||
mode: Mode, |
||||
maxLength: number, |
||||
renderDots: boolean, |
||||
renderLines: boolean, // TODO: refactor same as scatter-pod
|
||||
useOutOfRange: boolean, // It's temporary hack. Need to refactor getValueInterval() method
|
||||
dashArray: string; // dasharray attr, only for lines
|
||||
class: string; // option to add custom class to each serie element
|
||||
renderArea: boolean; // TODO: move to render type
|
||||
} |
||||
export enum Mode { |
||||
STANDARD = 'Standard', |
||||
CHARGE = 'Charge' |
||||
|
||||
export type LineTimeSerie = Serie & Partial<LineTimeSerieParams>; |
||||
export type LineOptions = Options & { |
||||
events? : { |
||||
zoomOut?: (centers: { |
||||
x: number; |
||||
y: number; |
||||
}, range: AxisRange[]) => void; |
||||
} |
||||
} |
||||
export type LineTimeSerie = TimeSerie & Partial<LineTimeSerieParams>; |
||||
export type LineOptions = Options; |
||||
|
||||
export type MouseObj = { |
||||
x: number, |
||||
y: number, |
||||
xVal: number, |
||||
yVal: number, |
||||
series: { value: [number, number], color: string, label: string }[], |
||||
chartX: number, |
||||
chartWidth: number |
||||
} |
Loading…
Reference in new issue