GithubHelp home page GithubHelp logo

Comments (6)

moshetanzer avatar moshetanzer commented on August 26, 2024 1

Hey @shehab267 great. Yeah. Will definitely take a better look. The problem seems to be a hydration type of issue. You still could keep the component. Just for now use only as a client side or fully server side. Need to check if issue is in the color module, nuxt ui, or general server component issue.

from dashboard.

shehab267 avatar shehab267 commented on August 26, 2024

Hi, @moshetanzer @benjamincanac
I removed the HomeChart component as suggested, and the issue disappeared. Can we address and fix the issue within the component?

Awaiting your guidance on next steps.

from dashboard.

shehab267 avatar shehab267 commented on August 26, 2024

Hey @shehab267 great. Yeah. Will definitely take a better look. The problem seems to be a hydration type of issue. You still could keep the component. Just for now use only as a client side or fully server side. Need to check if issue is in the color module, nuxt ui, or general server component issue.

Thanks for the info! I tried rendering the component on the client side only, but the issue still persists.

from dashboard.

moshetanzer avatar moshetanzer commented on August 26, 2024

Do you mind adding a reproduction of what exactly you did. Also did you test server side?

from dashboard.

Ctron-Dev avatar Ctron-Dev commented on August 26, 2024

hey i just tried it

homechart component when ran as server didn't render the data.

but after comenting out the library code "unovis/vue" the issue was gone

so i was trying to croner the issue and i am pretty much sure its from the library

this is the homechart componant after removing the library code

<script setup lang="ts">
import {
  eachDayOfInterval,
  eachWeekOfInterval,
  eachMonthOfInterval,
  format,
} from 'date-fns';

import type {Period, Range} from '~/types';

const cardRef = ref<HTMLElement | null>(null);

const props = defineProps({
  period: {
    type: String as PropType<Period>,
    required: true,
  },
  range: {
    type: Object as PropType<Range>,
    required: true,
  },
});

type DataRecord = {
  date: Date;
  amount: number;
};

const {width} = useElementSize(cardRef);

// We use `useAsyncData` here to have same random data on the client and server
const {data} = await useAsyncData<DataRecord[]>(
  async () => {
    const dates = {
      daily: eachDayOfInterval,
      weekly: eachWeekOfInterval,
      monthly: eachMonthOfInterval,
    }[props.period](props.range);

    const min = 1000;
    const max = 10000;

    return dates.map((date) => ({
      date,
      amount: Math.floor(Math.random() * (max - min + 1)) + min,
    }));
  },
  {
    watch: [() => props.period, () => props.range],
    default: () => [],
  },
);

const x = (_: DataRecord, i: number) => i;
const y = (d: DataRecord) => d.amount;

const total = computed(() =>
  data.value.reduce((acc: number, {amount}) => acc + amount, 0),
);

const formatNumber = new Intl.NumberFormat('en', {
  style: 'currency',
  currency: 'USD',
  maximumFractionDigits: 0,
}).format;

const formatDate = (date: Date): string => {
  return {
    daily: format(date, 'd MMM'),
    weekly: format(date, 'd MMM'),
    monthly: format(date, 'MMM yyy'),
  }[props.period];
};

const xTicks = (i: number) => {
  if (i === 0 || i === data.value.length - 1 || !data.value[i]) {
    return '';
  }

  return formatDate(data.value[i].date);
};

const template = (d: DataRecord) =>
  `${formatDate(d.date)}: ${formatNumber(d.amount)}`;
</script>

<template>
  <UDashboardCard ref="cardRef" :ui="{body: {padding: '!pb-3 !px-0'} as any}">
    <template #header>
      <div>
        <p class="mb-1 text-sm font-medium text-gray-500 dark:text-gray-400">
          Revenue
        </p>
        <p class="text-3xl font-semibold text-gray-900 dark:text-white">
          {{ formatNumber(total) }}
        </p>
      </div>
    </template>
  </UDashboardCard>
</template>

from dashboard.

shehab267 avatar shehab267 commented on August 26, 2024

Hi @moshetanzer,

I hope you are well. I am following up to inquire about any updates regarding this issue. Your assistance is much appreciated.

Thank you!

from dashboard.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.