2

I have a Highchart basic bar graph that I want to edit the tooltip for.

Basically as it stands when I hover over the bars it gives me the percentage values that I coded in (in the seriesData)

What I want is to be able to use a Count as well. I've seen the

.SetToolTip(new Tooltip {
    Shared = true,
    Formatter = @"function() { return this.whatever; }
}

possibly used to this effect, but I don't know what this refers to, or how to plug in my own variables from C# code.

5
  • 2
    I don't know anything about C#, or .NET, but in javascript I would console.log(this) to dump the contents of this and see what it had access to. Commented Jul 20, 2016 at 12:44
  • Are you looking to get the combined total of all of the percentages in your bars? If so, I have code for this. Commented Jul 20, 2016 at 13:01
  • @jlbriggs tried that in the inline javascript to no avail. Commented Jul 20, 2016 at 17:13
  • @MikeZavarello no i'm trying to get the raw c# data included in the tooltip but can't seem to manage it. head is hurting now so i'll revisit in the morning lol Commented Jul 20, 2016 at 17:14
  • if you set your config up in a jsfiddle, (or anywhere that you can edit the javascript and view it in a browser), you can console.log(this) and view its contents. Then you can go back to your C# and code the proper path to reach the data that you need. Commented Jul 20, 2016 at 19:28

1 Answer 1

1
Formatter = { headerFormat = "<b>{series.name} </b> <br>", pointFormat = "<b>{point.y:,.0f}%</b>" }

You need to add properties that are needed inside your formatter. headerFormat is use mostly for the title of your widget(eg. Drug name, City etc.) pointFormat this will be the return string/number upon hovering specific widget. Please see the sample here.

Sign up to request clarification or add additional context in comments.

4 Comments

this is a sample if you are using series in your highcahrt. pass both series name and point.y value, you can also add an calculation inside formatter. hope this help
Welcome to Stack Overflow! While this code snippet may solve the question, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. Please also try not to crowd your code with explanatory comments, as this reduces the readability of both the code and the explanations!
Will do it next time. thanks by the way @FrankerZ :)
Why next time @JJG? Only takes a few minutes to edit your post and give a nice solid answer. Plus: You'll earn a solid 10 rep from me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.