K
K
Kingg2021-10-14 09:45:05
WPF
Kingg, 2021-10-14 09:45:05

How to draw a graph with OxyPlot in WPF with received data?

Good day to all, I'm struggling with this issue. There is data obtained from JSON by type:

{
                "id": 17744942,
                "event_type_id": 22,
                "workshop_id": 1,
                "machine_id": 1,
                "time1": 1632993370500,
                "time2": null,
                "data": null,
                "float": 330.98,
                "enum_value": null,
                "uint32": null
            },
            {
                "id": 17744944,
                "event_type_id": 22,
                "workshop_id": 1,
                "machine_id": 1,
                "time1": 1632993371000,
                "time2": null,
                "data": null,
                "float": 329.59,
                "enum_value": null,
                "uint32": null
            },
            {
                "id": 17744946,
                "event_type_id": 22,
                "workshop_id": 1,
                "machine_id": 1,
                "time1": 1632993371500,
                "time2": null,
                "data": null,
                "float": 330.32,
                "enum_value": null,
                "uint32": null
            },

Deserialization is successful thanks to the generated reader classes and the built-in System.Text.Json library.
The data I'm interested in is "time1" (This is a UNIX timestamp that has already been translated) and "float" (Speed). I need to display the received data in the graph of the function using the OxyPlot library for WPF, where the X-axis is time1, the Y-axis is float. According to the documentation given on oxyplot, I cannot bind such data. Roughly what I'm trying to do:
Func<double, double> numID = (x) => Convert.ToDouble(dateTime); //dateTime перевод времени timestamp
                    Func<double, double> Float = (x) => [email protected]float; // item. обращение к классу десериализации

                    MyModel.Series.Add(new FunctionSeries(numID, 0, 10, 0.0001));
                    MyModel.Series.Add(new FunctionSeries(Float, 0, 10, 0.0001));

Help me please!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question