Home Forums Chart Support c to angular support

c to angular support

Viewing 2 posts - 1 through 2 (of 2 total)
  • #44511

    in c program iam gonna generate an sine wave
    that need to be passed through websocket to angular and displayed in webpage
    this must be an real time continious process
    is there any loc ??

    #44518

    @harishv,

    You can create a websocket service in Angular app which establishes connection with your C-program and receives data. The received data should be parsed to the format accepted by CanvasJS to update the chart. Please check the code-snippet below that shows how to parse the data received from the websocket.

    
    .
    ngOnInit(): void {
      this.websocketService.connect();
      this.websocketService.messageReceived.subscribe((message: string) => {
        // message passed from the socket is in format { "value": 10 }. Parse to dataPoint format as per value returned from the socket service.
        let data = JSON.parse(message);
        this.dataPoints.push({
          y: data.value
        });
        this.chart.render();
      })
    }
    .
    

    You can download the working sample from here. Also, refer to this article for more information on creating websocket service in Angular.

    Real time CanvasJS Chart using data from Websocket in Angular

    —-
    Manoj Mohan
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.