-1

I am using c1 chart (Component One) to plot and I want to enable zooming feature. I think that I need mouse wheel event but I am not very advanced with that topic. The plot is inside to scroll viewer so I have to be becareful.

Sebastian
  • 27
  • 11
  • Don't think there is any in-built functionality for this and you will most likely have to apply your own scaletransform this should help - https://stackoverflow.com/questions/741956/pan-zoom-image – Rand Random Mar 18 '21 at 13:30
  • @RandRandom There use image to render. Dont serve me, but thx for reply! – Sebastian Mar 18 '21 at 13:44
  • Doesn't matter if image or C1Chart every WPF control can be scaled/transformed. Zooming into an image is just the more common usecase. – Rand Random Mar 18 '21 at 13:53
  • chart.RenderTransform is not ScaleTransform in C1Chart and doesnt has an AxisX or AxisY attribute. chart would be x:name in xaml for C1Chart – Sebastian Mar 18 '21 at 14:33
  • I have used the "ZoomBorder" (second answer from the question) and seems to work just fine - [1]: https://i.stack.imgur.com/dDzA7.png [2]: https://i.stack.imgur.com/sfss8.png [3]: https://i.stack.imgur.com/BbvOf.png – Rand Random Mar 18 '21 at 14:41
  • The error you are getting is probably that the first answer needs you to define a ScaleTransform in XAML eg. https://i.stack.imgur.com/t29UV.png – Rand Random Mar 18 '21 at 14:43
  • The ZoomBorder does it itself in the method `Initialize` – Rand Random Mar 18 '21 at 14:44
  • When Define The compiler throw an error like: Nested types are not supported. I will test with ZoomBorder.cs – Sebastian Mar 18 '21 at 15:10

1 Answers1

0

I already done adding this to xaml.

    <c1:C1Chart.Actions>
        <c1:TranslateAction Modifiers="Shift" />
        <c1:ScaleAction Modifiers="Control" />
    </c1:C1Chart.Actions>

In xaml.cs:

chart.ActionEnter += new EventHandler(Actions_Enter);
chart.ActionLeave += new EventHandler(Actions_Leave);

        private void Actions_Leave(object sender, EventArgs e)
    {
        chart.Cursor = Cursors.Arrow;
    }

    private void Actions_Enter(object sender, EventArgs e)
    {
        if (sender is ScaleAction)
            chart.Cursor = Cursors.SizeNS;
        else if (sender is TranslateAction)
            chart.Cursor = Cursors.SizeAll;
        else
            chart.Cursor = Cursors.Hand;
    }
Sebastian
  • 27
  • 11