Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 是否可以按字母顺序排列氧图图例中的系列?_Wpf_Charts_Legend_Series_Oxyplot - Fatal编程技术网

Wpf 是否可以按字母顺序排列氧图图例中的系列?

Wpf 是否可以按字母顺序排列氧图图例中的系列?,wpf,charts,legend,series,oxyplot,Wpf,Charts,Legend,Series,Oxyplot,我想按字母顺序排列氧图的图例。在Oxyplot中是否可能出现这种情况 以下是我当前的情节: 我想订购我的图表的图例。我不会先对绘制数据的方式进行排序,因为这将意味着太多的条件,我希望尽量保持绘制的通用性。我知道这是一种选择,但我不想采用这种方法 请告诉我是否可以按字母顺序排列仅在Oxyplot中的图例项?您不能直接修改图例的顺序,但您可以在模型内对序列进行排序,因此您将看到按字母顺序排列的图例: 有两种方法可以进行排序: 选项1,简单气泡排序: Series temp; int length =

我想按
字母顺序排列氧图的
图例
。在Oxyplot中是否可能出现这种情况

以下是我当前的情节:

我想订购我的
图表的
图例
。我不会先对绘制数据的方式进行排序,因为这将意味着太多的条件,我希望尽量保持绘制的通用性。我知道这是一种选择,但我不想采用这种方法


请告诉我是否可以按字母顺序排列
仅在
Oxyplot
中的图例项?

您不能直接修改图例的顺序,但您可以在模型内对序列进行排序,因此您将看到按字母顺序排列的图例:

有两种方法可以进行排序:

选项1,简单气泡排序:

Series temp;
int length = plotModel.Series.Count;
for (i = 0; i < length; i++)
{
    for (int j = i + 1; j < length; j++)
    {
        if (string.Compare(plotModel.Series[i].Title, plotModel.Series[j].Title) > 0) //true if second string goes before first string in alphabetical order
        {
            temp = plotModel.Series[i];
            plotModel.Series[i] = plotModel.Series[j];
            plotModel.Series[j] = temp;
        }
    }
}
List<Series> sortedList = new List<Series>(plotModel.Series);
sortedList.Sort((x, y) => string.Compare(x.Title, y.Title));

plotModel.Series.Clear();
foreach(Series s in sortedList)
    plotModel.Series.Add(s);
系列温度;
int length=plotModel.Series.Count;
对于(i=0;i0)//如果第二个字符串按字母顺序排在第一个字符串之前,则为true
{
温度=绘图模型系列[i];
plotModel.Series[i]=plotModel.Series[j];
plotModel.Series[j]=温度;
}
}
}
选项2,辅助列表:

Series temp;
int length = plotModel.Series.Count;
for (i = 0; i < length; i++)
{
    for (int j = i + 1; j < length; j++)
    {
        if (string.Compare(plotModel.Series[i].Title, plotModel.Series[j].Title) > 0) //true if second string goes before first string in alphabetical order
        {
            temp = plotModel.Series[i];
            plotModel.Series[i] = plotModel.Series[j];
            plotModel.Series[j] = temp;
        }
    }
}
List<Series> sortedList = new List<Series>(plotModel.Series);
sortedList.Sort((x, y) => string.Compare(x.Title, y.Title));

plotModel.Series.Clear();
foreach(Series s in sortedList)
    plotModel.Series.Add(s);
List sortedList=新列表(plotModel.Series);
sortedList.Sort((x,y)=>string.Compare(x.Title,y.Title));
plotModel.Series.Clear();
foreach(分拣列表中的系列s)
plotModel.Series.Add(s);