none
adding a Candlestick or Stock chart breaks AxisX.IsStartedFromZero RRS feed

  • Question

  • 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.

    • Edited by Pseudo Bogon Sunday, January 28, 2018 2:51 AM more detail
    Sunday, January 28, 2018 2:30 AM

All replies

  • 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.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, January 29, 2018 7:34 AM
    Moderator
  • Hi Psrudo Bogon,

    Any update?

    If your question has been solved, please mark the useful reply as answer. This will make answer searching in the forum and be beneficial to community members as well.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, February 6, 2018 6:36 AM
    Moderator