This is a migrated thread and some comments may be shown as answers.

RadChartView not show legend when exported to image

3 Answers 27 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
zake
Top achievements
Rank 1
zake asked on 02 Nov 2018, 09:21 AM

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>        }

3 Answers, 1 is accepted

Sort by
0
zake
Top achievements
Rank 1
answered on 02 Nov 2018, 09:31 AM
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();
            }
        }
0
Dimitar
Telerik team
answered on 02 Nov 2018, 10:35 AM
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.
0
zake
Top achievements
Rank 1
answered on 06 Nov 2018, 03:05 AM

yeah, it's done.

thank a lot dimitar. 

Tags
ChartView
Asked by
zake
Top achievements
Rank 1
Answers by
zake
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or