0

I tried to replicate the example shown at Syncfusion but the Sparkline chart isn't rendered at all, neither shows any error. I'm doing it with NextJS.

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

function MySparkline () {
  const [domLoaded, setDomLoaded] = useState(false)

  useEffect(() => {
    setDomLoaded(true)
  }, [])

  return (
    <>
      {domLoaded &&
    <SparklineComponent
      id='sparkline'
      height='100px'
      width='70%'
     dataSource={[
       { x: 0, xval: '2005', yval: 20090440 },
       { x: 1, xval: '2006', yval: 20264080 },
       { x: 2, xval: '2007', yval: 20434180 },
       { x: 3, xval: '2008', yval: 21007310 },
       { x: 4, xval: '2009', yval: 21262640 },
       { x: 5, xval: '2010', yval: 21515750 },
       { x: 6, xval: '2011', yval: 21766710 },
       { x: 7, xval: '2012', yval: 22015580 },
       { x: 8, xval: '2013', yval: 22262500 },
       { x: 9, xval: '2014', yval: 22507620 }
     ]}
      xName='xval'
      yName='yval'
      type='Area'
      >
      <Inject services={[SparklineTooltip]}/>
    </SparklineComponent>
    }
    </>
  )
}

export default MySparkline

In my page I call it like this

<MySparkline />

Any help would be very appreciated. Thanks

1 Answer 1

0

I have prepared the sample in NextJS with sparkline chart. Control is rendered fine without any exception. Please check with the below sample and screenshot.

Screenshot : Sparkline

Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/Sparkline-1298560420.zip

Sign up to request clarification or add additional context in comments.

1 Comment

While providing a link to the code is fine, your answer should be self-contained and not rely on external resources. Please add the relevant code as text directly to the answer, and format it appropriately.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.