Skip to content

Commit 0c72d6e

Browse files
authored
Merge pull request #356 from Razz19/master
Charting Library with Sveltekit(svelte) example
2 parents 1aaa447 + 92158a8 commit 0c72d6e

File tree

13 files changed

+1267
-0
lines changed

13 files changed

+1267
-0
lines changed

sveltekit/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.DS_Store
2+
node_modules
3+
/build
4+
/.svelte-kit
5+
/package
6+
.env
7+
.env.*
8+
!.env.example
9+
vite.config.js.timestamp-*
10+
vite.config.ts.timestamp-*
11+
static/charting_library
12+
src/lib/charting_library
13+
src/lib/datafeeds

sveltekit/.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
engine-strict=true
2+
resolution-mode=highest

sveltekit/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# TradingView Charting Library and Sveltekit(Svelte) Integration Example
2+
3+
**_The earliest supported version of the charting library for these examples is
4+
`v24`._**
5+
6+
**_This example is for Sveltekit v.1.0 and Svelte v.4.0 and above_**
7+
8+
## How to start
9+
10+
1. Check that you can view
11+
[https://github.com/tradingview/charting_library/](https://github.com/tradingview/charting_library/).
12+
If you do not have access then you can
13+
[request access to this repository here](https://www.tradingview.com/HTML5-stock-forex-bitcoin-charting-library/).
14+
1. Install dependencies `npm install`.
15+
1. Copy the charting library files
16+
1. If you are able to run bash scripts then the
17+
`copy_charting_library_files.sh` script can be used to copy the current
18+
stable version's files.
19+
1. If you are not able to run bash scripts then do the following:
20+
1. Copy the `charting_library` folder from
21+
[https://github.com/tradingview/charting_library/](https://github.com/tradingview/charting_library/)
22+
to `/static` and `/src/lib` folder.
23+
1. Copy the `datafeeds` folder from
24+
[https://github.com/tradingview/charting_library/](https://github.com/tradingview/charting_library/)
25+
to `/src/lib`.
26+
1. Run `npm run dev` to run the app in development mode
27+
with the Charting Library.
28+
1. Run `npm run build` To create a production version of your app.
29+
> You can preview the production build with `npm run preview`.
30+
31+
## What is Charting Library
32+
33+
Charting Library is a standalone solution for displaying charts. This free,
34+
downloadable library is hosted on your servers and is connected to your data
35+
feed to be used in your website or app.
36+
[Learn more and download](https://www.tradingview.com/HTML5-stock-forex-bitcoin-charting-library/).
37+
38+
## Credit
39+
40+
Example kindly provided by [Razz19](https://github.com/Razz19)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
remove_if_directory_exists() {
4+
if [ -d "$1" ]; then rm -Rf "$1"; fi
5+
}
6+
7+
BRANCH="master";
8+
9+
REPOSITORY='https://github.com/tradingview/charting_library/'
10+
11+
LATEST_HASH=$(git ls-remote $REPOSITORY $BRANCH | grep -Eo '^[[:alnum:]]+')
12+
13+
remove_if_directory_exists "$LATEST_HASH"
14+
15+
git clone -q --depth 1 -b "$BRANCH" $REPOSITORY "$LATEST_HASH"
16+
17+
remove_if_directory_exists "static/charting_library"
18+
remove_if_directory_exists "src/lib/datafeeds"
19+
remove_if_directory_exists "src/lib/charting_library"
20+
21+
cp -r "$LATEST_HASH/charting_library" static
22+
cp -r "$LATEST_HASH/datafeeds" src/lib
23+
cp -r "$LATEST_HASH/charting_library" src/lib
24+
25+
remove_if_directory_exists "$LATEST_HASH"

0 commit comments

Comments
 (0)