I am using MS Chart control to draw graphs on Winform.
I want to show the current (x,y) Value as tooltip on Mousedown on chartarea.
How do I do that?
From the chart samples (Samples Environments for Microsoft Chart Controls)
// Set ToolTips for Data Point Series
chart1.Series[0].ToolTip = "Percent: #PERCENT";
// Set ToolTips for legend items
chart1.Series[0].LegendToolTip = "Income in #LABEL is #VAL million";
// Set ToolTips for the Data Point labels
chart1.Series[0].LabelToolTip = "#PERCENT";
// Set ToolTips for second Data Point
chart1.Series[0].Points[1].ToolTip = "Unknown";
This tooltip will appear on mouseover. I'm not sure if you can set it for mousedown event.
Chart1.Series["Series1"].ToolTip = "#VALY, #VALX";
If you want to show tooltips with maximum and minimum values in Range type charts, the following code can be used.
Chart1.Series["Series1"].ToolTip = "Min:#VALY1, Max:#VALY2";
Related
I have this AmCharts4 radar chart in my react application is there any way to disable the click-drag zooming?
Thx.
Image of the chart
Assuming you're referring to the zoom from the chart cursor, you have to set the cursor object's behavior to "none":
chart.cursor = new am4charts.RadarCursor();
chart.cursor.behavior = "none";
You can find a list of valid properties in the linked documentation and in this tutorial.
I have a react app that uses ChartJS through 'npm react-chartjs-2'.
I am working with a Line chart and I a have the following requirements:
1- Detect clicking on chart area (white area; other than data set line, and legend), then do some logic
2- Detect clicking on legend rectangle at the top to hide/show the dataset (current default behaviour)
I have tried using options.onClick but it seems to override legend click.
Also tried getElementAtEvent it returns the dataset clicked on but when clicking on legend/chart area comes as empty. getDatasetAtEvent always return empty array. And if I use options.legend.onClick I loose default hide/show behaviour and need to do it programmatically.
I was wondering is there is a better way to achieve requirements above. Thanks
You can use the getElementsAtEvent property. This gives value only when the chart area is clicked, the element is null if it is clicked on the legend. If it is clicked on the chart area then it holds properties from which we can get the clicked xAxis and legend value.
document.getElementById("yourChartCanvasId").addEventListener("click", function (e) {
var element = instance.getElementsAtEvent(e)[0];
if (element) {
//Handle click on chart area
}
else {
//Handle click on legend area
}
});
Also if you don't want to do anything on legend click, keeping the default Chart.js behavior then don't include the else block.
The chartjs feature to show/hide a dataset by clicking on the legend is really nice. Is it possible to achieve the same but clicking on for instance a checkbox outside the chart canvas?
This should do the trick
chart.data.datasets.forEach(function(e) {
e.hidden = true;
});
I am using AnyMap and my client wants to display some information in the legend for unbound regions.
Because I can just add a legend item for a series I am implementing an empty series and then adding a legend item on this. However as there is no country to select I do not want my legend item to be selectable. How can I prevent this?
The only solution I found for this is applying "disabled:true" to my legendItem, but then the color changes..
This is how my code looks so far
var unboundRegions = anyMap.choropleth();
unboundRegions.legendItem({text: data.unbound, iconType: "square", iconFill: '#ffffff', iconStroke: '#e8e8e9', disabled: true});
Any ideas?
You can prevent legend icon selection using "legendItemMouseDown" legend event listener - just prevent its default behavior using e.preventDefault();
jsfiddle example
I have a grid and i am trying to autosize its columns after getting data, using autosize() method of sencha. This grid's parent has border layout. autosize() method is not working for in this case.so I tried setting column size using html content.
var el = gridObj.el.dom.childNodes[me.el.dom.childElementCount - 1].childNodes[0];
if(el.childNodes.length > 0){
el = el.childNodes[el.childElementCount-1];
if(el.childNodes.length > 0){
var trows =el.childNodes[el.childElementCount - 1].childNodes;
this code gave me html 'tr's. looping on them i got some width of column and I set them to respective columns of grid. but i am unable set the sum of those column widths to the grid. this is only case if, parent of grid has border layout or fit layout. For these layouts, i have tried to set grid body width( gridObj.el.setWidth(400)),it worked fine, but i am not able to set width to header and top/bottom toolbar in the same way.
can any one help me in resizing columns for these layouts either seeting width to grid or setting width to all(grid header/toolbar/body)?