# \[BUG?\] Perspective Power Chart Bug - Embr-Chart as a Replacement?

**URL:** <https://forum.inductiveautomation.com/t/bug-perspective-power-chart-bug-embr-chart-as-a-replacement/102084>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [February 10, 2025, 5:42am UTC](https://forum.inductiveautomation.com/t/bug-perspective-power-chart-bug-embr-chart-as-a-replacement/102084 "2025-02-10T05:42:11Z")\
**Posts on this page:** 1\
**Showing post:** 36

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [February 12, 2025, 2:33am UTC](https://forum.inductiveautomation.com/t/bug-perspective-power-chart-bug-embr-chart-as-a-replacement/102084/36 "2025-02-12T02:33:04Z")

</div>

> [@nminchin](#):
>
> Yep you were right, I had the events defined in the wrong spot, oops! Thanks.

🎉

> [@nminchin](#):
>
> it behaves now and seems to be smoother

Yeah my first example didn't track the mouse very well.

Here's a version that should be exactly 1-to-1 by using some `Chart.js` scale helpers (`getPixelForValue` and `getValueForPixel`). You'll have to add the mouse cursor stuff back in (or have Claude do it for you 😉)

```python
(chart, event) => {
    if (event.event.type !== 'mousedown') return

    const { x: clickX, y: clickY } = event.event
    const scale = chart.scales.y

    if (clickX > scale.right || clickX < scale.left) return

    let isDragging = true
    const startMax = scale.max
    const startPixel = scale.getPixelForValue(startMax)

    const onMouseMove = (moveEvent) => {
        if (!isDragging) return

        const deltaPixels = clickY - moveEvent.clientY
        const deltaValue = scale.getValueForPixel(startPixel + deltaPixels) - scale.getValueForPixel(startPixel)

        chart.options.scales.y.max = startMax + deltaValue
        chart.update()
    }

    const onMouseUp = () => {
        isDragging = false
        document.removeEventListener('mousemove', onMouseMove)
        document.removeEventListener('mouseup', onMouseUp)
    }

    document.addEventListener('mousemove', onMouseMove)
    document.addEventListener('mouseup', onMouseUp)
}

```

Question: does dragging only adjust the max of the Citech chart? Is there an alternative way of adjusting the minimum?

---

_[View the full topic](https://forum.inductiveautomation.com/t/bug-perspective-power-chart-bug-embr-chart-as-a-replacement/102084)._
