I'm using the latest version of Chart.js and am trying to make the line chart fit run right up to the edge of the containing div but when I enable the yAxes ticks it adds a small padding to the right or in other words pushes the graph to the left.
How can I have tick labels and also have the chart extend to the edges of the <canvas />?
See screenshots:
You should be able to resolve some things like that by using the different callback hooks that are available in the update process.
Testing things out on my own, I was able get it to fix that gap by setting the right padding on the axis to 0 in the afterFit method, which based on the docs is:
Callback that runs after the scale fits to the canvas
const options = {
scales: {
xAxes: [{
afterFit: (axis) => {
axis.paddingRight = 0;
}
}]
}
}
Related
I am using a Column chart from the Google Visualization API, and have set up a "click" event for when I click on one of my columns as so:
google.visualization.events.addListener(chart, 'select', function(event) {
if (!isWebview) {
log.logInfo("Selected Sum");
$("#reportBody").trigger("app:update", { toXYZ: true});
} else {
}
});
However, this fires 4 times every time that I select a bar in the chart. This also happens to be the amount of rows that I have in the chart - could this be connected?
Thanks in advance.
Answer:
I found the problem - there were two. Firstly, the html file for this js file loaded the same js code twice - once for ios and once for android, but on the browser loads both, thus adding the same event listeners twice.
Furthermore, both these ways of setting the onLoad callback were used:
google.charts.load('visualization', '1', {
'packages': ['corechart', 'table'],
'callback': drawAll
});
and
google.setOnLoadCallback(drawAll);
The latter of which is a deprecated version if I'm not mistaken.
Therefore, the drawAll function, which creates the event listener, ended up being called 4 times, so I had 4 event listeners for the same event, all executing the same code.
I have to many points on my chart so when I am clicking through on mobile or small screen my tooltip just showing data from multiple points:
I researched on that and find out the the best approach would be is to disable the tooltip on small screens. I tried to follow this advice from the docs. But have no luck:
options: {
// This chart will not respond to mousemove, etc
events: ['click']
}
Also I found that but I think it is actually related to what I just did based on the advice form the docs.
Any ideas how to fix?
Tooltips can be disabled in the options as shown below (see Tooltip Configuration):
option:
tooltips: {
enabled: false
}
...
}
Instead of using a hard coded value false, you may obtain the value from a function that returns true or false depending on the screen size.
option:
tooltips: {
enabled: window.screen.width > 400
}
...
}
I've no experience in creating web apps for mobile devices. Therefore
400 is probably not the right choice. The following answer should help
finding the appropriate function: https://stackoverflow.com/a/11381730/2358409
I'm exploring the markAvailable property of this example.
I would like to add a transition while the ports color change.
So I changed the css as follow:
/* port styling */
.available-magnet{
fill: yellow;
transition: fill 0.5s;
}
.port circle{
transition: fill 0.5s;
}
But I still do not get any transition.
UPDATE
I created an example. It is clear that the problem is inside defaultLink property. In particular, removing the z attribute I get the right transition, but in this way I lost a fundamental property for my need, that is indeed to have all links with the lower z index.
The Example reported in the Update is correct.
In order to maintain each link on the back of other elements (that corresponds to set a z value equals to -1), Simply use the method link.toBack() each time a new link is created. In this way the transitions work.
Use -webkit-transition if you are in Chrome if you are in Mozilla use -moz-transition
I have a slider made with the jquerycycle2 plugin, but it seems to initiate after the content has loaded causing all the images/content in the slider to show at once on first load. I don't want to put a fixed height with overflow hidden because the site is responsive and the height will vary. Any idea for a fix for this? Ideally I'd like to fade it in on load. You can see it here:
.slideshow div {
display: none;
}
.slideshow div:first-child {
display: block;
}
This hides all but the first slide when the page first loads, and prevents the flash of content showing all slides before the jQuery kicks in.
Create a standard App with ribbon, then add this to the CMainFrame::InitializeRibbon() at the appropriate place.
// Create panel
CMFCRibbonPanel* pMyPanel = pCategory->AddPanel(L"Test", m_PanelImages.ExtractIcon(27));
// Add wide combobox with short label to panel
m_pMyCombo = new CMFCRibbonComboBox(ID_MYCOMBO, false, 150, L"Short:");
m_pMyCombo->AddItem(L"Just some test data");
pMyPanel->Add(m_pMyCombo);
// Add narrow edit with longer label to panel.
CMFCRibbonEdit* pMyEdit = new CMFCRibbonEdit(ID_MYEDIT, 50, L"Longer label:");
pMyPanel->Add(pMyEdit);
Issue 1:
The combobox "sticks" to the top of the panel.
The edit control "sticks" to the combobox.
There is about 1/3 of the height unused.
Is there a way to make these 2 controls use the full height ? I can use pMyPanel->SetCenterColumnVert(); But the 2 controls are still stuck together although they're now vertically centered. What I'm really after is that there is more or less even spacing above and below the controls.
Issue 2:
this looks like
Short: [______________________|v]
Longer label: [___]
which isn't really looking nice.
I can call SetJustifyColums() but this results in
Short: [______________________|v]
Longer label: [___]
which may seem OK enough, but if the length of the labels reverses it gives:
Longer label: [______________________|v]
Short: [___]
which isn't really looking OK.
I'd really like to get this to like you'd normally make a dialog. Labels left aligned and controls left aligned also.
Short: [______________________|v]
Longer label: [___]
How can these issues be solved?