添加烛台或股票图表会破坏AxisX.IsStartedFromZero [英] adding a Candlestick or Stock chart breaks AxisX.IsStartedFromZero

查看:105
本文介绍了添加烛台或股票图表会破坏AxisX.IsStartedFromZero的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用System.Windows.Forms.DataVisualization.Charting.Chart做一个项目,它的行为符合预期。但是,仅仅将烛台或股票系列添加到图表区域会破坏相关的IsStartedFromZero属性 - 强制它为true,尽管在设计器中将
设置为false。



(我的帐户验证后会发布截图)


编辑添加:  ; IsStartedFromZero与Stock / Candlestick一起使用如果在同一区域内没有其他带有数据点的图表。


解决方案

Hi Pseudo Bogon,


谢谢你在这里发布。


对于你的问题,当我向图表区域添加烛台或股票系列时,我的数据都是正数,IsStartedFromZero的值是的。当所有数据点值为正时,轴的最小值将为
自动设置为零。 如果存在负数据点值,则将使用数据点的最小值。



以下是供您参考的代码。

 private void _0129_Load(object sender,EventArgs e)
{
// TODO:这行代码将数据加载到'dataBase.Stocks'表中。您可以根据需要移动或删除它。
this.stocksTableAdapter.Fill(this.dataBase.Stocks);

}

private void btnSave_Click(object sender,EventArgs e)
{
try
{
stocksBindingSource.EndEdit( );
stocksTableAdapter.Update(dataBase.Stocks);
dataGridView.Refresh();
MessageBox.Show("您的数据已成功保存。","消息",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
catch(exception ex)
{
MessageBox.Show(ex.Message," Message",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}

private void btnLoad_Click(object sender,EventArgs e)
{
// Clear Grid
chart.ChartAreas [" ; ChartArea1"]。AxisX.MajorGrid.LineWidth = 0;
chart.ChartAreas [" ChartArea1"]。AxisY.MajorGrid.LineWidth = 0;
// Init
chart.Series [" Daily"]。XValueMember =" Day" ;;
chart.Series [" Daily"]。YValueMembers =" High,Low,Open,Close" ;;
chart.Series [" Daily"]。XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Date;
chart.Series [" Daily"]。CustomProperties =" PriceDownColor = Red,PriceUpColor = Blue" ;;
//chart.Series [" Daily"] [" OpenCloseStyle"] =" Triangle" ;;
chart.Series [" Daily"] [" ShowOpenClose"] =" Both" ;;
chart.DataManipulator.IsStartFromFirst = true;
chart.DataSource = dataBase.Stocks;
chart.DataBind();
}






股票



烛台



对于这些步骤,您想参考YouTube中的视频。


https://www.youtube.com/watch?v=IGKSaH4yz-g


最诚挚的问候,


Wendy


注意:此回复包含参考第三方万维网站点。 Microsoft提供此信息是为了方便您。 

Microsoft不会控制这些网站,并没有测试在这些网站上找到的任何软件或信息;因此,Microsoft不能对任何软件的质量,安全性或适用性进行任何陈述。
或在那里找到的信息。






I'm doing a project with System.Windows.Forms.DataVisualization.Charting.Chart, it behaves as expected. However, merely adding a Candlestick or Stock series to a chart area breaks relevant IsStartedFromZero property - forcing it to true, despite being set to false in designer.

(I'll post screenshots when my account is verified)

Edited to add: IsStartedFromZero works with Stock/Candlestick if there are no other charts with datapoints in the same area.

解决方案

Hi Pseudo Bogon,

Thank you for posting here.

For your question, when I add a Candlestick or Stock series to chart area, my data is all positive, the value of IsStartedFromZero is true. When the all data point values are positive, the minimum value of the axis will be automatically set to zero.  If there are negative data point values, the minimum value of the data points will be used.

Here is the code for your reference.

 private void _0129_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dataBase.Stocks' table. You can move, or remove it, as needed.
            this.stocksTableAdapter.Fill(this.dataBase.Stocks);

        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                stocksBindingSource.EndEdit();
                stocksTableAdapter.Update(dataBase.Stocks);
                dataGridView.Refresh();
                MessageBox.Show("Your data has been successfully saved.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void btnLoad_Click(object sender, EventArgs e)
        {
            //Clear Grid
            chart.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineWidth = 0;
            chart.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineWidth = 0;
            //Init
            chart.Series["Daily"].XValueMember = "Day";
            chart.Series["Daily"].YValueMembers = "High, Low, Open, Close";
            chart.Series["Daily"].XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Date;
            chart.Series["Daily"].CustomProperties = "PriceDownColor =Red, PriceUpColor=Blue";
            //chart.Series["Daily"]["OpenCloseStyle"] = "Triangle";
            chart.Series["Daily"]["ShowOpenClose"] = "Both";
            chart.DataManipulator.IsStartFromFirst = true;
            chart.DataSource = dataBase.Stocks;
            chart.DataBind();
        }



Stocks

Candlestick

For the steps, you would like to refer to the video in YouTube.

https://www.youtube.com/watch?v=IGKSaH4yz-g

Best Regards,

Wendy

Note: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you. 
Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


这篇关于添加烛台或股票图表会破坏AxisX.IsStartedFromZero的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆