1

I am using a tee chart library in xamarin (Android). i am facing a problem to daynamic binding data in "Candle Chart"

The Sample Code Like this!

protected override void OnCreate(Bundle bundle)
{
    base.OnCreate(bundle);
    RequestWindowFeature(WindowFeatures.NoTitle);
    SetContentView(Resource.Layout.CandleChart);

    //InitializeComponent();

    chart = new Steema.TeeChart.TChart(this.ApplicationContext);
    chart.Zoom.Style = Steema.TeeChart.ZoomStyles.InChart;
    Steema.TeeChart.Themes.BlackIsBackTheme myTheme = new Steema.TeeChart.Themes.BlackIsBackTheme(chart.Chart);
    myTheme.Apply();
    Type tmp = (Type)Steema.TeeChart.Utils.SeriesTypesOf[12];
    Steema.TeeChart.Styles.Series series;
    series = chart.Series.Add(tmp);

    series.FillSampleValues();  /* Here i want to fill series with my data listed bellow */

    chart.Aspect.View3D = Needs3D(chart[0]);
    chart.Panel.Transparent = true;

    SetContentView(chart);
}

now i want add series data manually

like :

currentItem.Data.Close

currentItem.Data.Open

currentItem.Data.High

currentItem.Data.Low

currentItem.Time

etc.. so, plz help me to achieve this ..

thanks, in advance

==================================================================================

My Code Like as Bellow

    private void LoadChart(GraphOutput resGraph)
    {
        DataSet_Obj.Tables.Add("CandleTable");
        DataSet_Obj.Tables["CandleTable"].Columns.Add(new DataColumn("Date", System.Type.GetType("System.DateTime")));
        DataSet_Obj.Tables["CandleTable"].Columns.Add(new DataColumn("Open", System.Type.GetType("System.Double")));
        DataSet_Obj.Tables["CandleTable"].Columns.Add(new DataColumn("Close", System.Type.GetType("System.Double")));
        DataSet_Obj.Tables["CandleTable"].Columns.Add(new DataColumn("High", System.Type.GetType("System.Double")));
        DataSet_Obj.Tables["CandleTable"].Columns.Add(new DataColumn("Low", System.Type.GetType("System.Double"))); 

        for (int i = 0; i < resGraph.graphSymbol[0].CandleSticks.Length; i++)
        {
            DataRow_Obj = DataSet_Obj.Tables["CandleTable"].NewRow();
            DataRow_Obj["Date"] = resGraph.graphSymbol[0].CandleSticks[i].CandleTime;        //DateTime 
            DataRow_Obj["Low"] = resGraph.graphSymbol[0].CandleSticks[i].CandleData.Low;     //Float
            DataRow_Obj["Close"] = resGraph.graphSymbol[0].CandleSticks[i].CandleData.Close; //Float
            DataRow_Obj["Open"] = resGraph.graphSymbol[0].CandleSticks[i].CandleData.Open;   //Float
            DataRow_Obj["High"] = resGraph.graphSymbol[0].CandleSticks[i].CandleData.High;   //Float
            DataSet_Obj.Tables["CandleTable"].Rows.Add(DataRow_Obj);
            DataRow_Obj = null;
        }

        Tag_Serie_Candle = new Steema.TeeChart.Styles.Candle ();
        chart.Series.Add(Tag_Serie_Candle);
        chart.Aspect.View3D = Needs3D(chart[0]);
        chart.Panel.Transparent = true;

        try
        {
            Tag_Serie_Candle.DataSource = DataSet_Obj.Tables["CandleTable"];   /* here I got Error Like: "Cannot bind to non-supported datasource: CandleTable" */
            Tag_Serie_Candle.OpenValues.DataMember = DataSet_Obj.Tables["CandleTable"].Columns["Open"].ToString();
            Tag_Serie_Candle.CloseValues.DataMember = DataSet_Obj.Tables["CandleTable"].Columns["Close"].ToString();
            Tag_Serie_Candle.DateValues.DataMember = DataSet_Obj.Tables["CandleTable"].Columns["Date"].ToString();
            Tag_Serie_Candle.DateValues.DateTime = true;
            Tag_Serie_Candle.HighValues.DataMember = DataSet_Obj.Tables["CandleTable"].Columns["High"].ToString();
            Tag_Serie_Candle.LowValues.DataMember = DataSet_Obj.Tables["CandleTable"].Columns["Low"].ToString();
            Tag_Serie_Candle.LabelMember = "Candle Chart";
            Tag_Serie_Candle.CheckDataSource();

            chartpie.AddView(chart, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));
        }
        catch (Exception exe)
        {
            exe.Message.ToString();
        }
    }

1 Answer 1

0

You should do something as in the examples here:

http://www.teechart.net/support/viewtopic.php?f=4&t=2978&p=10547#p10547 http://www.teechart.net/support/viewtopic.php?f=4&t=3291&p=11691#p11691 http://www.teechart.net/support/viewtopic.php?f=4&t=2741&p=11681#p11681

I have found that, at the present moment, this is not working. I added the defect (ID566) list to be fixed as soon as possible (now fixed, see update at the bottom of the reply). If you register at Steema Software's Bugzilla system, you will be able to be in the CC List and be notified about status updates. In the meantime you can manually read values from the DataSet using this code:

Tag_Serie_Candle.DateValues.DateTime = true;

for (int i = 0; i < DataSet_Obj.Tables["CandleTable"].Rows.Count; i++)
{
  DataRow row = DataSet_Obj.Tables["CandleTable"].Rows[i];

  DateTime dt = Convert.ToDateTime(row["Date"]);
  Double open = Convert.ToDouble(row["Open"]);
  Double high = Convert.ToDouble(row["High"]);
  Double low = Convert.ToDouble(row["Low"]);
  Double close = Convert.ToDouble(row["Close"]);

  Tag_Serie_Candle.Add(dt, open, high, low, close);
}

UPDATE: As of 11th February 2014, the defect has been fixed. Anyone interested in testing the solution please let me know.

6
  • Still there is some problem to bind data. i am getting error like "Cannot bind to non-supported datasource: CandleTable" ... see the updated code and please help me...
    – Hari
    Commented Jan 13, 2014 at 12:59
  • @Hari which is the type of CandleTable? Can you please send us a simple example project, with a runtime created datasource, so that we can reproduce the problem here? You'll find an example on how to do that here: teechart.net/support/viewtopic.php?t=8206. You can post your files at www.steema.net/upload/. Thanks in advance. Commented Jan 13, 2014 at 13:48
  • Calvet : i was uploaded a code on "www.steema.net/upload/" so please see the code and inform me,where is i am wrong ..so, please help me to correct it
    – Hari
    Commented Feb 7, 2014 at 11:27
  • @Hari thanks for the example. Looks like this is a bug. I updated my reply with more info and a workaround suggestion. Commented Feb 10, 2014 at 12:45
  • @Hari this bug (bugs.teechart.net/show_bug.cgi?id=566) has just been fixed for the next maintenance release. In the meantime, if you are interested, I can provide a test assembly. Commented Feb 11, 2014 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.