Hi Joern,
Yes it is possible to create toolbar buttons that have custom actions - the following code shows how to create a toolbar that has a reset axes custom toolbar button:
using System;
using System.Drawing;
using System.Web;
using Nevron.Chart;
using Nevron.Chart.ThinWeb;
using Nevron.GraphicsCore;
using Nevron.ThinWeb;
namespace Nevron.Examples.Chart.WebForm
{
public partial class NToolbarConfigurationUC : NExampleUC
{
protected void Page_Load(object sender, EventArgs e)
{
NThinChartControl1.StateId = "Chart1";
if (!NThinChartControl1.Initialized)
{
// set a chart title
NLabel title = new NLabel("Toolbar Configuration");
NThinChartControl1.Panels.Add(title);
title.DockMode = PanelDockMode.Top;
title.Padding = new NMarginsL(4, 6, 4, 6);
title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
// configure the legend
// configure the chart
NCartesianChart chart = (NCartesianChart)NThinChartControl1.Charts[0];
// setup the X axis
NAxis axisX = chart.Axis(StandardAxis.PrimaryX);
axisX.ScrollBar.Visible = true;
// add interlaced stripe for the Y axis
NAxis axisY = chart.Axis(StandardAxis.PrimaryY);
axisY.ScrollBar.Visible = true;
// add a bar series and fill it with data
NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);
bar.Name = "Simple Bar Chart";
bar.BarShape = BarShape.SmoothEdgeBar;
bar.Legend.Mode = SeriesLegendMode.DataPoints;
bar.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point);
bar.DataLabelStyle.Visible = false;
bar.Values.FillRandom(new Random(), 10);
// configure toolbar
NThinChartControl1.Toolbar.Visible = true;
NThinChartControl1.Controller.SetActivePanel(chart);
// add a data zoom tool
NDataZoomTool dataZoomTool = new NDataZoomTool();
dataZoomTool.Exclusive = true;
dataZoomTool.Enabled = false;
NThinChartControl1.Controller.Tools.Add(dataZoomTool);
NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleDataZoomToolAction()));
NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new ResetZoomAction()));
NThinChartControl1.CustomRequestCallback = new CustomRequestCallback();
}
}
/// <summary>
/// A simple class showing how to show / hide data labels
/// </summary>
[Serializable]
class ResetZoomAction : NAction
{
public ResetZoomAction()
: base("Reset Zoom")
{
}
public override Bitmap GetImage()
{
string path = HttpContext.Current.Server.MapPath(@"~\Images\ShowDataLabelsButton.png");
return (Bitmap)Bitmap.FromFile(path);
}
public override string GetScript()
{
NThinChartControl control = (NThinChartControl)this.m_Control;
return "NClientNode.GetFromId(\'" + control.StateId + "\').ExecuteCustomRequest(\"ResetZoom\");";
}
public override bool IsEnabled()
{
NThinChartControl control = (NThinChartControl)this.m_Control;
NChart chart = control.Charts[0];
return chart.Axis(StandardAxis.PrimaryX).PagingView.Enabled || chart.Axis(StandardAxis.PrimaryY).PagingView.Enabled;
}
}
[Serializable]
public class CustomRequestCallback : INCustomRequestCallback
{
#region INCustomRequestCallback Members
void INCustomRequestCallback.OnCustomRequestCallback(NAspNetThinWebControl control, NRequestContext context, string argument)
{
NThinChartControl chartControl = (NThinChartControl)control;
NChart chart = chartControl.Charts[0];
switch (argument)
{
case "ResetZoom":
{
chart.Axis(StandardAxis.PrimaryY).PagingView.Enabled = false;
chart.Axis(StandardAxis.PrimaryX).PagingView.Enabled = false;
}
break;
}
// update the control and toolbar
chartControl.Update();
}
#endregion
}
}
}
Hope this help let us know if you meet any problems.
Best Regards,
Nevron Support Team