-
-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09151d1
commit 9e15e28
Showing
12 changed files
with
633 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import * as dotProp from 'dot-prop' | ||
import * as q from '../../../../backend/src/Model' | ||
import * as React from 'react' | ||
import PlotHistory from './PlotHistory' | ||
import { Base64Message } from '../../../../backend/src/Model/Base64Message' | ||
import { toPlottableValue } from './CodeDiff/util' | ||
|
||
interface Props { | ||
history: q.MessageHistory | ||
dotPath?: string | ||
} | ||
|
||
function nodeToHistory(history: q.MessageHistory) { | ||
return history | ||
.toArray() | ||
.map((message: q.Message) => { | ||
const value = message.value ? toPlottableValue(Base64Message.toUnicodeString(message.value)) : NaN | ||
return { x: message.received.getTime(), y: toPlottableValue(value) } | ||
}).filter(data => !isNaN(data.y as any)) as any | ||
} | ||
|
||
function nodeDotPathToHistory(history: q.MessageHistory, dotPath: string) { | ||
return history | ||
.toArray() | ||
.map((message: q.Message) => { | ||
const json = message.value ? JSON.parse(Base64Message.toUnicodeString(message.value)) : {} | ||
let value = dotProp.get(json, dotPath) | ||
|
||
return { x: message.received.getTime(), y: toPlottableValue(value) } | ||
}).filter(data => !isNaN(data.y as any)) as any | ||
} | ||
|
||
function render(props: Props) { | ||
const data = props.dotPath ? nodeDotPathToHistory(props.history, props.dotPath) : nodeToHistory(props.history) | ||
console.log(props.dotPath, data) | ||
return <PlotHistory data={data} /> | ||
} | ||
|
||
export default render |
Oops, something went wrong.