Silverlight 和 C# 中的日期时间数据问题

发布于 2024-11-24 20:33:41 字数 1324 浏览 0 评论 0原文

我正在 Silverlight 和 C# 中使用 VISI Fire 来生成一些数据图表。一种样式的图表允许将堆叠数据显示在列中,我正在使用的 xaml 代码如下所示:

 IMG]https://i67.photobucket.com/albums/h292/Athono/xaml.png[/IMG

我试图构建的图表是基于以visi火图为例。如果您访问 http://www.visifire.com/silverlight_wpf_charts_gauges_gallery.php 并查看他们在这里堆积的例子http://www.visifire.com/silverlight_stacked_charts_gallery.php 你可以看到我正在尝试的xaml示例效仿。

IMG]https://i67.photobucket.com/albums/h292/Athono/post_this.png[ /IMG

但我的图表结果有所不同。我的有这个奇怪的重叠日期功能

IMG]http://i67.photobucket.com/albums/h292/Athono/badrepresentation.png [/IMG

现在,我已经仔细地执行了代码,据我所知,每个数据集对都有相同的日期。

IMG]http://i67.photobucket.com/albums/h292/Athono/code-1.png[/IMG

我已逐步执行此代码,并确保对于 i 的每个值,每个数据对的年份和月份都完全相同。那么为什么我的图表如此混乱?

我使用 DateTime 类的方式有问题吗?

new DateTime((Int32) Year_Id,(Int32) SMonth_Id, (Int32)1);

I am using VISI Fire in Silverlight and C# to produce some data charts. One style of chart allows stacked data to be displayed in colums the xaml code I am using looks like this:

IMG]https://i67.photobucket.com/albums/h292/Athono/xaml.png[/IMG

The chart i am trying to build is based on a visi fire chart example. if you go to http://www.visifire.com/silverlight_wpf_charts_gauges_gallery.php and look at their stacked examples here http://www.visifire.com/silverlight_stacked_charts_gallery.php you can see the xaml example I am trying to emulate.

IMG]https://i67.photobucket.com/albums/h292/Athono/post_this.png[/IMG

But my chart comes out differently. mine has this odd overlaping date feature

IMG]http://i67.photobucket.com/albums/h292/Athono/badrepresentation.png[/IMG

Now, I have carefully stepped through the code and as far as I can tell, I have the same date for each data set pair.

IMG]http://i67.photobucket.com/albums/h292/Athono/code-1.png[/IMG

I have stepped through this code and I have made sure that with each value for i, the years and the months for each data pair are exactly the same. So why is my graph so messed up?

Is there something wrong with they way I am using the DateTime class?

new DateTime((Int32) Year_Id,(Int32) SMonth_Id, (Int32)1);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

慕巷 2024-12-01 20:33:42

第一个解决方案:

将两个 DataSeries 中的 AxisXLabel 属性而不是 XValue 设置为字符串。不要在 DataSeries 或 x 轴中设置 XValueType。也不要在 x 轴上设置 Interval 属性。

示例:

<vc:Chart.Series>
    <vc:DataSeries>
        <vc:DataSeries.DataPoints>
            <vc:DataPoint  AxisXLabel="Jan - 2010" YValue="2"/>
            <vc:DataPoint  AxisXLabel="Feb - 2010" YValue="3"/>
            <vc:DataPoint  AxisXLabel="Mar - 2010" YValue="4"/>
        </vc:DataSeries.DataPoints>
    </vc:DataSeries>
    <vc:DataSeries>
        <vc:DataSeries.DataPoints>
            <vc:DataPoint  AxisXLabel="Jan - 2010" YValue="10"/>
            <vc:DataPoint  AxisXLabel="Feb - 2010" YValue="20"/>
            <vc:DataPoint  AxisXLabel="Mar - 2010" YValue="30"/>
        </vc:DataSeries.DataPoints>
    </vc:DataSeries>
</vc:Chart.Series>

第二个解决方案:

无需对当前代码进行任何更改。继续按当前设置设置 XValue。您只需在 XAML 中的 x 轴中设置两个属性 IntervalType="Month" 和 Interval="1" 即可。

1st Solution:

Set AxisXLabel property instead of XValue in both DataSeries as String. Do not set XValueType in DataSeries or in x-axis. Also do not set Interval property in x-axis.

Example:

<vc:Chart.Series>
    <vc:DataSeries>
        <vc:DataSeries.DataPoints>
            <vc:DataPoint  AxisXLabel="Jan - 2010" YValue="2"/>
            <vc:DataPoint  AxisXLabel="Feb - 2010" YValue="3"/>
            <vc:DataPoint  AxisXLabel="Mar - 2010" YValue="4"/>
        </vc:DataSeries.DataPoints>
    </vc:DataSeries>
    <vc:DataSeries>
        <vc:DataSeries.DataPoints>
            <vc:DataPoint  AxisXLabel="Jan - 2010" YValue="10"/>
            <vc:DataPoint  AxisXLabel="Feb - 2010" YValue="20"/>
            <vc:DataPoint  AxisXLabel="Mar - 2010" YValue="30"/>
        </vc:DataSeries.DataPoints>
    </vc:DataSeries>
</vc:Chart.Series>

2nd Solution:

No need to do any changes in your current code. Continue setting XValue as you are setting currently. You just need to set two properties IntervalType="Month" and Interval="1" in x-axis in XAML.

猫烠⑼条掵仅有一顆心 2024-12-01 20:33:42

Somnath 的第二个解决方案有效。

我不确定第一个。我记得我曾经尝试过,但没有取得好的结果。对于堆叠图表来说,它有问题。

我终于让它工作了。我必须向 xaml 添加一些规范。

这是修复方法:

<vc:Chart.AxesX>
    <vc:Axis ValueFormatString="MMM - yyyy" Padding="4" LineThickness="0" IntervalType="Months"  Interval="1"/>
</vc:Chart.AxesX>

2nd solution from Somnath works.

I am not sure about the 1st. I remember it was tried and I did not have good results. For a stacked chart, it had issues.

I got it working finally. I had to add some specification to the xaml.

Here is the fix:

<vc:Chart.AxesX>
    <vc:Axis ValueFormatString="MMM - yyyy" Padding="4" LineThickness="0" IntervalType="Months"  Interval="1"/>
</vc:Chart.AxesX>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文