GraphUtility 1.1.1
dotnet add package GraphUtility --version 1.1.1
NuGet\Install-Package GraphUtility -Version 1.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GraphUtility" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GraphUtility --version 1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: GraphUtility, 1.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install GraphUtility as a Cake Addin #addin nuget:?package=GraphUtility&version=1.1.1 // Install GraphUtility as a Cake Tool #tool nuget:?package=GraphUtility&version=1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GraphUtilityTest
{
internal partial class GraphUtilityTest : Form
{
public GraphUtilityTest()
{
Font = SystemInformation.MenuFont;
StartPosition = FormStartPosition.CenterScreen;
var f = new Font("Times New Roman", 12, FontStyle.Italic);
GraphUtility.Graph gu = new GraphUtility.Graph("Sample graph", f);
gu.MainGraph.GraphPane.Legend.IsVisible = false;
gu.SetLegendPosition(ZedGraph.LegendPos.Right);
gu.SetLegendFontSize(9);
MenuStrip menu = new MenuStrip() { Parent = this, };
var toolStripMenuItemTest = new ToolStripMenuItem() { Text = "Test", };
var toolStripMenuItemSettings = new ToolStripMenuItem() { Text = "Settings", };
var toolStripMenuItemAddCurve1 = new ToolStripMenuItem() { Text = "AddCurve1", };
menu.Items.Add(toolStripMenuItemTest);
menu.Items.Add(toolStripMenuItemSettings);
var toolStripMenuItemLabel = new ToolStripMenuItem() { Text = "Set label direct", CheckOnClick = true, };
toolStripMenuItemSettings.DropDownItems.Add(toolStripMenuItemLabel);
var toolStripMenuItemGraphType = new ToolStripMenuItem() { Text = "Set bargraphtype to stack", CheckOnClick = true, };
toolStripMenuItemSettings.DropDownItems.Add(toolStripMenuItemGraphType);
var toolStripMenuItemShowLegend = new ToolStripMenuItem() { Text = "Show legend", CheckOnClick = true, };
toolStripMenuItemShowLegend.CheckedChanged += (sender, e) =>
{
gu.MainGraph.GraphPane.Legend.IsVisible = toolStripMenuItemShowLegend.Checked;
gu.RefreshGraph();
};
toolStripMenuItemSettings.DropDownItems.Add(toolStripMenuItemShowLegend);
toolStripMenuItemTest.DropDownItems.Add(toolStripMenuItemAddCurve1);
var toolStripMenuItemShowTextLabel = new ToolStripMenuItem() { Text = "Show text label", CheckOnClick = true, };
toolStripMenuItemSettings.DropDownItems.Add(toolStripMenuItemShowTextLabel);
toolStripMenuItemAddCurve1.Click += (sender, e) =>
{
//Y axis disappear if use AddCurve or AddBar after using AddPieChart,
//To avoid that, use InitGraphPane
//gu.InitGraphPane(f);
gu.ClearCurve();
gu.SetXAxisTitle("x value");
var s = 2000;
var ppl = GraphUtility.GraphHelper.CreatePointPairList(Enumerable.Range(-s, (s * 2) + 1).Select(x => new ZedGraph.PointPair(x, x * 2 - 20)));
gu.AddCurve(ppl, "y=2x-20", Color.Red);
gu.SetYAxisTitle("red");
var ppl2 = GraphUtility.GraphHelper.CreatePointPairList(Enumerable.Range(-s, (s * 2) + 1).Select(x => new ZedGraph.PointPair(x, Math.Pow(x, 2) - 4 * x + 1)));
gu.AddCurve2(ppl2, "y=x^2-4x+1", Color.Green);
if(toolStripMenuItemShowTextLabel.Checked)
{
var listTextObjPpl1 = GraphUtility.GraphHelper.CreateTextObjList();
var listTextObjPpl2 = GraphUtility.GraphHelper.CreateTextObjList();
listTextObjPpl1.AddRange(ppl.Where(x => x.X % 1000 == 0).Select(x => GraphUtility.GraphHelper.CreateTextObj(x.Y.ToString(), x.X, x.Y,false,f)));
listTextObjPpl2.AddRange(ppl2.Where(x => x.X % 1000 == 0).Select(x => GraphUtility.GraphHelper.CreateTextObj2(x.Y.ToString(), x.X, x.Y,false,f)));
gu.SetTextObj(listTextObjPpl1);
gu.SetTextObj(listTextObjPpl2);
}
gu.SetY2AxisTitle("green");
gu.ReSetLineGraphType(ZedGraph.LineType.Normal);
if (toolStripMenuItemLabel.Checked)
{
/** Set x-axis label directly */
gu.SetXAxisType(ZedGraph.AxisType.Text, 0, Enumerable.Range(0, ppl.Count).Select(x => string.Format("{0}?", x)));
gu.SetXAxisMajorStep(-1);
}
else
{
gu.SetXAxisType(ZedGraph.AxisType.Linear);
gu.SetXAxisScaleFormat("0");
gu.SetXAxisMajorStep(-1);
}
gu.RefreshGraph();
gu.ResetPointValueMode(GraphUtility.Graph.PointValueMode.Normal);
};
var toolStripMenuItemAddBar1 = new ToolStripMenuItem() { Text = "AddBar1", };
toolStripMenuItemTest.DropDownItems.Add(toolStripMenuItemAddBar1);
toolStripMenuItemAddBar1.Click += (sender, e) =>
{
//Y axis disappear if use AddCurve or AddBar after using AddPieChart,
//To avoid that, use InitGraphPane
//gu.InitGraphPane(f);
gu.ClearCurve();
if (toolStripMenuItemGraphType.Checked)
{
/** Stack graph */
gu.ReSetBarGraphType(ZedGraph.BarType.Stack);
}
else
{
/** Bar graph */
gu.ReSetBarGraphType(ZedGraph.BarType.Cluster);
}
var ppl = GraphUtility.GraphHelper.CreatePointPairList();
var ppl2 = GraphUtility.GraphHelper.CreatePointPairList();
foreach (var d in Enumerable.Range(-10, 21))
{
ppl.Add(GraphUtility.GraphHelper.CreatePointPair(DateTime.Today.AddDays(d), d * 4));
ppl2.Add(GraphUtility.GraphHelper.CreatePointPair(DateTime.Today.AddDays(d), d * 4 + d));
}
gu.AddBar(ppl, "date", Color.Red);
gu.AddBar(ppl2, "date2", Color.Blue);
if (toolStripMenuItemShowTextLabel.Checked)
{
var listTextObjPpl1 = GraphUtility.GraphHelper.CreateTextObjList();
var listTextObjPpl2 = GraphUtility.GraphHelper.CreateTextObjList();
listTextObjPpl1.AddRange(ppl.Select(x => GraphUtility.GraphHelper.CreateTextObj(x.Y.ToString(), x.X, (int)( x.Y*1.2) ,false,f )));
listTextObjPpl2.AddRange(ppl2.Select(x => GraphUtility.GraphHelper.CreateTextObj2(x.Y.ToString(), x.X, (int)( x.Y*1.2),false,f)));
gu.SetTextObj(listTextObjPpl1);
gu.SetTextObj(listTextObjPpl2);
}
if (toolStripMenuItemLabel.Checked)
{
/** Set x-axis label directly */
gu.SetXAxisType(ZedGraph.AxisType.Text, 0, Enumerable.Range(0, ppl.Count).Select(x => string.Format("{0}?", x)));
gu.SetXAxisMajorStep(-1);
}
else
{
/** When use date as x-axis label */
gu.SetXAxisType(ZedGraph.AxisType.Date, 45);
gu.SetXAxisScaleFormat("yyyy/MM/dd");
gu.SetXAxisMajorStep(7);
}
gu.ResetPointValueMode(GraphUtility.Graph.PointValueMode.DateTime);
gu.RefreshGraph();
};
var toolStripMenuItemAddPieChart = new ToolStripMenuItem() { Text = "PieChart", };
toolStripMenuItemAddPieChart.Click += (sender, e) =>
{
gu.ClearCurve();
gu.AddPieSlice(70, "bar");
gu.AddPieSlice(50, "baz");
gu.AddPieSlice(30, "foo", null, 0, 0.1);
//gu.ResetPointValueMode(GraphUtility.Graph.PointValueMode.None);
gu.RefreshGraph();
};
toolStripMenuItemTest.DropDownItems.Add(toolStripMenuItemAddPieChart);
/** if want to remove default savemenu, clear ContextMenuStrip */
//gu.ContextMenuStrip.Items.Clear();
var graph = gu.MainGraph;
Controls.Add(graph);
Controls.Add(menu);
SizeChanged += (sender, e) =>
{
graph.Height = ClientSize.Height - menu.Height;
};
ClientSize = new Size(1200, 600);
return;
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.6.1
- ZedGraph (>= 5.1.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.