Compare commits
No commits in common. 'main' and 'target-master' have entirely different histories.
main
...
target-mas
43 changed files with 5354 additions and 5516 deletions
File diff suppressed because one or more lines are too long
@ -1,3 +0,0 @@ |
|||||||
nodeLinker: node-modules |
|
||||||
|
|
||||||
yarnPath: .yarn/releases/yarn-3.2.1.cjs |
|
@ -1,13 +1,201 @@ |
|||||||
Copyright 2020-2021 CorpGlory Inc. |
Apache License |
||||||
|
Version 2.0, January 2004 |
||||||
Permission to use, copy, modify, and/or distribute this software for any purpose |
http://www.apache.org/licenses/ |
||||||
with or without fee is hereby granted, provided that the above copyright notice |
|
||||||
and this permission notice appear in all copies. |
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION |
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH |
1. Definitions. |
||||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
||||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, |
"License" shall mean the terms and conditions for use, reproduction, |
||||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS |
and distribution as defined by Sections 1 through 9 of this document. |
||||||
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
|
||||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF |
"Licensor" shall mean the copyright owner or entity authorized by |
||||||
THIS SOFTWARE. |
the copyright owner that is granting the License. |
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all |
||||||
|
other entities that control, are controlled by, or are under common |
||||||
|
control with that entity. For the purposes of this definition, |
||||||
|
"control" means (i) the power, direct or indirect, to cause the |
||||||
|
direction or management of such entity, whether by contract or |
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the |
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity. |
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity |
||||||
|
exercising permissions granted by this License. |
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications, |
||||||
|
including but not limited to software source code, documentation |
||||||
|
source, and configuration files. |
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical |
||||||
|
transformation or translation of a Source form, including but |
||||||
|
not limited to compiled object code, generated documentation, |
||||||
|
and conversions to other media types. |
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or |
||||||
|
Object form, made available under the License, as indicated by a |
||||||
|
copyright notice that is included in or attached to the work |
||||||
|
(an example is provided in the Appendix below). |
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object |
||||||
|
form, that is based on (or derived from) the Work and for which the |
||||||
|
editorial revisions, annotations, elaborations, or other modifications |
||||||
|
represent, as a whole, an original work of authorship. For the purposes |
||||||
|
of this License, Derivative Works shall not include works that remain |
||||||
|
separable from, or merely link (or bind by name) to the interfaces of, |
||||||
|
the Work and Derivative Works thereof. |
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including |
||||||
|
the original version of the Work and any modifications or additions |
||||||
|
to that Work or Derivative Works thereof, that is intentionally |
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner |
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of |
||||||
|
the copyright owner. For the purposes of this definition, "submitted" |
||||||
|
means any form of electronic, verbal, or written communication sent |
||||||
|
to the Licensor or its representatives, including but not limited to |
||||||
|
communication on electronic mailing lists, source code control systems, |
||||||
|
and issue tracking systems that are managed by, or on behalf of, the |
||||||
|
Licensor for the purpose of discussing and improving the Work, but |
||||||
|
excluding communication that is conspicuously marked or otherwise |
||||||
|
designated in writing by the copyright owner as "Not a Contribution." |
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity |
||||||
|
on behalf of whom a Contribution has been received by Licensor and |
||||||
|
subsequently incorporated within the Work. |
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of |
||||||
|
this License, each Contributor hereby grants to You a perpetual, |
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
||||||
|
copyright license to reproduce, prepare Derivative Works of, |
||||||
|
publicly display, publicly perform, sublicense, and distribute the |
||||||
|
Work and such Derivative Works in Source or Object form. |
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of |
||||||
|
this License, each Contributor hereby grants to You a perpetual, |
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
||||||
|
(except as stated in this section) patent license to make, have made, |
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work, |
||||||
|
where such license applies only to those patent claims licensable |
||||||
|
by such Contributor that are necessarily infringed by their |
||||||
|
Contribution(s) alone or by combination of their Contribution(s) |
||||||
|
with the Work to which such Contribution(s) was submitted. If You |
||||||
|
institute patent litigation against any entity (including a |
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work |
||||||
|
or a Contribution incorporated within the Work constitutes direct |
||||||
|
or contributory patent infringement, then any patent licenses |
||||||
|
granted to You under this License for that Work shall terminate |
||||||
|
as of the date such litigation is filed. |
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the |
||||||
|
Work or Derivative Works thereof in any medium, with or without |
||||||
|
modifications, and in Source or Object form, provided that You |
||||||
|
meet the following conditions: |
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or |
||||||
|
Derivative Works a copy of this License; and |
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices |
||||||
|
stating that You changed the files; and |
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works |
||||||
|
that You distribute, all copyright, patent, trademark, and |
||||||
|
attribution notices from the Source form of the Work, |
||||||
|
excluding those notices that do not pertain to any part of |
||||||
|
the Derivative Works; and |
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its |
||||||
|
distribution, then any Derivative Works that You distribute must |
||||||
|
include a readable copy of the attribution notices contained |
||||||
|
within such NOTICE file, excluding those notices that do not |
||||||
|
pertain to any part of the Derivative Works, in at least one |
||||||
|
of the following places: within a NOTICE text file distributed |
||||||
|
as part of the Derivative Works; within the Source form or |
||||||
|
documentation, if provided along with the Derivative Works; or, |
||||||
|
within a display generated by the Derivative Works, if and |
||||||
|
wherever such third-party notices normally appear. The contents |
||||||
|
of the NOTICE file are for informational purposes only and |
||||||
|
do not modify the License. You may add Your own attribution |
||||||
|
notices within Derivative Works that You distribute, alongside |
||||||
|
or as an addendum to the NOTICE text from the Work, provided |
||||||
|
that such additional attribution notices cannot be construed |
||||||
|
as modifying the License. |
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and |
||||||
|
may provide additional or different license terms and conditions |
||||||
|
for use, reproduction, or distribution of Your modifications, or |
||||||
|
for any such Derivative Works as a whole, provided Your use, |
||||||
|
reproduction, and distribution of the Work otherwise complies with |
||||||
|
the conditions stated in this License. |
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise, |
||||||
|
any Contribution intentionally submitted for inclusion in the Work |
||||||
|
by You to the Licensor shall be under the terms and conditions of |
||||||
|
this License, without any additional terms or conditions. |
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify |
||||||
|
the terms of any separate license agreement you may have executed |
||||||
|
with Licensor regarding such Contributions. |
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade |
||||||
|
names, trademarks, service marks, or product names of the Licensor, |
||||||
|
except as required for reasonable and customary use in describing the |
||||||
|
origin of the Work and reproducing the content of the NOTICE file. |
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or |
||||||
|
agreed to in writing, Licensor provides the Work (and each |
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS, |
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
||||||
|
implied, including, without limitation, any warranties or conditions |
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A |
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the |
||||||
|
appropriateness of using or redistributing the Work and assume any |
||||||
|
risks associated with Your exercise of permissions under this License. |
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory, |
||||||
|
whether in tort (including negligence), contract, or otherwise, |
||||||
|
unless required by applicable law (such as deliberate and grossly |
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be |
||||||
|
liable to You for damages, including any direct, indirect, special, |
||||||
|
incidental, or consequential damages of any character arising as a |
||||||
|
result of this License or out of the use or inability to use the |
||||||
|
Work (including but not limited to damages for loss of goodwill, |
||||||
|
work stoppage, computer failure or malfunction, or any and all |
||||||
|
other commercial damages or losses), even if such Contributor |
||||||
|
has been advised of the possibility of such damages. |
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing |
||||||
|
the Work or Derivative Works thereof, You may choose to offer, |
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity, |
||||||
|
or other liability obligations and/or rights consistent with this |
||||||
|
License. However, in accepting such obligations, You may act only |
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf |
||||||
|
of any other Contributor, and only if You agree to indemnify, |
||||||
|
defend, and hold each Contributor harmless for any liability |
||||||
|
incurred by, or claims asserted against, such Contributor by reason |
||||||
|
of your accepting any such warranty or additional liability. |
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS |
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work. |
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following |
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]" |
||||||
|
replaced with your own identifying information. (Don't include |
||||||
|
the brackets!) The text should be enclosed in the appropriate |
||||||
|
comment syntax for the file format. We also recommend that a |
||||||
|
file or class name and description of purpose be included on the |
||||||
|
same "printed page" as the copyright notice for easier |
||||||
|
identification within third-party archives. |
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner] |
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
you may not use this file except in compliance with the License. |
||||||
|
You may obtain a copy of the License at |
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software |
||||||
|
distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
See the License for the specific language governing permissions and |
||||||
|
limitations under the License. |
||||||
|
@ -1,43 +1,2 @@ |
|||||||
# Chartwerk Line Pod |
# 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 |
|
||||||
``` |
|
@ -0,0 +1,99 @@ |
|||||||
|
import { ChartwerkPod, TickOrientation, TimeFormat } from '@chartwerk/core'; |
||||||
|
import { LineTimeSerie, LineOptions, Mode } from './types'; |
||||||
|
export declare class ChartwerkLineChart extends ChartwerkPod<LineTimeSerie, LineOptions> { |
||||||
|
lineGenerator: any; |
||||||
|
metricContainer: any; |
||||||
|
constructor(_el: HTMLElement, _series?: LineTimeSerie[], _options?: LineOptions); |
||||||
|
renderMetrics(): void; |
||||||
|
initLineGenerator(): void; |
||||||
|
appendData(data: [number, number][]): 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; |
||||||
|
} |
||||||
|
export declare const VueChartwerkLineChartObject: { |
||||||
|
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
@ -0,0 +1,16 @@ |
|||||||
|
import { TimeSerie, Options } from '@chartwerk/core'; |
||||||
|
declare type LineTimeSerieParams = { |
||||||
|
confidence: number; |
||||||
|
mode: Mode; |
||||||
|
maxLength: number; |
||||||
|
renderDots: boolean; |
||||||
|
renderLines: boolean; |
||||||
|
useOutOfRange: boolean; |
||||||
|
}; |
||||||
|
export declare enum Mode { |
||||||
|
STANDARD = "Standard", |
||||||
|
CHARGE = "Charge" |
||||||
|
} |
||||||
|
export declare type LineTimeSerie = TimeSerie & Partial<LineTimeSerieParams>; |
||||||
|
export declare type LineOptions = Options; |
||||||
|
export {}; |
@ -1,42 +0,0 @@ |
|||||||
<!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"> |
|
||||||
let options = { |
|
||||||
renderLegend: false, usePanning: false, |
|
||||||
axis: { |
|
||||||
x: { format: 'numeric', range: [0, 100] }, |
|
||||||
y: { invert: true, range: [0, 100] }, |
|
||||||
y1: { isActive: true, format: 'numeric', range: [0, 1000] }, |
|
||||||
}, |
|
||||||
zoomEvents: { |
|
||||||
mouse: { zoom: { isActive: false, orientation: 'horizontal' } }, |
|
||||||
scroll: { zoom: { isActive: false, orientation: 'horizontal' } } |
|
||||||
}, |
|
||||||
} |
|
||||||
const data1 = [[0,0], [35, 40], [65, 60], [100, 100]]; |
|
||||||
const data2 = [[0,0], [35, 50], [65, 65], [80, 100]]; |
|
||||||
const data3 = [[0,0], [35, 20], [65, 50], [100, 80]]; |
|
||||||
const data4 = [[0,900], [35, 800], [65, 700], [100, 600]]; |
|
||||||
var pod = new LinePod( |
|
||||||
document.getElementById('chart'), |
|
||||||
[ |
|
||||||
{ target: 'test1', datapoints: data1, color: 'green', renderArea: 'Above' }, |
|
||||||
{ target: 'test2', datapoints: data2, color: 'blue', renderArea: 'Below' }, |
|
||||||
{ target: 'test3', datapoints: data3, color: 'orange', renderArea: 'Below', yOrientation: 'right' }, |
|
||||||
{ target: 'test4', datapoints: data4, color: 'purple', renderArea: 'Above', yOrientation: 'right' }, |
|
||||||
], |
|
||||||
options |
|
||||||
); |
|
||||||
pod.render(); |
|
||||||
</script> |
|
||||||
</body> |
|
||||||
</html> |
|
@ -1,45 +0,0 @@ |
|||||||
<!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 arrayLength = 20; |
|
||||||
const data1 = Array.from({ length: arrayLength }, (el, idx) => [startTime + idx * 10000, Math.floor(Math.random() * 40)]); |
|
||||||
const data2 = Array.from({ length: arrayLength }, (el, idx) => [startTime + idx * 10000, Math.floor(Math.random() * 10)]); |
|
||||||
const data3 = Array.from({ length: arrayLength }, (el, idx) => [startTime + idx * 10000, Math.floor(Math.random() * 20) + 90]); |
|
||||||
const zoomIn = (ranges) => { const xRange = ranges[0]; options.axis.x.range = xRange; pod.updateData(undefined, options); } |
|
||||||
const panningEnd = (ranges) => { const xRange = ranges[0]; options.axis.x.range = xRange; pod.updateData(undefined, options); } |
|
||||||
let options = { |
|
||||||
renderLegend: false, usePanning: false, |
|
||||||
axis: { |
|
||||||
y: { invert: false, range: [0, 350] }, |
|
||||||
y1: { isActive: true, range: [0, 10], ticksCount: 8 }, |
|
||||||
x: { format: 'time' } |
|
||||||
}, |
|
||||||
zoomEvents: { |
|
||||||
mouse: { zoom: { isActive: true, orientation: 'horizontal' } }, |
|
||||||
scroll: { zoom: { isActive: true, orientation: 'horizontal' } } |
|
||||||
}, |
|
||||||
eventsCallbacks: { zoomIn: zoomIn, panningEnd } |
|
||||||
} |
|
||||||
var pod = new LinePod( |
|
||||||
document.getElementById('chart'), |
|
||||||
[ |
|
||||||
{ target: 'test1', datapoints: data1, color: 'green', dashArray: '5,3', class: 'first', renderArea: true }, |
|
||||||
{ target: 'test2', datapoints: data2, color: 'blue', yOrientation: 'right' }, |
|
||||||
{ target: 'test3', datapoints: data3, color: 'orange' }, |
|
||||||
], |
|
||||||
options |
|
||||||
); |
|
||||||
pod.render(); |
|
||||||
</script> |
|
||||||
</body> |
|
||||||
</html> |
|
@ -0,0 +1,36 @@ |
|||||||
|
<!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.js" type="text/javascript"></script> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<div id="chart" style="width: 500px; height: 500px;"></div> |
||||||
|
|
||||||
|
<script type="text/javascript"> |
||||||
|
const startTime = 1590590148; |
||||||
|
const arrayLength = 20; |
||||||
|
const data1 = Array.from({ length: arrayLength }, (el, idx) => [Math.floor(Math.random() * 40), startTime + idx * 10000]); |
||||||
|
const data2 = Array.from({ length: arrayLength }, (el, idx) => [Math.floor(Math.random() * 100), startTime + idx * 10000]); |
||||||
|
const data3 = Array.from({ length: arrayLength }, (el, idx) => [Math.floor(Math.random() * 20) + 90, startTime + idx * 10000]); |
||||||
|
const zoomIn = (ranges) => { const range = ranges[0]; options.axis.x.range = range; pod.updateData(undefined, options) } |
||||||
|
const zoomOut = (ranges) => { console.log('zoomout'); options.axis.x.range = undefined; pod.updateData(undefined, options) } |
||||||
|
let options = { |
||||||
|
renderLegend: false, usePanning: false, axis: { y: { invert: false, range: [0, 350] }, x: { format: 'time' } }, |
||||||
|
eventsCallbacks: { zoomIn: zoomIn, zoomOut } |
||||||
|
} |
||||||
|
var pod = new ChartwerkLineChart( |
||||||
|
document.getElementById('chart'), |
||||||
|
[ |
||||||
|
{ target: 'test1', datapoints: data1, color: 'green' }, |
||||||
|
{ target: 'test2', datapoints: data2, color: 'blue' }, |
||||||
|
{ target: 'test3', datapoints: data3, color: 'orange' }, |
||||||
|
], |
||||||
|
options |
||||||
|
); |
||||||
|
pod.render(); |
||||||
|
</script> |
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,48 @@ |
|||||||
|
<!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.js" type="text/javascript"></script> |
||||||
|
</head> |
||||||
|
|
||||||
|
<body> |
||||||
|
<div id="chart" style="width: 500px; height: 500px;"></div> |
||||||
|
|
||||||
|
<script type="text/javascript"> |
||||||
|
const startTime = 1590590148; |
||||||
|
const arrayLength = 100; |
||||||
|
const data1 = Array.from({ length: arrayLength }, (el, idx) => [Math.floor(Math.random() * 40), startTime + idx * 10000]); |
||||||
|
const data2 = Array.from({ length: arrayLength }, (el, idx) => [Math.floor(Math.random() * 100), startTime + idx * 10000]); |
||||||
|
const data3 = Array.from({ length: arrayLength }, (el, idx) => [Math.floor(Math.random() * 20) + 90, startTime + idx * 10000]); |
||||||
|
let options = { renderLegend: false, usePanning: false, axis: { y: { invert: false, range: [0, 350] }, x: { format: 'time' } } }; |
||||||
|
var pod = new ChartwerkLineChart( |
||||||
|
document.getElementById('chart'), |
||||||
|
[ |
||||||
|
{ target: 'test1', datapoints: data1, color: 'green', maxLength: arrayLength + 30, renderDots: true }, |
||||||
|
{ target: 'test2', datapoints: data2, color: 'blue', maxLength: arrayLength + 30, renderDots: true }, |
||||||
|
{ target: 'test3', datapoints: data3, color: 'orange', maxLength: arrayLength + 30, renderDots: true }, |
||||||
|
], |
||||||
|
options |
||||||
|
); |
||||||
|
pod.render(); |
||||||
|
let rerenderIdx = arrayLength; |
||||||
|
var test = setInterval(() => { |
||||||
|
rerenderIdx += 1; |
||||||
|
const d1 = [Math.floor(Math.random() * 40), startTime + rerenderIdx * 10000]; |
||||||
|
const d2 = [Math.floor(Math.random() * 100), startTime + rerenderIdx * 10000]; |
||||||
|
const d3 = [Math.floor(Math.random() * 20) + 90, startTime + rerenderIdx * 10000]; |
||||||
|
|
||||||
|
console.time('rerender'); |
||||||
|
pod.appendData([d1, d2, d3]); |
||||||
|
console.timeEnd('rerender'); |
||||||
|
if(rerenderIdx > arrayLength + 100) { |
||||||
|
clearInterval(test); |
||||||
|
} |
||||||
|
}, 1000); |
||||||
|
</script> |
||||||
|
</body> |
||||||
|
|
||||||
|
</html> |
@ -1,59 +0,0 @@ |
|||||||
<!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: 500px; height: 500px;"></div> |
|
||||||
|
|
||||||
<script type="text/javascript"> |
|
||||||
const startTime = 1590590148; |
|
||||||
const arrayLength = 100; |
|
||||||
this.isZoomed = false; // TODO: temporary hack to have zoomin|zoomout with `appendData`. It will be moved to Pod. |
|
||||||
var data1 = Array.from({ length: arrayLength }, (el, idx) => [startTime + idx * 10000, Math.floor(Math.random() * 40)]); |
|
||||||
var data2 = Array.from({ length: arrayLength }, (el, idx) => [startTime + idx * 10000, Math.floor(Math.random() * 100)]); |
|
||||||
var data3 = Array.from({ length: arrayLength }, (el, idx) => [startTime + idx * 10000, Math.floor(Math.random() * 20) + 90]); |
|
||||||
const zoomIn = (ranges) => { const xRange = ranges[0]; options.axis.x.range = xRange; pod.updateData(undefined, options); this.isZoomed = true } |
|
||||||
const zoomOut = (ranges) => { options.axis.x.range = undefined; pod.updateData(undefined, options); this.isZoomed = false } |
|
||||||
let options = { renderLegend: false, axis: { y: { invert: false, range: [0, 350] }, x: { format: 'time' } }, eventsCallbacks: { zoomIn: zoomIn, zoomOut } }; |
|
||||||
var pod = new LinePod( |
|
||||||
document.getElementById('chart'), |
|
||||||
[ |
|
||||||
{ target: 'test1', datapoints: data1, color: 'green', maxLength: arrayLength + 30, renderDots: true }, |
|
||||||
{ target: 'test2', datapoints: data2, color: 'blue', maxLength: arrayLength + 30, renderDots: true }, |
|
||||||
{ target: 'test3', datapoints: data3, color: 'orange', maxLength: arrayLength + 30, renderDots: true }, |
|
||||||
], |
|
||||||
options |
|
||||||
); |
|
||||||
pod.render(); |
|
||||||
let rerenderIdx = arrayLength; |
|
||||||
var test = setInterval(() => { |
|
||||||
rerenderIdx += 1; |
|
||||||
const d1 = [startTime + rerenderIdx * 10000, Math.floor(Math.random() * 20) + 90]; |
|
||||||
const d2 = [startTime + rerenderIdx * 10000, Math.floor(Math.random() * 100)]; |
|
||||||
const d3 = [startTime + rerenderIdx * 10000, Math.floor(Math.random() * 20) + 90]; |
|
||||||
console.log('d1', data1) |
|
||||||
const shouldRerender = !this.isZoomed; |
|
||||||
console.time('rerender'); |
|
||||||
data1.push(d1); |
|
||||||
data2.push(d2); |
|
||||||
data3.push(d3); |
|
||||||
pod.updateData([ |
|
||||||
{ target: 'test1', datapoints: data1, color: 'green', maxLength: arrayLength + 30, renderDots: false }, |
|
||||||
{ target: 'test2', datapoints: data2, color: 'blue', maxLength: arrayLength + 30, renderDots: false }, |
|
||||||
{ target: 'test3', datapoints: data3, color: 'orange', maxLength: arrayLength + 30, renderDots: false }, |
|
||||||
]); |
|
||||||
console.timeEnd('rerender'); |
|
||||||
if(rerenderIdx > arrayLength + 100) { |
|
||||||
clearInterval(test); |
|
||||||
} |
|
||||||
}, 1000); |
|
||||||
</script> |
|
||||||
</body> |
|
||||||
|
|
||||||
</html> |
|
@ -1,51 +0,0 @@ |
|||||||
<!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 markersData1 = [3, 6, 9].map(el => ({ |
|
||||||
x: startTime + el * 1000, |
|
||||||
color: 'red', |
|
||||||
alwaysDisplay: false, |
|
||||||
html: new Date(startTime).toISOString(), |
|
||||||
})); |
|
||||||
const markersData2 = [4, 11].map(el => ({ |
|
||||||
x: startTime + el * 1000, |
|
||||||
color: 'blue', |
|
||||||
alwaysDisplay: true, |
|
||||||
html: new Date(startTime).toISOString(), |
|
||||||
})); |
|
||||||
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 }, |
|
||||||
{ data: markersData2 }, |
|
||||||
] |
|
||||||
} |
|
||||||
); |
|
||||||
pod.render(); |
|
||||||
</script> |
|
||||||
</body> |
|
||||||
</html> |
|
@ -1,47 +0,0 @@ |
|||||||
<!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 markersData = [3, 6, 9].map(el => ({ |
|
||||||
x: startTime + el * 1000, |
|
||||||
payload: el, |
|
||||||
color: 'red', |
|
||||||
})); |
|
||||||
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 }, |
|
||||||
], |
|
||||||
events: { |
|
||||||
onMouseMove: (el) => { console.log(el); }, |
|
||||||
onMouseOut: () => { console.log('mouse out'); } |
|
||||||
} |
|
||||||
} |
|
||||||
); |
|
||||||
pod.render(); |
|
||||||
</script> |
|
||||||
</body> |
|
||||||
</html> |
|
@ -1,33 +0,0 @@ |
|||||||
<!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> |
|
@ -1,29 +0,0 @@ |
|||||||
<!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> |
|
@ -1,33 +0,0 @@ |
|||||||
<!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: { contextMenu: (position) => console.log('contextMenu', position) } |
|
||||||
} |
|
||||||
var pod = new LinePod( |
|
||||||
document.getElementById('chart'), |
|
||||||
[{ datapoints: data }], |
|
||||||
options |
|
||||||
); |
|
||||||
pod.render(); |
|
||||||
</script> |
|
||||||
</body> |
|
||||||
</html> |
|
@ -1,41 +0,0 @@ |
|||||||
<!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) * 1100]); |
|
||||||
let options = { |
|
||||||
renderLegend: false, |
|
||||||
axis: { |
|
||||||
y: { range: [0, 10] }, |
|
||||||
x: { format: 'time' } |
|
||||||
}, |
|
||||||
} |
|
||||||
var pod = new LinePod( |
|
||||||
document.getElementById('chart'), |
|
||||||
[ |
|
||||||
{ datapoints: timeSerieData, color: 'black' }, |
|
||||||
], |
|
||||||
options, |
|
||||||
undefined, |
|
||||||
[ |
|
||||||
{ |
|
||||||
data: segmentsData, |
|
||||||
color:'#FFE545' |
|
||||||
} |
|
||||||
] |
|
||||||
); |
|
||||||
pod.render(); |
|
||||||
</script> |
|
||||||
</body> |
|
||||||
</html> |
|
@ -1,46 +0,0 @@ |
|||||||
<!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) * 1100]); |
|
||||||
let options = { |
|
||||||
renderLegend: false, |
|
||||||
axis: { |
|
||||||
y: { range: [0, 10] }, |
|
||||||
x: { format: 'time' } |
|
||||||
}, |
|
||||||
} |
|
||||||
var pod = new LinePod( |
|
||||||
document.getElementById('chart'), |
|
||||||
[ |
|
||||||
{ datapoints: timeSerieData, color: 'black' }, |
|
||||||
], |
|
||||||
options, |
|
||||||
undefined, |
|
||||||
[ |
|
||||||
{ |
|
||||||
data: segmentsData, |
|
||||||
color:'#FFE545', |
|
||||||
select: true, |
|
||||||
opacity: 0.4, |
|
||||||
opacitySelect: 0.8, |
|
||||||
onSelect: console.log, |
|
||||||
onUnselect: console.log |
|
||||||
} |
|
||||||
] |
|
||||||
); |
|
||||||
pod.render(); |
|
||||||
</script> |
|
||||||
</body> |
|
||||||
</html> |
|
@ -1,37 +0,0 @@ |
|||||||
<!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,37 +1,32 @@ |
|||||||
{ |
{ |
||||||
"name": "@chartwerk/line-pod", |
"name": "@chartwerk/line-chart", |
||||||
"version": "0.7.8", |
"version": "0.2.4", |
||||||
"description": "Chartwerk line chart", |
"description": "Chartwerk line chart", |
||||||
"main": "dist/index.js", |
"main": "dist/index.js", |
||||||
"files": [ |
|
||||||
"/dist" |
|
||||||
], |
|
||||||
"scripts": { |
"scripts": { |
||||||
"build": "rm -rf dist && cd react && yarn build && cd .. && webpack --config build/webpack.prod.conf.js && webpack --config build/webpack.dev.conf.js", |
"build": "webpack --config build/webpack.prod.conf.js", |
||||||
"dev": "webpack --watch --config build/webpack.dev.conf.js", |
"dev": "webpack --config build/webpack.dev.conf.js", |
||||||
"test": "echo \"Error: no test specified\" && exit 1", |
"test": "echo \"Error: no test specified\" && exit 1" |
||||||
"update-core": "yarn up @chartwerk/core && yarn up @chartwerk/core@latest" |
|
||||||
}, |
}, |
||||||
"repository": { |
"repository": { |
||||||
"type": "git", |
"type": "git", |
||||||
"url": "http://code.corpglory.net/chartwerk/line-pod.git" |
"url": "https://github.com/chartwerk/line-chart.git" |
||||||
}, |
}, |
||||||
"author": "CorpGlory", |
"author": "CorpGlory", |
||||||
"license": "ISC", |
"license": "Apache-2.0", |
||||||
"dependencies": { |
"dependencies": { |
||||||
"@chartwerk/core": "^0.6.26" |
"@chartwerk/core": "github:chartwerk/core#6e41013932bf16b05da2bc2757bcfaacba3cdb21" |
||||||
}, |
}, |
||||||
"devDependencies": { |
"devDependencies": { |
||||||
"copy-webpack-plugin": "^11.0.0", |
"@types/d3": "5.16.4", |
||||||
"css-loader": "^6.8.1", |
"@types/lodash": "^4.14.149", |
||||||
"style-loader": "^3.3.3", |
"css-loader": "^3.4.2", |
||||||
"ts-loader": "^9.4.3", |
"d3": "5.16.0", |
||||||
"typescript": "^5.1.3", |
"lodash": "^4.17.15", |
||||||
"webpack": "^5.87.0", |
"style-loader": "^1.1.3", |
||||||
"webpack-cli": "^5.1.4" |
"ts-loader": "^6.2.1", |
||||||
}, |
"typescript": "^3.8.3", |
||||||
"packageManager": "yarn@3.2.1", |
"webpack": "^4.42.0", |
||||||
"workspaces": [ |
"webpack-cli": "^3.3.11" |
||||||
"react/*" |
} |
||||||
] |
|
||||||
} |
} |
||||||
|
@ -1,26 +0,0 @@ |
|||||||
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' |
|
||||||
] |
|
||||||
}; |
|
@ -1,8 +0,0 @@ |
|||||||
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; |
|
@ -1,6 +0,0 @@ |
|||||||
const baseWebpackConfig = require('./webpack.base.conf'); |
|
||||||
|
|
||||||
var conf = baseWebpackConfig; |
|
||||||
conf.mode = 'production'; |
|
||||||
|
|
||||||
module.exports = baseWebpackConfig; |
|
@ -1,23 +0,0 @@ |
|||||||
{ |
|
||||||
"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" |
|
||||||
} |
|
||||||
} |
|
@ -1,74 +0,0 @@ |
|||||||
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; |
|
@ -1,23 +0,0 @@ |
|||||||
{ |
|
||||||
"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" |
|
||||||
} |
|
||||||
} |
|
@ -1,139 +0,0 @@ |
|||||||
import { MarkerElem, MarkersConf, MarkerSerie } from '../models/marker'; |
|
||||||
import { LineTimeSerie, LineOptions } from '../types'; |
|
||||||
|
|
||||||
import { Margin, PodState } from '@chartwerk/core'; |
|
||||||
|
|
||||||
import d3 from 'd3'; |
|
||||||
|
|
||||||
export class Markers { |
|
||||||
private _layerContainer = null; |
|
||||||
private _chartHeight = 0; |
|
||||||
|
|
||||||
constructor( |
|
||||||
private _chartContainer: d3.Selection<HTMLElement, unknown, null, undefined>, |
|
||||||
private _markerConf: MarkersConf, |
|
||||||
private _state: PodState<LineTimeSerie, LineOptions>, |
|
||||||
private _margin: Margin, |
|
||||||
) { } |
|
||||||
|
|
||||||
clear() { |
|
||||||
if(this._layerContainer !== null) { |
|
||||||
this._layerContainer.remove(); |
|
||||||
} |
|
||||||
this._chartContainer.selectAll('.marker-content').remove(); |
|
||||||
} |
|
||||||
|
|
||||||
render(metricContainer: d3.Selection<SVGGElement, unknown, null, undefined>, chartHeight: number) { |
|
||||||
this._chartHeight = chartHeight; |
|
||||||
this._layerContainer = metricContainer |
|
||||||
.append('g') |
|
||||||
.attr('class', 'markers-layer'); |
|
||||||
for(const serie of this._markerConf.series) { |
|
||||||
this.renderSerie(serie); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private _getLinePosition(marker: MarkerElem): number { |
|
||||||
return this._state.xScale(marker.x); |
|
||||||
} |
|
||||||
|
|
||||||
private _renderCircle(marker: MarkerElem) { |
|
||||||
const linePosition = this._getLinePosition(marker); |
|
||||||
|
|
||||||
let circle = this._layerContainer.append('circle') |
|
||||||
.attr('class', 'gap-circle') |
|
||||||
.attr('stroke', marker.color) |
|
||||||
.attr('stroke-width', '2px') |
|
||||||
.attr('r', 4) |
|
||||||
.attr('cx', linePosition) |
|
||||||
.attr('cy', 5) |
|
||||||
|
|
||||||
circle |
|
||||||
.attr('pointer-events', 'all') |
|
||||||
.style('cursor', 'pointer') |
|
||||||
.on('mousemove', () => { |
|
||||||
const onMouseMove = this._markerConf.events?.onMouseMove; |
|
||||||
if(onMouseMove) { |
|
||||||
onMouseMove(marker); |
|
||||||
return |
|
||||||
} |
|
||||||
if(marker.alwaysDisplay) { |
|
||||||
return; |
|
||||||
} |
|
||||||
this._chartContainer |
|
||||||
.selectAll(`.marker-content-${marker.x}`) |
|
||||||
.style('visibility', 'visible') |
|
||||||
.style('z-index', 9999); |
|
||||||
}) |
|
||||||
.on('mouseout', () => { |
|
||||||
const onMouseOut = this._markerConf.events?.onMouseOut; |
|
||||||
if(onMouseOut) { |
|
||||||
onMouseOut() |
|
||||||
return |
|
||||||
} |
|
||||||
if(marker.alwaysDisplay) { |
|
||||||
return; |
|
||||||
} |
|
||||||
this._chartContainer |
|
||||||
.selectAll(`.marker-content-${marker.x}`) |
|
||||||
.style('visibility', 'hidden') |
|
||||||
.style('z-index', 1); |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
private _renderLine(marker: MarkerElem) { |
|
||||||
const linePosition = this._getLinePosition(marker); |
|
||||||
|
|
||||||
this._layerContainer.append('line') |
|
||||||
.attr('class', 'gap-line') |
|
||||||
.attr('stroke', marker.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'); |
|
||||||
} |
|
||||||
|
|
||||||
private _renderTooltip(marker: MarkerElem) { |
|
||||||
if(marker.html === undefined) { |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
const linePosition = this._getLinePosition(marker); |
|
||||||
|
|
||||||
const div = this._chartContainer |
|
||||||
.append('div') |
|
||||||
.attr('class', `marker-content marker-content-${marker.x}`) |
|
||||||
// @ts-ignore // TODO: remove ignore but boxParams are protected
|
|
||||||
.style('top', `${this._state.boxParams.height - this._chartHeight}px`) |
|
||||||
.style('visibility', marker.alwaysDisplay ? 'visible' : 'hidden') |
|
||||||
.style('position', 'absolute') |
|
||||||
.style('border', '1px solid black') |
|
||||||
.style('background-color', 'rgb(33, 37, 41)') |
|
||||||
.style('color', 'rgb(255, 255, 255)') |
|
||||||
.style('line-height', '1.55') |
|
||||||
.style('font-size', '0.875rem') |
|
||||||
.style('border-radius', '0.5rem') |
|
||||||
.style('padding', 'calc(0.3125rem) 0.625rem') |
|
||||||
.style('position', 'absolute') |
|
||||||
.style('white-space', 'nowrap') |
|
||||||
.style('pointer-events', 'none') |
|
||||||
.style('z-index', 1) |
|
||||||
.html(marker.html); |
|
||||||
|
|
||||||
// align tooltip: center (we need it to be rendered first)
|
|
||||||
div.style('left', `${linePosition + this._margin.left - div.node().getBoundingClientRect().width / 2}px`) |
|
||||||
} |
|
||||||
|
|
||||||
protected renderSerie(serie: MarkerSerie) { |
|
||||||
serie.data.forEach((marker: MarkerElem) => { |
|
||||||
this._renderLine(marker); |
|
||||||
this._renderCircle(marker); |
|
||||||
this._renderTooltip(marker); |
|
||||||
}); |
|
||||||
} |
|
||||||
} |
|
@ -1,73 +0,0 @@ |
|||||||
import { SegmentSerie, SegmentElement } from "../models/segment"; |
|
||||||
import { PodState } from "@chartwerk/core"; |
|
||||||
import { LineTimeSerie, LineOptions } from "../types"; |
|
||||||
|
|
||||||
import * as d3 from "d3"; |
|
||||||
|
|
||||||
const OPACITY = 0.3; |
|
||||||
const OPACITY_SELECT = 0.3; |
|
||||||
|
|
||||||
export class Segments { |
|
||||||
// TODO: more semantic name
|
|
||||||
private _d3Holder = null; |
|
||||||
private _metricCon = null; |
|
||||||
|
|
||||||
constructor( |
|
||||||
private _series: SegmentSerie[], |
|
||||||
private _state: PodState<LineTimeSerie, LineOptions> |
|
||||||
) { |
|
||||||
} |
|
||||||
|
|
||||||
render(metricContainer: d3.Selection<SVGGElement, unknown, null, undefined>, chartContainer: 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(chartContainer, s); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected renderSerie(chartContainer: d3.Selection<SVGGElement, unknown, null, undefined>, serie: SegmentSerie) { |
|
||||||
// TODO: it's hack with core, need to find a better way
|
|
||||||
const overlay = chartContainer.select('.overlay'); |
|
||||||
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);
|
|
||||||
const opacity = serie.opacity || OPACITY; |
|
||||||
const opacitySelect = serie.opacitySelect || OPACITY_SELECT; |
|
||||||
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', opacity) |
|
||||||
.style('fill', serie.color) |
|
||||||
.on('mouseover', function() { |
|
||||||
if(serie.select === true) { |
|
||||||
d3.select(this).attr('opacity', opacitySelect); |
|
||||||
if(serie.onSelect) { |
|
||||||
serie.onSelect(d); |
|
||||||
} |
|
||||||
} |
|
||||||
}) |
|
||||||
.on('mouseout', function(e) { |
|
||||||
if(serie.select === true) { |
|
||||||
d3.select(this).attr('opacity', opacity); |
|
||||||
if(serie.onUnselect) { |
|
||||||
serie.onUnselect(d); |
|
||||||
} |
|
||||||
} |
|
||||||
}) |
|
||||||
.on('mousemove', function(e) { |
|
||||||
var event = new MouseEvent('mousemove', d3.event); |
|
||||||
overlay.node().dispatchEvent(event) |
|
||||||
}) |
|
||||||
}); |
|
||||||
} |
|
||||||
} |
|
@ -1,21 +0,0 @@ |
|||||||
import { CoreSeries, yAxisOrientation } from '@chartwerk/core'; |
|
||||||
import { LineTimeSerie, AreaType } from '../types'; |
|
||||||
|
|
||||||
import * as _ from 'lodash'; |
|
||||||
|
|
||||||
|
|
||||||
const LINE_SERIE_DEFAULTS = { |
|
||||||
maxLength: undefined, |
|
||||||
renderDots: false, |
|
||||||
renderLines: true, |
|
||||||
dashArray: '0', |
|
||||||
class: '', |
|
||||||
renderArea: AreaType.NONE, |
|
||||||
yOrientation: yAxisOrientation.LEFT, |
|
||||||
}; |
|
||||||
|
|
||||||
export class LineSeries extends CoreSeries<LineTimeSerie> { |
|
||||||
constructor(series: LineTimeSerie[]) { |
|
||||||
super(series, _.clone(LINE_SERIE_DEFAULTS)); |
|
||||||
} |
|
||||||
} |
|
@ -1,19 +0,0 @@ |
|||||||
export type MarkerElem = { |
|
||||||
x: number; |
|
||||||
color: string; |
|
||||||
html?: string; |
|
||||||
alwaysDisplay?: boolean; |
|
||||||
payload?: any; |
|
||||||
} |
|
||||||
|
|
||||||
export type MarkerSerie = { |
|
||||||
data: MarkerElem[]; |
|
||||||
} |
|
||||||
|
|
||||||
export type MarkersConf = { |
|
||||||
series: MarkerSerie[], |
|
||||||
events?: { |
|
||||||
onMouseMove?: (el: MarkerElem) => void; |
|
||||||
onMouseOut?: () => void; |
|
||||||
} |
|
||||||
} |
|
@ -1,11 +0,0 @@ |
|||||||
export type SegmentElement = [number, number, any?]; |
|
||||||
|
|
||||||
export type SegmentSerie = { |
|
||||||
color: string; |
|
||||||
data: SegmentElement[] // [from, to, payload?] payload is any data for tooltip,
|
|
||||||
select?: boolean, |
|
||||||
opacity?: number, |
|
||||||
opacitySelect?: number, |
|
||||||
onSelect?: (SegmentElement) => void |
|
||||||
onUnselect?: (SegmentElement) => void |
|
||||||
} |
|
@ -1,41 +1,16 @@ |
|||||||
import { Serie, Options } from '@chartwerk/core'; |
import { TimeSerie, Options } from '@chartwerk/core'; |
||||||
import { AxisRange } from '@chartwerk/core/dist/types'; |
|
||||||
|
|
||||||
type LineTimeSerieParams = { |
type LineTimeSerieParams = { |
||||||
maxLength: number; |
confidence: number, |
||||||
renderDots: boolean; |
mode: Mode, |
||||||
renderLines: boolean; // TODO: refactor same as scatter-pod
|
maxLength: number, |
||||||
dashArray: string; // dasharray attr, only for lines
|
renderDots: boolean, |
||||||
class: string; // option to add custom class to each serie element
|
renderLines: boolean, // TODO: refactor same as scatter-pod
|
||||||
renderArea: AreaType; // default is none
|
useOutOfRange: boolean, // It's temporary hack. Need to refactor getValueInterval() method
|
||||||
} |
} |
||||||
|
export enum Mode { |
||||||
export enum AreaType { |
STANDARD = 'Standard', |
||||||
NONE = 'None', |
CHARGE = 'Charge' |
||||||
ABOVE = 'Above', |
|
||||||
BELOW = 'Below', |
|
||||||
} |
|
||||||
|
|
||||||
export type LineTimeSerie = Serie & Partial<LineTimeSerieParams>; |
|
||||||
export type LineOptions = Options & { |
|
||||||
events? : { |
|
||||||
zoomOut?: (centers: { |
|
||||||
x: number; |
|
||||||
y: number; |
|
||||||
}, range: AxisRange[]) => void; |
|
||||||
contextMenu?: (position: { |
|
||||||
x: number; |
|
||||||
y: number; |
|
||||||
}) => void; |
|
||||||
} |
|
||||||
} |
} |
||||||
|
export type LineTimeSerie = TimeSerie & Partial<LineTimeSerieParams>; |
||||||
export type MouseObj = { |
export type LineOptions = Options; |
||||||
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