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. Image for the cookie policy date

text for series

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

5 Replies

MC Mohan Chandran Syncfusion Team August 29, 2017 09:36 AM UTC

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. 



MJ Miranda Johnson August 29, 2017 11:13 PM UTC

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


MC Mohan Chandran Syncfusion Team August 30, 2017 10:36 AM UTC

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. 



MJ Miranda Johnson August 30, 2017 09:11 PM UTC

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;

}

                    





MC Mohan Chandran Syncfusion Team August 31, 2017 05:12 AM UTC

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. 


Loader.
Up arrow icon