Skip to content

Commit

Permalink
Merge pull request #356 from Razz19/master
Browse files Browse the repository at this point in the history
Charting Library with Sveltekit(svelte) example
  • Loading branch information
SlicedSilver authored Aug 31, 2023
2 parents 1aaa447 + 92158a8 commit 0c72d6e
Show file tree
Hide file tree
Showing 13 changed files with 1,267 additions and 0 deletions.
13 changes: 13 additions & 0 deletions sveltekit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
static/charting_library
src/lib/charting_library
src/lib/datafeeds
2 changes: 2 additions & 0 deletions sveltekit/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
engine-strict=true
resolution-mode=highest
40 changes: 40 additions & 0 deletions sveltekit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# TradingView Charting Library and Sveltekit(Svelte) Integration Example

**_The earliest supported version of the charting library for these examples is
`v24`._**

**_This example is for Sveltekit v.1.0 and Svelte v.4.0 and above_**

## How to start

1. Check that you can view
[https://github.com/tradingview/charting_library/](https://github.com/tradingview/charting_library/).
If you do not have access then you can
[request access to this repository here](https://www.tradingview.com/HTML5-stock-forex-bitcoin-charting-library/).
1. Install dependencies `npm install`.
1. Copy the charting library files
1. If you are able to run bash scripts then the
`copy_charting_library_files.sh` script can be used to copy the current
stable version's files.
1. If you are not able to run bash scripts then do the following:
1. Copy the `charting_library` folder from
[https://github.com/tradingview/charting_library/](https://github.com/tradingview/charting_library/)
to `/static` and `/src/lib` folder.
1. Copy the `datafeeds` folder from
[https://github.com/tradingview/charting_library/](https://github.com/tradingview/charting_library/)
to `/src/lib`.
1. Run `npm run dev` to run the app in development mode
with the Charting Library.
1. Run `npm run build` To create a production version of your app.
> You can preview the production build with `npm run preview`.
## What is Charting Library

Charting Library is a standalone solution for displaying charts. This free,
downloadable library is hosted on your servers and is connected to your data
feed to be used in your website or app.
[Learn more and download](https://www.tradingview.com/HTML5-stock-forex-bitcoin-charting-library/).

## Credit

Example kindly provided by [Razz19](https://github.com/Razz19)
25 changes: 25 additions & 0 deletions sveltekit/copy_charting_library_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

remove_if_directory_exists() {
if [ -d "$1" ]; then rm -Rf "$1"; fi
}

BRANCH="master";

REPOSITORY='https://github.com/tradingview/charting_library/'

LATEST_HASH=$(git ls-remote $REPOSITORY $BRANCH | grep -Eo '^[[:alnum:]]+')

remove_if_directory_exists "$LATEST_HASH"

git clone -q --depth 1 -b "$BRANCH" $REPOSITORY "$LATEST_HASH"

remove_if_directory_exists "static/charting_library"
remove_if_directory_exists "src/lib/datafeeds"
remove_if_directory_exists "src/lib/charting_library"

cp -r "$LATEST_HASH/charting_library" static
cp -r "$LATEST_HASH/datafeeds" src/lib
cp -r "$LATEST_HASH/charting_library" src/lib

remove_if_directory_exists "$LATEST_HASH"
Loading

0 comments on commit 0c72d6e

Please sign in to comment.