bugfixing

This commit is contained in:
MuslemRahimi 2024-12-03 18:59:17 +01:00
parent 6162028a68
commit f94e0c6055
3 changed files with 42 additions and 23 deletions

View File

@ -123,13 +123,20 @@
.map((rating) => ({ .map((rating) => ({
// Marker at the rating's date // Marker at the rating's date
type: "max", // Marking the rating date type: "max", // Marking the rating date
name: rating.rating_current, name: rating?.rating_current,
coord: [ coord: [
rating.date, rating.date,
closeValues[dates.indexOf(rating.date)], // Find the close value corresponding to the rating date closeValues[dates.indexOf(rating.date)], // Find the close value corresponding to the rating date
], ],
label: { label: {
formatter: rating.rating_current, // Display the rating_current text formatter: rating.rating_current
?.replace("Sector Perform", "Hold")
?.replace("Equal-Weight", "Hold")
?.replace("Market Perform", "Hold")
?.replace("Overweight", "Buy")
?.replace("Outperform", "Buy")
?.replace("Underperform", "Sell")
?.replace("Underweight", "Sell"), // Display the rating_current text
position: "top", // Position the label above the point position: "top", // Position the label above the point
color: "white", // Set label color (can be customized) color: "white", // Set label color (can be customized)
fontSize: 14, // Set font size (increase for better visibility) fontSize: 14, // Set font size (increase for better visibility)
@ -257,26 +264,38 @@
<div class="w-full overflow-hidden m-auto mt-5"> <div class="w-full overflow-hidden m-auto mt-5">
{#if isLoaded && optionsData !== null} {#if isLoaded && optionsData !== null}
<div class="app w-full relative"> {#if historicalData?.length > 0}
<div class="flex justify-start space-x-4 absolute left-20 top-0 z-10"> <div class="app w-full relative">
{#each ["1Y", "3Y", "5Y", "Max"] as item} <div class="flex justify-start space-x-2 absolute left-16 top-0 z-10">
<label {#each ["1Y", "3Y", "5Y", "Max"] as item}
on:click={() => (timePeriod = item)} <label
class="px-4 py-2 {timePeriod === item on:click={() => (timePeriod = item)}
? 'bg-[#27272A]' class="px-4 py-2 {timePeriod === item
: ''} sm:hover:bg-[#27272A] border border-gray-600 text-white rounded-md cursor-pointer" ? 'bg-[#27272A]'
> : ''} sm:hover:bg-[#27272A] border border-gray-600 text-white rounded-md cursor-pointer"
{item} >
</label> {item}
{/each} </label>
{/each}
</div>
<h2
class="text-white text-xl font-semibold text-center absolute left-1/2 transform -translate-x-1/2 top-5 -translate-y-1/2"
>
{symbol} - {numOfRatings} Ratings
</h2>
<Chart {init} options={optionsData} class="chart" />
</div> </div>
<h2 {:else}
class="text-white text-xl font-semibold text-center absolute left-1/2 transform -translate-x-1/2 top-5 -translate-y-1/2" <div class="h-[250px] sm:h-[350px]">
> <div
{symbol} - {numOfRatings} Ratings class="flex h-full w-full flex-col items-center justify-center rounded-sm border border-gray-800 p-6 text-center md:p-12"
</h2> >
<Chart {init} options={optionsData} class="chart" /> <div class="mb-4 text-white text-[1rem] sm:text-xl font-semibold">
</div> No chart data available for {symbol}
</div>
</div>
</div>
{/if}
{:else} {:else}
<div class="flex justify-center items-center h-80"> <div class="flex justify-center items-center h-80">
<div class="relative"> <div class="relative">

View File

@ -148,7 +148,7 @@
socket.addEventListener("open", () => { socket.addEventListener("open", () => {
console.log("WebSocket connection opened"); console.log("WebSocket connection opened");
// Send only current watchlist symbols // Send only current watchlist symbols
const tickerList = [$etfTicker] || []; const tickerList = [$etfTicker?.toUpperCase()] || [];
sendMessage(tickerList); sendMessage(tickerList);
}); });

View File

@ -157,7 +157,7 @@
socket.addEventListener("open", () => { socket.addEventListener("open", () => {
console.log("WebSocket connection opened"); console.log("WebSocket connection opened");
// Send only current watchlist symbols // Send only current watchlist symbols
const tickerList = [$stockTicker] || []; const tickerList = [$stockTicker?.toUpperCase()] || [];
sendMessage(tickerList); sendMessage(tickerList);
}); });