RadChartView not show legend when exported to image

4 posts, 0 answers
  1. zake
    zake avatar
    17 posts
    Member since:
    Nov 2018

    Posted 02 Nov 2018 Link to this post

    Hi,,,

     

    I am using Telerik Q1 2015, i just want to export chart view into image but legend not showing event I set show legend is true.

    please help me, bellow is my code

    private RadChartView radChartView1;<br><br>        public Form1()<br>        {<br>            InitializeComponent();<br><br>            this.radChartView1 = new RadChartView();<br>            LoadData();<br><br>            this.radChartView1.ShowLegend = true;<br>            this.radChartView1.ChartElement.LegendElement.LegendTitle = "Expenses";<br>            this.radChartView1.ShowTitle = true;<br>            this.radChartView1.Title = "Personal monthly expenses";<br>            <br><br>            //this.Controls.Add(this.radChartView1);<br>        }<br><br>        private void radButton1_Click(object sender, EventArgs e)<br>        {<br>            Application.DoEvents();<br>            this.radChartView1.ExportToImage(@"C:\Users\syahr\Documents\Visual Studio 2010\Projects\TesTelerik\OutputTes\sopp.png", new Size(1871, 1086), ImageFormat.Png);<br>            <br>            RadMessageBox.Show("ok");        <br>        }<br><br>        private void LoadData()<br>        {<br>            LineSeries lineSeries;<br>            LineSeriesDataModel model = new LineSeriesDataModel();<br><br>            for (int i = 0; i < 11; i++)<br>            {<br>                lineSeries = new LineSeries();<br>                lineSeries.CategoryMember = "Month";<br>                lineSeries.ValueMember = "Expense";<br>                lineSeries.LegendTitle = model.GetLegendText(i);<br>                lineSeries.DataSource = model.GetData(i);<br>                lineSeries.PointSize = new SizeF(3f, 3f);<br>                lineSeries.BorderColor = Color.Blue;<br>                lineSeries.IsVisibleInLegend = true;<br><br>                this.radChartView1.Series.Add(lineSeries);<br>                Application.DoEvents();<br>            }<br>        }
  2. zake
    zake avatar
    17 posts
    Member since:
    Nov 2018

    Posted 02 Nov 2018 in reply to zake Link to this post

    private RadChartView radChartView1;
     
            public Form1()
            {
                InitializeComponent();
     
                 
     
                //this.Controls.Add(this.radChartView1);
            }
     
            private void radButton1_Click(object sender, EventArgs e)
            {
                this.radChartView1 = new RadChartView();
                LoadData();
     
                this.radChartView1.ShowLegend = true;
                this.radChartView1.ChartElement.LegendElement.LegendTitle = "Expenses";
                this.radChartView1.ShowTitle = true;
                this.radChartView1.Title = "Personal monthly expenses";
     
                Application.DoEvents();
                this.radChartView1.ExportToImage(@"C:\Users\syahr\Documents\Visual Studio 2010\Projects\TesTelerik\OutputTes\sopp.png", new Size(1871, 1086), ImageFormat.Png);
                 
                RadMessageBox.Show("ok");       
            }
     
            private void LoadData()
            {
                LineSeries lineSeries;
                LineSeriesDataModel model = new LineSeriesDataModel();
     
                for (int i = 0; i < 11; i++)
                {
                    lineSeries = new LineSeries();
                    lineSeries.CategoryMember = "Month";
                    lineSeries.ValueMember = "Expense";
                    lineSeries.LegendTitle = model.GetLegendText(i);
                    lineSeries.DataSource = model.GetData(i);
                    lineSeries.PointSize = new SizeF(3f, 3f);
                    lineSeries.BorderColor = Color.Blue;
                    lineSeries.IsVisibleInLegend = true;
     
                    this.radChartView1.Series.Add(lineSeries);
                    Application.DoEvents();
                }
            }
  3. Dimitar
    Admin
    Dimitar avatar
    2881 posts

    Posted 02 Nov 2018 Link to this post

    Hi Zake,

    Could you please try adding the following code:
    radChartView1.BindingContext = new BindingContext();
    LoadData();
    radChartView1.LoadElementTree();           
    Application.DoEvents();
    this.radChartView1.ExportToImage(@"d:\sopp.png", new Size(1871, 1086), ImageFormat.Png);

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Progress Telerik
    Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  4. zake
    zake avatar
    17 posts
    Member since:
    Nov 2018

    Posted 05 Nov 2018 in reply to Dimitar Link to this post

    yeah, it's done.

    thank a lot dimitar. 

Back to Top