NVD3, Clear svg before loading new chart
You can select all the elements below the SVG with the “svg > *” selector, i.e. to remove all of those, do d3.selectAll(“svg > *”).remove();
You can select all the elements below the SVG with the “svg > *” selector, i.e. to remove all of those, do d3.selectAll(“svg > *”).remove();
I’ve done this with kind of a brute force method. First, figure out the maximum number of tick marks you can fit into the space. Divide the total range of values by the number of ticks; this is the minimum spacing of the tick. Now calculate the floor of the logarithm base 10 to get … Read more
You can use the chart controls in two ways: Generating the Image from a Controller By generating the chart and returning it as an image from an action (as Chatuman is referring to I think): Chart chart = new Chart(); chart.BackColor = Color.Transparent; chart.Width = Unit.Pixel(250); chart.Height = Unit.Pixel(100); Series series1 = new Series(“Series1”); series1.ChartArea … Read more
The width and height property that you set for the canvas only work if the Chartjs’ responsive mode is false (which is true by default). Change your stats_tab.js to this and it will work. window.onload=function(){ var ctx = document.getElementById(“myChart”).getContext(“2d”); var myChart = new Chart(ctx, { type: ‘line’, data: { labels: [1,2,3,4,5,6,7,8,9,10], datasets: [ { label: … Read more
Google Charts is an excellent choice if you don’t want to use Flash. It’s pretty easy to use on its own, but for Rails, it’s even easier with the gchartrb gem. An example: GoogleChart::PieChart.new(‘320×200’, “Things I Like To Eat”, false) do |pc| pc.data “Broccoli”, 30 pc.data “Pizza”, 20 pc.data “PB&J”, 40 pc.data “Turnips”, 10 puts … Read more
I handled it this way in new version: new Chart(ctx, { type: ‘bar’, data: chartData, options: { scales: { yAxes: [{ ticks: { beginAtZero: true, callback: function(value) {if (value % 1 === 0) {return value;}} } }] } } });
Update: As @Soham Shetty comments, getSegmentsAtEvent(event) only works for 1.x and for 2.x getElementsAtEvent should be used. .getElementsAtEvent(e) Looks for the element under the event point, then returns all elements at the same data index. This is used internally for ‘label’ mode highlighting. Calling getElementsAtEvent(event) on your Chart instance passing an argument of an event, … Read more
Just add xAxis: { … lineWidth: 0, minorGridLineWidth: 0, lineColor: ‘transparent’, … labels: { enabled: false }, minorTickLength: 0, tickLength: 0 } to the xAxis definition. Since Version 4.1.9 you can simply use the axis attribute visible: xAxis: { visible: false, }
UPDATE chart.js 2.1 and above var chart = new Chart(ctx, { … options:{ scales:{ xAxes: [{ display: false //this will remove all the x-axis grid lines }] } } }); var chart = new Chart(ctx, { … options: { scales: { xAxes: [{ ticks: { display: false //this will remove only the label } }] … Read more
Do you mean something like this: >>> from matplotlib import * >>> plot(xrange(10)) >>> yticks(xrange(10), rotation=’vertical’) ? In general, to show any text in matplotlib with a vertical orientation, you can add the keyword rotation=’vertical’. For further options, you can look at help(matplotlib.pyplot.text) The yticks function plots the ticks on the y axis; I am … Read more