|
<SfButton CssClass="e-info" IsPrimary="true" @onclick="LoadChart">Zoom Chart</SfButton>
<SfButton CssClass="e-info" IsPrimary="true" @onclick="Reset">Reset</SfButton> <SfChart Title="Inflation - Consumer Price" @ref="ChartInstance"> // add additional code here
</SfChart> @code{
SfChart ChartInstance; // add additional code here
void LoadChart() { ChartInstance.PrimaryXAxis.ZoomFactor = 0.5; ChartInstance.PrimaryXAxis.ZoomPosition = 0.5; ChartInstance.Refresh(); } void Reset() { ChartInstance.PrimaryXAxis.ZoomFactor = 1; ChartInstance.PrimaryXAxis.ZoomPosition = 1; ChartInstance.Refresh(); } } |
I am using 19.3.44 version, SfChart seems to does not have PrimaryXAxis property in this version, but I added reference to axis istead:
<ChartPrimaryXAxis @ref="xaxis">
Axis scroll bar set to "Enabled":
<ChartZoomSettings Mode="ZoomMode.X" EnableSelectionZooming="true" EnablePan="true" EnableMouseWheelZooming="true" EnablePinchZooming="true" EnableScrollbar="true"></ChartZoomSettings>
|
<SfChart @ref="ChartInstance">
<ChartPrimaryXAxis ZoomFactor="@ZF" ZoomPosition="@ZP">
</ChartPrimaryXAxis>
</SfChart>
@code{
SfChart ChartInstance;
public double ZF = 1;
public double ZP = 0;
void LoadChart()
{
ZF = 0.5;
ZP = 0.5;
ChartInstance.Refresh();
}
void Reset()
{
ZF = 1;
ZP = 0;
ChartInstance.Refresh();
}
} |
I tried sample provided. EnableSelectionZooming="true" works until you press RESET button.
Once I press RESET button, I no longer able to select range using mouse.