Force replot of Windows Forms DataVisualization Chart - windows

When you use a DataVisualization Chart object and you add points to it, the graph is automatically updated but when you change the points the chart is not updated. For example:
System.Windows.Forms.DataVisualization.Charting.Chart myChart;
// When you add points, the chart is automatically redrawn.
myChart.Series[0].Points.AddXY(0,0);
myChart.Series[0].Points.AddXY(1,1);
myChart.Series[0].Points.AddXY(2,0);
// When I change the value of points, the chart is not automatically redrawn.
myChart.Series[0].Points[0].SetValueXY(0,1);
How can I force a redraw of the chart? Something like myChart.Update() or something. As a workaround I'm deleting the last point and re-adding it at each update to force a redraw, but I would like something a little bit more elegant.:
// Re-add last point to force redraw.
myChart.Series[0].Points.RemoveAt(2);
myChart.Series[0].Points.AddXY(2,0);

Related

How to make a tooltip for a chart in d3?

We need to make it move like here.example The code is complex there, I can't figure it out.
I wrote the code my code, but I don’t understand how to make the tooltip move horizontally not behind the mouse, but near the nearest horizontal mark (as in the example)
It is not yet clear where the text above the bold text in the tooltip comes from. How to remove it so that it looks like in the picture?
How do I make the title of the tooltip match the label on the X-axis?
There are many ways to accomplish this. The way I typically do this is to create a series of SVG elements -- such as circles or rects -- using the same scale and data as the paths.
You can make these objects visible or invisible. Either way, you can attach mouseenter, mouseleave events to each to render and populate the tooltip.

Update multiple brushes when zooming

New to D3 here. I am attempting to combine brush and zoom(ex1) with multiple brushes(ex2).
The idea is that the user will be able to create multiple brushes on top of Ex1's focus chart to make annotations on the data. Which I am able to do. However, I am only able to update one(the first) annotation brush position on the chart after zooming using this on ex2's zoomed function:
.select("#brush-0").call(brushes[0].brush.move, lastSelection.map(t.applyX, t));
Where t is the zoom transform and lastSelection is the selection from the last brush that was created. Very hacky, I know, but at least behaves as expected.
I would like to be able to update all the brushes that are stored in the brushes array after zooming and panning in a way that can be called from the zoomed function. Help!
EDIT:
I have recreated the issue with my (flawed) solution attempt here: jsfiddle.net/0pk8wce9/1

How to remove a series from XYChartScrollbar in amCharts v4?

How can a series be removed from the XYChartScrollbar in amCharts v4?
It was added in much the same way as series are added to the chart:
chart.scrollbarX = new am4charts.XYChartScrollbar();
chart.scrollbarX.series.push(series);
Removing it seems to remove it from the List (chart.scrollbarX.series.length goes from 1 to 0) but it remains on the scrollbar display. I've also tried removeIndex, but no luck there either.
// removes from List, but still displayed
var scrollbarIndex = chart.scrollbarX.series.indexOf(series);
chart.scrollbarX.series.removeIndex(scrollbarIndex);
// same result, removed from List but still displayed
chart.scrollbarX.series.removeValue(series);
I have also tried calling invalidate() and even deepInvalidate() to try to get the scrollbar to refresh but no success.
An example pen is at https://codepen.io/anon/pen/OrQvbw?editors=0011. Clicking on a toggle button adds the series to the chart and scrollbar, but only removes it from the chart.
Removing a series from the scrollbar itself does not seem to remove the series from the scrollbar's chart which itself is a whole other chart with distinct series. Going to look into this more and get back to you.
In the meantime, we can piggy back off of the scrollbar's removeValue method via the series' List's "removed" event, to do the same thing on scrollbarChart. The scrollbarChart's series are all clones of the original chart's series, presuming a series only ever has 1 clone and that that clone is within scrollbarChart, this code seems to do the trick (removed.oldValue is the series we just removed from scrollbarX.series):
chart.scrollbarX.series.events.on("removed", function(removed){
chart.scrollbarX.scrollbarChart.series.removeValue(removed.oldValue.clones.getIndex(0));
});
Here's a fork of your demo with that addition:
https://codepen.io/team/amcharts/pen/1b623a1b4ddf6a198bc80bdf5f5e1514

CanvasJS - Dynamic chart without setInteval()

Here is the original example code :
http://canvasjs.com/html5-javascript-dynamic-chart/
I need to update the value without setInterval(), I mean whenever the yAxis got a value somewhere, then it will plot automatically without time delay. One more thing, I dont’t want to shift the graph while the value reach datalength, when it reach the maximum datalength, clear all the old plotted data, go back to 0 point and plot again.
Thank you for your support !
canvasjs
Gia Huy,
You can remove dps.shift from the example to avoid shifting. Check this example.
And you can remove setInterval to avoid update of charge based on time-basis and you can manually push y-value to dataPoints and render chart whenever you get y-value.
setInterval(function(){updateChart()}, updateInterval);
Remove setInterval and push y-Value to dataPoints when you encounter it.
dps.push({y: yValue});
chart.render();
and render the chart.

Google Visualization - Annotated timeline legend

I have an annotated timeline chart that gets new data over ajax. It's working fine, new points come in and I redraw the graph. My graph has two lines, so there are two labels in the legend on top. For whatever stupid reason, every single time the graph is redrawn, the legend labels swap places! So it will say
• Foo 5.2 • Bar 3.6
And then I'll refresh (and there will be no new data, so the call to redraw is 100% identical to the previous one) and now it says
• Bar 3.6 • Foo 5.2
In the respective red and blue, of course. What on earth would possess the applet to do this? Is there any way I can control the order of legend labels? I couldn't find anything about it in the official documentation.
Try using google.visualization.DataTable. For example:
dataTable = new google.visualization.DataTable({cols:graphColumns, rows:graphRows});
chart = new google.visualization.AnnotatedTimeLine($('#chart_div')[0]);
chart.draw(dataTable)
I use it this way and don't have any problems with my legend values.

Resources