logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
lwsr  
#1 Posted : Friday, July 2, 2021 4:18:12 PM(UTC)
lwsr

Rank: Newbie

Groups: Registered
Joined: 10/16/2020(UTC)
Posts: 1
United States

I have a plotly chart showing a simple scatterplot, I'd just like to add more info to the label on hover.
For simplicity, lets say I have columns for Date, Value, and Description. I'm plotting Date and Value as my x and y, but I'd like to have the Description display on hover ONLY (i.e. not using it as a splitter, axis, or plotted serie).
It was easy enough to customize the template to display hardcoded dummy "descriptions", but my C# isn't great and I just can't seem to actually access the Description column data without plotting it.

So is there a way to access a column in the model that isn't explicitly a serie and get it's values into something resembling the ChartYSerieValues string? Or alternatively, to make it a serie but not plot it?

Thanks!
epf  
#2 Posted : Monday, July 5, 2021 12:19:55 PM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 991
Switzerland

Thanks: 14 times
Was thanked: 170 time(s) in 164 post(s)
I made a report to handle your requirement...just to display the last name in the chart.
based on https://plotly.com/javas...ver-text-and-formatting/

In a custom template of the Plotly View, create a text values string that will be the list of label descriptions:
Code:
                        var textValues = "";
                        foreach (var xv in page.ChartXLabels.Split(',')) {
                            //find the row in the ResultTable
                            var desc = "";
                            foreach (System.Data.DataRow dr in reportModel.ResultTable.Rows) {
                                if (dr["C0"].ToString() == xv.Replace("'","")) {
                                    desc = dr["C1"].ToString();
                                    break;
                                }
                            }
                        
                            if (textValues.Length != 0)  { textValues += ","; }
                            textValues += Helper.QuoteSingle(System.Web.HttpUtility.JavaScriptStringEncode(desc));
                        }

Note that C0 or C1 are the columns defined in the model (View SQL from the model).


Then inject it in the chart:
Code:
                            marker: { color: @Raw(color) },
                            text: [@Raw(textValues)]
                        },
                        </text>


The full example is here: custom plotly label.srex (15kb) downloaded 1 time(s).

Edited by user Monday, July 5, 2021 12:22:15 PM(UTC)  | Reason: Not specified

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.