Click here to Skip to main content
15,900,681 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi !

I dinamically add graf from code :
C#
bool gridLine = true;
List<lineseries> list = new List<lineseries>();
for (int i = 0; i < SeriesCount; i++)
{
    list.Add(new LineSeries());
}
foreach (LineSeries series in list)
{
    series.IsSelectionEnabled = true;
    series.IndependentValueBinding = new System.Windows.Data.Binding("Key");
    series.DependentValueBinding = new System.Windows.Data.Binding("Value");

    LinearAxis dependentLA = new LinearAxis();
    dependentLA.Orientation = AxisOrientation.Y;
    dependentLA.Maximum = maximum;
    dependentLA.Minimum = minimum;
    dependentLA.Interval = interval;
    dependentLA.Title = axisYname;
    dependentLA.Location = AxisLocation.Left;
    if (gridLine)
    {
        dependentLA.ShowGridLines = true;
    }
    else
    {
        dependentLA.ShowGridLines = false;
    }
    series.DependentRangeAxis = dependentLA;
    gridLine = false;

    graf.Series.Add(series);
}</lineseries></lineseries>


But it shows chart with two Y axis labels on left side (if Location is auto: one on left, second on the right side). I try to create graf just with one Y axis and 2+ lines.
Any1 help me ?

P.S.: If i define just one LinearAxis (for example in first series), second is generated automatically and it shows two axis Y with labels and with gridlines (it looks terrible). If I define no LinearAxis its good, but i need set range,max,min,..
Posted
Updated 20-Nov-11 23:40pm
v2

1 solution

Finally I have found solution.

{
List<lineseries> list = new List<lineseries>();
for (int i = 0; i < SeriesCount; i++)
{
    list.Add(new LineSeries());
}
LinearAxis dependentLA = new LinearAxis();
dependentLA.Orientation = AxisOrientation.Y;
dependentLA.Maximum = maximum;
dependentLA.Minimum = minimum;
dependentLA.Interval = interval;
dependentLA.Title = axisYname;
dependentLA.Location = AxisLocation.Left;
dependentLA.ShowGridLines=true;

CategoryAxis independentLA = new CategoryAxis();
independentLA.Orientation = AxisOrientation.X;
independentLA.Location = AxisLocation.Bottom;
independentLA.Title = axisXname;

graf.Axes.Add(dependentLA);
graf.Axes.Add(independentLA);


foreach (LineSeries series in list)
{
    series.IsSelectionEnabled = true;
    series.IndependentValueBinding = new System.Windows.Data.Binding("Key");
    series.DependentValueBinding = new System.Windows.Data.Binding("Value");

    graf.Series.Add(series);
}

}</lineseries></lineseries>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900