[LinearGauge] Unable to setAnnotationValue in Docker

Hi Syncfusion Team

I created a react project with linear gauge and run as a docker image. Everytime i use setAnnotationValue method, there will be an error:

TypeError: Cannot set properties of undefined (setting 'content')

at t.setAnnotationValue (linear-gauge.js: 850)

This only happens only when is on docker.


Please assist


Regards

Amanda


5 Replies

IR Indumathi Ravi Syncfusion Team November 24, 2021 09:19 PM UTC

Hi Amanda,Thank you for contacting Syncfusion Support. 
We are unable to reproduce the reported issue with the Linear Gauge control in the React application which is run as a docker image. Please find the sample application in which we tried to reproduce the reported issue and the screen capture video of the same below. 
  
  
Screen Capture Video: 
  
Please provide the code snippet or modify the above sample to reproduce the issue. It will be helpful for us to analyze and assist you further. 
Regards,Indumathi R 



AM Amanda November 25, 2021 07:11 AM UTC

Hi Indumathi

I try to create a sample. When click on the + sign, the same error occurred. Please refer to link below:

Sample: https://codesandbox.io/s/suspicious-http-9d77p?file=/src/App.tsx


Thanks

Regards

Amanda



IR Indumathi Ravi Syncfusion Team November 26, 2021 08:51 PM UTC

Hi Amanda,Thank you for your update. 
  
When we analyzed the provided sample link, we came to know that the Linear Gauge control is not used in the sample. So we added the Linear Gauge control in the provided sample and the issue is not reproduced. Please find the modified sample link and the screen capture video of the same below. 
  
  
Please provide us the code snippet or the sample application to reproduce the reported issue. It will be helpful for us to analyze and assist you further. 
Regards, 
Indumathi R 



AM Amanda November 27, 2021 03:47 AM UTC

Hi Indumathi


I didnt realize that the link i sent you is empty. I just paste the code below instead:


import "./styles.css";
import React from 'react';
import { useRef } from 'react';
import {
LinearGaugeComponent,
Inject,
Annotations,
AxesDirective,
AxisDirective,
} from '@syncfusion/ej2-react-lineargauge';

const data = [
{ content: "1" },
{ content: "2" },
{ content: "3" },
{ content: "4" },
{ content: "5" }
];

export default function App() {
const linearRef = useRef<LinearGaugeComponent | null>(null);

const toggleSet = () => {
data.forEach((item: any, index: number) => {
if(linearRef.current !== null) {
linearRef.current.setAnnotationValue(index, item.content);
}
})
};

return (
<div>
<button onClick={toggleSet}>
<span>+</span>
</button>
<LinearGaugeComponent
orientation='Horizontal'
ref={(scope) => linearRef.current = scope}
>
<Inject services={[Annotations]} />
<AxesDirective>
<AxisDirective
minorTicks={{ interval: 10, width: 1, height: 15 }}
majorTicks={{ interval: 1, width: 1, height: 35 }}
minimum={0}
maximum={10}
line={{ width: 1 }}
>
</AxisDirective>
</AxesDirective>
</LinearGaugeComponent>
</div>
)
}


When click on +, the error message will show up


Regards

Amanda



IR Indumathi Ravi Syncfusion Team November 29, 2021 08:25 PM UTC

Hi Amanda, 
  
Thank you for the update. 
  
When we analyzed the provided code and we came to know that the “AnnotationDirective” is not used in the code. We need to declare "AnnotationDirective" tags to change the corresponding annotation content using "setAnnotationValue" method. Please find the code snippet. 
  
Code Snippet
const toggleSet = () => { 
    data.forEach((item: any, index: number) => { 
      if (linearRef.current !== null) { 
        linearRef.current.setAnnotationValue(index, item.content, index); 
      } 
    }); 
  };
<LinearGaugeComponent> 
        <Inject services={[Annotations]} /> 
        <AnnotationsDirective> 
          {data.map((item) => ( 
            <AnnotationDirective 
              content="" 
              zIndex="1" 
            ></AnnotationDirective> 
          ))} 
        </AnnotationsDirective> 
</LinearGaugeComponent> 
  
We have modified the sample to demonstrate the same and it can be found from the below link. 
  
Please let us know if the above sample meets your requirement and let us know if you need any further assistance. 
  
Regards, 
Indumathi R. 


Loader.
Up arrow icon