FlexChart
FlexChart
Zooming and Panning
Mouse action:
Zoom mode: Select the chart area to zoom in, or scroll mouse wheel to zoom in/out.
Features
Settings
Mouse Action: Zoom
Interactive Axes: X
Description
-
Mouse action:
- Zoom mode: Select the chart area to zoom in, or scroll mouse wheel to zoom in/out.
- Pan mode: Click and drag within the chart area to change the display range.
-
Touch action:
- Pan the chart area to change the display range; pinch it to zoom in/out.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | using MvcExplorer.Models; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; namespace MvcExplorer.Controllers { public partial class FlexChartController: Controller { private static IEnumerable<FinanceData> fbData = JsonDataReader.GetFromAssembly<FinanceData>( "fb2.json" ); public ActionResult PanningAndScaling() { return View(fbData); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | @model List< FinanceData > @ { ViewBag.DemoSettings = true ; } < c1-flex-chart id = "gesturesChart" class = "stchart" chart-type = "Area" binding-x = "X" legend-position = "None" plot-margin = "NaN NaN NaN 80" > < c1-flex-chart-axis c1-property = "AxisX" axis-line = "false" ></ c1-flex-chart-axis > < c1-flex-chart-series binding = "Close" name = "Y Value" ></ c1-flex-chart-series > < c1-items-source source-collection = "Model" ></ c1-items-source > < c1-chart-gestures id = "gestures" mouse-action = "Zoom" interactive-axes = "X" scale-x = "0.5f" scale-y = "0.5f" pos-x = "0.1f" pos-y = "0.1f" ></ c1-chart-gestures > </ c1-flex-chart > @section Scripts{ <script> var chart, chartGestures; c1.documentReady( function () { var gesturesChart = getChart(); if (navigator.userAgent.match(/iPad/i) != null || /Android/i.test(navigator.userAgent)) { document.querySelector( '#mouseAction' ).style.display = 'none' ; } if (gesturesChart) { gesturesChart.axisX.rangeChanged.addHandler( function () { document.querySelector( '#reset' ).disabled = undefined; }); gesturesChart.axisY.rangeChanged.addHandler( function () { document.querySelector( '#reset' ).disabled = undefined; }); } }); function getChart() { if (!chart) { chart = wijmo.Control.getControl( '#gesturesChart' ); } return chart; } function getChartGesture() { var gesturesChart; if (!chartGestures) { gesturesChart = getChart(); chartGestures = c1.getExtender(gesturesChart, 'gestures' ); } return chartGestures; } function updateMenu(menu, headerNamePrefix) { menu.header = headerNamePrefix + ': <b>' + menu.selectedItem.Header + '</b>' ; } function mouseActionChanged(menu) { var extGesture = getChartGesture(); updateMenu(menu, 'Mouse Action' ); if (extGesture) { extGesture.mouseAction = wijmo.chart.interaction.MouseAction[menu.selectedItem.Header]; } } function interactiveAxesChanged(menu) { var extGesture = getChartGesture(); updateMenu(menu, 'Interactive Axes' ); if (extGesture) { extGesture.interactiveAxes = wijmo.chart.interaction.InteractiveAxes[menu.selectedItem.Header]; } } function resetAxes() { var extGesture = getChartGesture(); if (extGesture) { extGesture.reset(); } document.querySelector( '#reset' ).disabled = 'disabled' ; } </script> } @section Settings{ < c1-menu id = "mouseAction" header= "Mouse Action: <b>Zoom</b>" item-clicked= "mouseActionChanged" > < c1-menu-item header = "Zoom" ></ c1-menu-item > < c1-menu-item header = "Pan" ></ c1-menu-item > </ c1-menu > < c1-menu id = "interactiveAxes" header= "Interactive Axes: <b>X</b>" item-clicked= "interactiveAxesChanged" > < c1-menu-item header = "X" ></ c1-menu-item > < c1-menu-item header = "Y" ></ c1-menu-item > < c1-menu-item header = "XY" ></ c1-menu-item > </ c1-menu > < button id = "reset" class = "btn btn-primary" onclick = "resetAxes()" disabled = "disabled" >Reset Zoom</ button > } @section Description{ < div class = "panel panel-default" > < div class = "panel-heading" > < ul > < li > < b > @Html .Raw(FlexChartRes.PanningAndScaling_MouseAction)</ b > < ol > < li > @Html .Raw(FlexChartRes.PanningAndScaling_Li1)</ li > < li > @Html .Raw(FlexChartRes.PanningAndScaling_Li2)</ li > </ ol > </ li > < li > < b > @Html .Raw(FlexChartRes.PanningAndScaling_TouchAction)</ b > < ol > < li > @Html .Raw(FlexChartRes.PanningAndScaling_Li3) </ li > </ ol > </ li > </ ul > </ div > </ div > } |