We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

text for series

Thread ID:

Created:

Updated:

Platform:

Replies:

132363 Aug 28,2017 03:04 PM Aug 31,2017 01:12 AM ASP.NET MVC 5
loading
Tags: XlsIO
Miranda Johnson
Asked On August 28, 2017 03:04 PM

I am creating charts and instead of having it say series 1, series 2, series 3, series 4, etc. in the legend how do I get the actual value from the query in there?

This is dynamic data (meaning the values in there for my development will NOT be the same as the values when it is live) so to code at design time is not an option.

How do I get it to be like the chart shown in the image?  both with the value showing and the legend actually showing the text instead of a series#?

Attachment: Q4example_e85be164.zip

Mohan Chandran [Syncfusion]
Replied On August 29, 2017 05:36 AM

Hi Miranda, 
 
Please refer the following table for your queries. 
 
               Query 
                                                                   Answer 
I am creating charts and instead of having it say series 1, series 2, series 3, series 4, etc. in the legend how do I get the actual value from the query in there? 
While creating the chart , the data range should include the series names. Otherwise, the chart will show default series names. You can set the includeheader  parameter value as true  in the importData method to give series names for the data . 
 
Code Snippet: 
worksheet.ImportData(customers, 3, 1, true); 
 
How do I get  the chart with the value showing? 
You can use IChartDataLabels.IsValue property to show the series values in the chart. Please refer the following code sample for the same. 
Code Snippet: 
serie.DataPoints.DefaultDataPoint.DataLabels.IsValue = true; 
 
We have prepared a sample to achieve your requirement which can be downloaded from the following link. 
 
 
Regards, 
Mohan Chandran. 


Miranda Johnson
Replied On August 29, 2017 07:13 PM

It displays names but instead of the name of the column, it is displaying the name of the parameters in my method.    Is there a way around this?

I have included the methods for data access in the DAL.cs file, my stored procedure in the databaseProcedures.sql file, the results of the procedure (PivotedDemographicGroupAverage) used in the PivotedDemographics method as "results of  query.xlsx", the controller code,  and a copy of the latest excel file generated by the PivotedDemographics method


Attachment: MYFILES_ebb73b0.ZIP

Mohan Chandran [Syncfusion]
Replied On August 30, 2017 06:36 AM

Hi Miranda, 
 
While using importData method property names will be considered as headers for the data. So, either you have to change the property names or you can set the headers by giving cell’s value . We have shared a sample to achieve your requirement which can be downloaded from the following link. 
 
 
Please let us know if you have any other queries. 
 
Regards, 
Mohan Chandran. 


Miranda Johnson
Replied On August 30, 2017 05:11 PM

Thank you with a bit of modification I was able to use your code.  

My solution 

Since these are dynamic I needed something that would fill them in at run time instead of design time.  So what I did was create a list with the values and then did a foreach loop to populate the text for the legend.


GetDemographicResponses gdr = new GetDemographicResponses();

gdr.Demographic = Demographic;

List<GetDemographicResponses_Result> DR = gdr.DemographicResponses();

int z = 1;


Then whenever I am displaying a chart and I want the legend to display the actual value I did the following.


sheet0[3, 1].Text = "Questions";

foreach(var x in DR)

{

sheet0[3, (z + x.Sequence)].Text = x.ResponseText;

}

                    




Mohan Chandran [Syncfusion]
Replied On August 31, 2017 01:12 AM

Hi Miranda, 
 
We are glad that the issue is resolved at you end. Please let us know if you have any other queries. 
 
Regards, 
Mohan Chandran. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;