I am making a small app that plots financial price data and since the finance markets are closed on the weekends, I have no data for those days. By default the chart, found in the new WPF Toolkit, shows a large gap between Friday and following Monday and this behaviour is not acceptable. I am trying to figure out a way to "hide" the weekend gaps but can't seem to find any good solutions. So far, I figured that I would have to overload the standard DateTime
struct (how?) which will be able to recognize and skip weekends and holidays. I am looking for suggestions and/or pointers before I start down that slippery slope.
我正在制作一个小型应用程序来绘制金融价格数据,并且由于金融市场在周末关闭,我没有那些日子的数据。默认情况下,在新的WPF工具包中找到的图表显示星期五和星期一之间存在很大差距,这种行为是不可接受的。我试图想办法“隐藏”周末的差距,但似乎找不到任何好的解决方案。到目前为止,我认为我必须重载标准的DateTime结构(如何?),它将能够识别并跳过周末和假日。在我开始滑坡之前,我正在寻找建议和/或指示。
Some more details:
更多细节:
I am given a wide range of data - currently daily closing prices on NYSE. I am using the DayTimeAxis
to plot the independent variable of LineSeries
which is of type DateTime
. It currently simply plots all the prices, one day at a time - and that's where the devil is, it shows wider gaps due to lack of data for Saturdays and Sundays and some major holidays.
我获得了大量数据 - 目前纽约证券交易所的每日收盘价。我使用DayTimeAxis绘制LineSeries的自变量,其类型为DateTime。它目前只是简单地绘制所有价格,一次一天 - 这就是恶魔所在的地方,由于周六和周日以及一些重大节日缺乏数据,它显示出更大的差距。
I will eventually have to show more detailed (hourly, minute) chart once data becomes available, but the problem will remain if the user will want to view hourly data for some Friday and the following Monday.
一旦数据可用,我最终将必须显示更详细的(每小时,分钟)图表,但如果用户想要查看某个星期五和下周一的每小时数据,问题仍将存在。
3 个解决方案
#1
2
After much playing around with various options, I ended up using the CategoryAxis instead of DateTimeAxis. It treats each day as a category without inferring the relationship between the days.
在经历了各种各样的选择之后,我最终使用了CategoryAxis而不是DateTimeAxis。它将每一天视为一个类别,而不会推断出这些日子之间的关系。
The data can still be kept as DateTime objects for any necessary calculations and you just have to worry about the ToString (that's what CategoryAxis to label each category). Or just throw them all in as strings - technically calculations are done on the data points, not the array of dates so not much of a loss here...
对于任何必要的计算,数据仍然可以作为DateTime对象保存,您只需要担心ToString(这是分别标记每个类别的CategoryAxis)。或者只是将它们全部作为字符串抛出 - 技术上计算是在数据点上进行的,而不是日期数组,所以这里没有太大的损失......
#2
1
If you will plot candlestick or ohlc you can't go with toolkit (you can but it will be VERY unpleasant) if you are open to use component use visifire's the one you may go. if you can't figure it out with that send a sample code please.
如果您将绘制烛台或ohlc,您不能使用工具包(您可以,但它会非常不愉快)如果您打开使用组件使用visifire是您可能去的那个。如果您无法弄明白,请发送示例代码。
#3
0
Completely off the top of my head, so I'm not sure how feasible this would be, but could you possibly set up a value converter on the Width property of the data point that would return "Auto" on a weekday and 0 for a weekend?
完全脱离我的头脑,所以我不确定这是多么可行,但是你可能在数据点的Width属性上设置一个值转换器,它将在工作日返回“Auto”,0表示周末?
#1
2
After much playing around with various options, I ended up using the CategoryAxis instead of DateTimeAxis. It treats each day as a category without inferring the relationship between the days.
在经历了各种各样的选择之后,我最终使用了CategoryAxis而不是DateTimeAxis。它将每一天视为一个类别,而不会推断出这些日子之间的关系。
The data can still be kept as DateTime objects for any necessary calculations and you just have to worry about the ToString (that's what CategoryAxis to label each category). Or just throw them all in as strings - technically calculations are done on the data points, not the array of dates so not much of a loss here...
对于任何必要的计算,数据仍然可以作为DateTime对象保存,您只需要担心ToString(这是分别标记每个类别的CategoryAxis)。或者只是将它们全部作为字符串抛出 - 技术上计算是在数据点上进行的,而不是日期数组,所以这里没有太大的损失......
#2
1
If you will plot candlestick or ohlc you can't go with toolkit (you can but it will be VERY unpleasant) if you are open to use component use visifire's the one you may go. if you can't figure it out with that send a sample code please.
如果您将绘制烛台或ohlc,您不能使用工具包(您可以,但它会非常不愉快)如果您打开使用组件使用visifire是您可能去的那个。如果您无法弄明白,请发送示例代码。
#3
0
Completely off the top of my head, so I'm not sure how feasible this would be, but could you possibly set up a value converter on the Width property of the data point that would return "Auto" on a weekday and 0 for a weekend?
完全脱离我的头脑,所以我不确定这是多么可行,但是你可能在数据点的Width属性上设置一个值转换器,它将在工作日返回“Auto”,0表示周末?