Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sparkline #44

Open
ZettaDevs opened this issue Jul 5, 2024 · 1 comment
Open

Sparkline #44

ZettaDevs opened this issue Jul 5, 2024 · 1 comment

Comments

@ZettaDevs
Copy link

I've followed the tutorial as closely as possible, however, the Sparkline still won't show. I've logged the data, its clearly being passed into the Sparkline component, but the chart just won't show. Any ideas?

Screenshot (295)

My SparkLine.js file currently looks like this (Without console logs)

import React from 'react';
import {SparklineComponent , Inject, SparklineTooltip } from '@syncfusion/ej2-react-charts';

const SparkLine = ({id, height, width, color, data, type, currentColor}) => {
  return (
    <SparklineComponent 
    id={id}
    height={height}
    width={width}
    lineWidth={1}
    valueType="Numeric"
    fill={color}
    border={{ color: currentColor, width: 2 }}
    dataSource={data}
    xName="x"
    yName="y"
    type={type}
    >
      <Inject services={[SparklineTooltip]} />
    </SparklineComponent>
  )
}

export default SparkLine

and my Ecommerce.jsx currently looks like this:

`import React from 'react'
import { BsCurrencyDollar } from 'react-icons/bs';
import {GoDotFill} from 'react-icons/go';

import {Stacked, Pie, Button, SparkLine} from '../components';
import {earningData, SparklineAreaData, ecomPieChartData} from '../data/dummy';
import { useStateContext } from '../contexts/ContextProvider';

const Ecommerce = () => {
return (






Earnings


$70,899.67







    {/* Card Items Start Here */}
    <div className="flex m-3 flex-wrap justify-center">
      {earningData.map((item) =>(<div key={item.title} className="bg-white dark:text-gray-200 dark:bg-secondary-dark-bg md:w-56 p-4 pt-9 rounded-2xl">  
        <button type="button"
        style={{color: item.iconColor, backgroundColor: item.iconBg}} className='text-2xl opacity-0.9 rounded-full p-4 hover:drop-shadow-xl'>
          {item.icon}
        </button>
        <p className="mt-3">
          <span className='text-lg font-semibold'>
            {item.amount}
          </span>
          <span className={`text-sm text-${item.pcColor} ml-2`}>
            {item.percentage}
          </span>
        </p>
        <p className="text-sm text-gray-400 mt-1">{item.title}</p>
        </div>
      ))}
    </div>
  </div>
  {/* Card Items End Here */}


  {/* Revenue Updates Start Here */}
  <div className="flex gap-10 flex-wrap justify-center">
    <div className="bg-white dark:text-gray-200 dark:bg-secondary-dark-bg  m-3 p-4 rounded-2xl md:w-780">
      <div className="flex justify-between">
          <p className="font-semibold text-xl">Revenue Updates</p>
          <div className="flex items-center gap-4">
            <p className="flex items-center gap-2 text-gray-600 hover:drop-shadow-xl">
              <span><GoDotFill /></span>
              <span>Expense</span>
            </p>
            <p className="flex items-center gap-2 text-green-400 hover:drop-shadow-xl">
              <span><GoDotFill /></span>
              <span>Budget</span>
            </p>
          </div>
        </div>

        <div className="mt-10 flex gap-10 flex-wrap justify-center">
          <div className="border-r-1 border-color m-4 pr-10">
            <div>
              <p>
                <span className="text-3xl font-semibold">$95,672</span>
                <span className='p-1.5 hover:drop-shadow-xl cursor-pointer rounded-full text-white bg-green-400 ml-3 text-xs'>25%</span>
              </p>
              <p className="text-gray-500 mt-1">Budget</p>
            </div>
            <div className="mt-8">
              <p>
                <span className="text-3xl font-semibold">$45,349</span>
                
              </p>
              <p className="text-gray-500 mt-1">Expense</p>
            </div>

            {/* SparkLine Chart */}
            <div className="mt-5">
              <SparkLine 
              currentColor="blue" 
              id="line-sparkline"
              type="Line"
              height="80px"
              width="250px"
              data={ SparklineAreaData } 
              color="blue" />
            </div>

          </div>
          
        </div>

      </div>          
  </div>
</div>

)
}

export default Ecommerce`

@mateuszzbaraski
Copy link

mateuszzbaraski commented Oct 29, 2024

Hi there, I encountered the same issue. Turns out in the dummy dataset the SparklineAreaData has column labels 'x' and 'yval' instead of 'y'. In the SparkLine.jsx replace it with

  xName="x"
  yName="yval"

Or change the dummy data naming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants