wisdwins
Posts: 20
Joined: Sun Sep 04, 2022 3:20 am

Re: Dynamic graph link firebase data display (ios swift)

After adding the title, all are executed. Can I make the X-axis update every second according to the time, and the Y-axis random number 0~1?

Thank you for your patient teaching
wisdwins
Posts: 20
Joined: Sun Sep 04, 2022 3:20 am

Re: Dynamic graph link firebase data display (ios swift)

Can you assist me?
thank you very much :( :(
wisdwins
Posts: 20
Joined: Sun Sep 04, 2022 3:20 am

Re: Dynamic graph link firebase data display (ios swift)

Is there a way to make X axis: current time, Y axis: random number 0.00~1.00?

Thank you very much for your help and patience
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Dynamic graph link firebase data display (ios swift)

Hello,

If the test function with the title update I sent works, the problem may be with pasting the function from the original demo. You can also try testing the code below, making sure it is on one line.

Code: Select all

chart.events.load = HIFunction(jsFunction: "function(){setInterval(function(){this.series[0].addPoint([(new Date()).getTime(),Math.random()],true,true)},1000)}")

Regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
wisdwins
Posts: 20
Joined: Sun Sep 04, 2022 3:20 am

Re: Dynamic graph link firebase data display (ios swift)

The code can run normally, but the chart doesn't move. How can I write the function to run like in the movie?
https://www.highcharts.com/demo/ios/dyn ... dark-unica
How to write the code for the X-axis and Y-axis to complete, the current time of the X-axis (such as a movie), the random number of the Y-axis 0.00~0.1
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Dynamic graph link firebase data display (ios swift)

Hi,
The code can run normally, but the chart doesn't move. How can I write the function to run like in the movie?
Is there a problem with the code ... The snippet I sent is responsible for that.

In the attachment you have a working demo with the possibility of viewing the code. Maybe this will illustrate what you are doing wrong in your code.
Spline Live Demo iOS.zip
(5.98 KiB) Downloaded 11 times
Regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
wisdwins
Posts: 20
Joined: Sun Sep 04, 2022 3:20 am

Re: Dynamic graph link firebase data display (ios swift)

Hello! Thank you very much for your patient guidance!

The file you sent to me cannot be opened normally, I am using swift, can I trouble you to upload the file once?

Many thanks
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Dynamic graph link firebase data display (ios swift)

Hi,

I provide you with a link to Google Drive, maybe it will work like that.
https://drive.google.com/file/d/1AUGv6e ... sp=sharing

Regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
wisdwins
Posts: 20
Joined: Sun Sep 04, 2022 3:20 am

Re: Dynamic graph link firebase data display (ios swift)

It can work normally!!
Thank you so much!
Your company service is really good!
Thank you again
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Dynamic graph link firebase data display (ios swift)

That's great to hear!

Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
wisdwins
Posts: 20
Joined: Sun Sep 04, 2022 3:20 am

Re: Dynamic graph link firebase data display (ios swift)

How can I change the value displayed on the Y-axis?
Currently 0~1
Can it be changed to -1~1?
how to modify
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Dynamic graph link firebase data display (ios swift)

Hello,

You just need to modify y value in 2 places (chart.events.load() function and series.data) from:

Code: Select all

y = Math.random();
to:

Code: Select all

y = Math.random() * 2 - 1;

Regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
wisdwins
Posts: 20
Joined: Sun Sep 04, 2022 3:20 am

Re: Dynamic graph link firebase data display (ios swift)

Is there a way to add a switch and start running after it is turned on?
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Dynamic graph link firebase data display (ios swift)

Hi,

You can write your own timer with adding points.

Remove this function:

Code: Select all

chart.events = HIEvents()
chart.events.load = HIFunction(jsFunction: "function () { var series = this.series[0]; setInterval(function () { var x = (new Date()).getTime(), y = Math.random(); series.addPoint([x, y], true, true); }, 1000); }")
And add this code at the end:

Code: Select all

options.series = [spline]

if isButtonEnabled {
  Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { timer in
    let point = HIData()
    let x = Date().timeIntervalSince1970 * 1000
    let y = Float.random(in: 0..<1)
    
    point.x = x as NSNumber
    point.y = y as NSNumber

    spline.addPoint(point)
  }
}

Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
wisdwins
Posts: 20
Joined: Sun Sep 04, 2022 3:20 am

Re: Dynamic graph link firebase data display (ios swift)

Do I want to add a Button?
Or the Switch?
Could you please post an example for me to learn from?
Thank you very much

Return to “Highcharts Usage”