c# - remove white spaces below winforms graph -
i have created chart in winforms , host in wpf using winformhost. when implementing in wpf, there space below graph. if reduce size of chart, chart becomes small. how remove space below graph?
here code.
xaml.cs
var chartarea = new chartarea("eqgraph"); chart chart1 = this.findname("eqgraph") chart; chart1.chartareas.add("eqgraph"); chart1.series.add("front left"); chart1.chartareas[0].axisx.maximum = 20000; chart1.chartareas[0].axisx.minimum = 10; chart1.chartareas[0].axisx.islogarithmic = true; chart1.chartareas[0].axisx.minorgrid.interval = 1; chart1.chartareas[0].axisx.minorgrid.enabled = true; chart1.chartareas[0].axisy.maximum = 20; chart1.chartareas[0].axisy.minimum = -50; chart1.chartareas[0].axisy.interval = 5; chart1.chartareas[0].axisx.minorgrid.linedashstyle = system.windows.forms.datavisualization.charting.chartdashstyle.dashdotdot; chart1.chartareas[0].axisy.majorgrid.linedashstyle = system.windows.forms.datavisualization.charting.chartdashstyle.dashdotdot; chart1.chartareas[0].axisx.labelstyle.font = new system.drawing.font("trebuchet ms", 10f, system.drawing.fontstyle.bold); chart1.chartareas[0].axisy.labelstyle.font = new system.drawing.font("trebuchet ms", 10f, system.drawing.fontstyle.bold); chart1.chartareas[0].axisx.title = "frequency(hz)"; chart1.chartareas[0].axisy.title = "gain"; int[] xvaluesfrontleft = { 10, 100, 1000, 5000, 4200, 8499 }; int[] yvaluesfrontleft = { 16, 10, -5, -10, 35, -40 }; chart1.series["front left"].points.databindxy(xvaluesfrontleft, yvaluesfrontleft); chart1.series["front left"].charttype = seriescharttype.spline;
xaml
<dockpanel grid.column="3" grid.row="1" grid.rowspan="9" background="#fffbf9f9"> <windowsformshost x:name="host" height="500"> <winformchart:chart x:name="eqgraph" dock="fill"> <winformchart:chart.series > <winformchart:series name="series" charttype="line"/> </winformchart:chart.series> <winformchart:chart.chartareas> <winformchart:chartarea/> </winformchart:chart.chartareas> </winformchart:chart> </windowsformshost> </dockpanel>
i don't think need create new chartarea
place graph, because graph placed inside windowsformshost
in xaml already, , it's docked, same size it's host. use chart this:
// remove these lines // var chartarea = new chartarea("eqgraph"); // chart chart1 = this.findname("eqgraph") chart; // chart1.chartareas.add("eqgraph"); // adding values, series , properties graph inside winformshost chart chart1 = eqgraph;
you replace chart1
eqgraph
inside code directly, @ places:
eqgraph.series.add("front left"); eqgraph.chartareas[0].axisx.maximum = 20000; eqgraph.chartareas[0].axisx.minimum = 10; eqgraph.chartareas[0].axisx.islogarithmic = true; eqgraph.chartareas[0].axisx.minorgrid.interval = 1; eqgraph.chartareas[0].axisx.minorgrid.enabled = true; eqgraph.chartareas[0].axisy.maximum = 20; eqgraph.chartareas[0].axisy.minimum = -50; eqgraph.chartareas[0].axisy.interval = 5; eqgraph.chartareas[0].axisx.minorgrid.linedashstyle = system.windows.forms.datavisualization.charting.chartdashstyle.dashdotdot; eqgraph.chartareas[0].axisy.majorgrid.linedashstyle = system.windows.forms.datavisualization.charting.chartdashstyle.dashdotdot; eqgraph.chartareas[0].axisx.labelstyle.font = new system.drawing.font("trebuchet ms", 10f, system.drawing.fontstyle.bold); eqgraph.chartareas[0].axisy.labelstyle.font = new system.drawing.font("trebuchet ms", 10f, system.drawing.fontstyle.bold); eqgraph.chartareas[0].axisx.title = "frequency(hz)"; eqgraph.chartareas[0].axisy.title = "gain"; int[] xvaluesfrontleft = { 10, 100, 1000, 5000, 4200, 8499 }; int[] yvaluesfrontleft = { 16, 10, -5, -10, 35, -40 }; eqgraph.series["front left"].points.databindxy(xvaluesfrontleft, yvaluesfrontleft); eqgraph.series["front left"].charttype =seriescharttype.spline;
Comments
Post a Comment