Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
makedonsky94 committed Sep 1, 2023
2 parents 8f4da6e + 08c3dbd commit 63dcec1
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions lightweightlibrary/lib/app/subscriptions-function-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ export default class SubscriptionsFunctionManager {
(input, callback) => {
try {
const subscription = (params) => {
let customSeries = []
params.seriesPrices.forEach((value, key, map) => {
customSeries.push({id: this.seriesFunctionManager.getSeriesId(key, input), prices: value})
})
params.seriesPrices = customSeries
callback(params)
let mouseEvent = this.mouseEvent(params, input)
callback(mouseEvent)
}
chart.subscribeClick(subscription)
logger.d("subscribeOnChartClicked successful")
Expand All @@ -43,22 +39,8 @@ export default class SubscriptionsFunctionManager {
(input, callback) => {
try {
const subscription = (params) => {
params.sourceEvent = this.selectProps(
"clientX", "clientY", "pageX", "pageY", "screenX", "screenY",
"localX", "localY", "ctrlKey", "altKey", "shiftKey", "metaKey"
)(params.sourceEvent)

let customSeries = []
params.seriesData.forEach((value, key, map) => {
customSeries.push({id: this.seriesFunctionManager.getSeriesId(key, input), prices: value})
})
params.seriesData = customSeries

if (params.hoveredSeries) {
params.hoveredSeries = this.seriesFunctionManager.getSeriesId(params.hoveredSeries, input)
}

callback(params)
let mouseEvent = this.mouseEvent(params, input)
callback(mouseEvent)
}
chart.subscribeCrosshairMove(subscription)
logger.d("subscribeCrosshairMove successful")
Expand All @@ -79,6 +61,27 @@ export default class SubscriptionsFunctionManager {
)
}

mouseEvent(params, input) {
let result = this.selectProps("time", "logical", "point")(params)
result.sourceEvent = this.selectProps(
"clientX", "clientY", "pageX", "pageY", "screenX", "screenY",
"localX", "localY", "ctrlKey", "altKey", "shiftKey", "metaKey"
)(params.sourceEvent)

result.seriesData = []
params.seriesData.forEach((value, key, map) => {
result.seriesData.push({
id: this.seriesFunctionManager.getSeriesId(key, input),
prices: value
})
})


if (params.hoveredSeries) {
result.hoveredSeries = this.seriesFunctionManager.getSeriesId(params.hoveredSeries, input)
}
return result
}

selectProps(...props) {
return function (obj) {
Expand Down

0 comments on commit 63dcec1

Please sign in to comment.