How to set a legend item for unbound regions? - anychart

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

Related

How can i change a color of button thats inside a map function without changing all the buttons color in react?

here is the image of my codeI'm building a Twitter like app and i'm trying to build the 'Like' menu at the bottom of every tweet.
at the moment the 'Like' is a button and i want to change it's color once pressed.
the obvious problem is that all the other tweets 'likes' buttons are changing too..
i've tried everything i can using useState hooks and nothing worked..
any ideas?
What I would do is, I would store the liked info inside the item. So when you add like, you can change item.liked = true or item.liked = false
And once you do that you can style based on the item's liked field:
<button style={{backgroundColor: item.liked ? 'red' : ''}} ...

How to zoom into a series group by pressing on legend option in echarts

So I created a bar chart using echarts(v4.6.0) library inside Reactjs project. It has legend, data series chunked into groups with same colour and dataZoom slider. Every legend label corresponds to particular group of bars in the graph(they have same colours). However at the moment if user clicks on legend label, bars that correspond to this label disappears. What I want to achieve is when user clicks on legend label, the chart needs to zoom in to the group of bars that correspond to it instead of hiding them. Is there any way to do this?
In the common practice to make bar selected you can use the emphasis, it's style set activated by mouseover (something like rules declaration under :hover in CSS), for example (see tutorial):
itemStyle: {
// default styles
normal: {
shadowBlur: 200,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
// activated by mouseover
emphasis: {
shadowBlur: 200,
shadowColor: 'rgba(0, 0, 0, 0.8)'
}
}
If you need just to show bar in focus, it's easy:
Define emphasis styles.
Capture event legendselectchanged on legend component and suppress default behavior (see workaround) for prevent series disappear.
Dispatch highlight action for series or dataIndex and bar will be looks like selected.
I could be wrong, but as far as I know to zoom single (and stacked) bar it's not easy task. There are several unconventional ways like a draw resized bar clone above original, manipulations with datazoom component and recalculate/update bar data on mouseover and then return back old data on mouseout. Let me know if you choose one of these options I'm will try to help you.

ChartJS distinguish clicks between chart area, dataset and legend

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.

chartjs - show hide specific dataset with click on element outside graph

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;
});

ExtJs Border Around Control Box Only, Not Label

I have an EXTJS TimePicker control. I want to add a border around the picker box itself, not the label or overall panel just the box when the user clicks in the field. I have the follow code the provides a partial solution. It used to work when the label was to the left of the control. Once I moved the label to the top I get the incorrect behavior:
function txtTimeCtr_Focus(sender, event, eOpts )
{
//Change the border color to red to show the time is no longer running
sender.getPicker().pickerField.getEl().addCls('txtTime-focus-border');
//sender.getEl().addCls('txtTime-focus-border');
}
Here is a screen shot of what I am currently receiving
:
This is the functionality I need to obtain:
Thanks in advance everyone.
You need to set the style on the triggerWrap:
var f = new Ext.form.field.ComboBox({
renderTo: document.body
});
f.triggerWrap.setStyle('border', '1px solid red');

Resources