How to set month Column width in AnyGantt? - gantt-chart

Is it possible to change the width of month column in AnyGantt from AnyChart ?
This how my table look like
anychart.onDocumentReady(function() {
// create data tree on our data
var treeData = anychart.data.tree(getData(), anychart.enums.TreeFillingMethod.AS_TABLE);
// create resource gantt chart
chart = anychart.ganttResource();
// set container id for the chart
chart.container("container");
// set data for the chart
chart.data(treeData);
// set start splitter position settings
chart.splitterPosition(200);
// get chart data grid link to set column settings
var dataGrid = chart.dataGrid();
// initiate chart drawing
chart.draw();

Are you looking for zoom control?
chart.xScale().minimum(Date.UTC(2000, 1, 2));
chart.xScale().maximum(Date.UTC(2000, 3, 6));
// Set zoom to range.
chart.zoomTo("week", 2, "firstDate");
https://api.anychart.com/7.14.3/anychart.charts.Gantt#zoomTo
https://playground.anychart.com/api/7.14.3/charts/anychart.charts.Gantt.zoomTo_set_asInterval-plain
Also, there are:
https://api.anychart.com/7.14.3/anychart.charts.Gantt#fitAll
https://api.anychart.com/7.14.3/anychart.charts.Gantt#zoomIn
https://api.anychart.com/7.14.3/anychart.charts.Gantt#zoomOut

Related

Tabulator - Having Column Header Resize when Font Size Changes

I am using Tabulator and the default "fitData" function to size the cells. This works exactly as intended when I a) Have a default font size set and b) change the row font size using the rowFormatter:
rowFormatter:function(row){
var rowData = row.getData();
row.getElement().style.fontSize = config.body_font_size + "px";
The above works, however, when I want to change the font size of the column titles:
var curHeaders = document.getElementsByClassName("tabulator-col");
for (var i = 0; i < curHeaders.length; i++) {
curHeaders[i].style.fontSize = fontSize.toString() + "px";
}
This changes all the column font sizes, but does not resize the column width appropriately. Is there a different class where I should assigning the font? Is there a way to apply this in a similar way to the rowFormatter?
You shouldn't try and programatically alter elements inside Tabulator from outside the table. Because Tabulator uses a virtual DOM these changes can be overwritten at any point without notice.
If you need to format column header titles you should use a titleFormatter in the column definition for the column you want to change:
//define custom formatter
var customFormatter = function(cell, formatterParams, onRendered){
//set font size
cell.getElement().style.fontSize = fontSize.toString() + "px";
return cell.getValue();
}
//in the column definition for a column
{title:"Name", field:"name", titleFormatter:customFormatter },
Full documentation on how to use formatters can be found here: http://tabulator.info/docs/4.0/format
If you need to keep using your approach then you can call the table redraw function to force the table to be rebuilt:
table.redraw(true);
Is there a reason you need to change it at run time rather than just making the changes in CSS?

How To change Color in pie chart with the using of pykcharts library?

I Need 10 different Colors in Pie chart Using the Library of pykcharts.
Is it possible Because As per the Documentation they Provide only one shade_color.
Go through this link http://pykcharts.com/tour/pie
#Tkingovr chart_color is for all charts but One dimensional. You can use shade_color for One dimensional charts https://github.com/pykih/PykCharts.js/wiki/Colors#shade-color
#KIRANJOSHI
var selector = "pieContainer", // selector of your chart
colors = ["red","blue","green","yellow","orange"];
setTimeout(function() {
d3.selectAll("#" + selector + "_svg path.pie")
.attr("fill",function(d, i) {
return colors[i];
});
},1000);
setTimeout is required since the chart may take time to render and there is no provision in the current version to run a piece of code on chart render complete.
According to the documentation you should be able to pass in values like this:
{
"chart_color": ["blue","green","Yellow"]
}
The chart also accepts any of the following:
Color Names (Eg: "red")
Hex values (Eg: "#B0171F")
RGB values (Eg: "rgb(176,23,31)" )

Flot reset zoom

I'm using Flot Charts with mouse scroll to zoom in and out. I created a button to call zoomOut() and it works well, but I can't find any solution to how I can zoom out all the way so that it Looks just like when it was first loaded. I don't want to reload that who container because it using ajax to pull data from mysql on refresh.
I Googled but couldn't find anything.
You can also set a double click to reset the zoom function of the Flot chart. It redraws the Flot chart to its original state and can be used with dynamic data.
$("#placeholder").dblclick(function () {
plot = $.plot(placeholder, dataset, options);
});
You can set the ranges of the axes to null. By setting this, the zoom level will be set so every data point is visible, just like the default zoom level.
Unlike the other solutions, this solution will not construct a whole new plot.
var axes = plot.getAxes(),
xaxis = axes.xaxis.options,
yaxis = axes.yaxis.options;
xaxis.min = null;
xaxis.max = null;
yaxis.min = null;
yaxis.max = null;
// Don't forget to redraw the plot
plot.setupGrid();
plot.draw();
You can save your initial ranges of axes and redraw your plot like in example for navigating. But your code will be look like these:
// do the zooming
plotObjectPointer = $.plot(placeholder, plotData,
$.extend(true, {}, options, {
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to },
yaxis: { min: ranges.yaxis.from, max: ranges.yaxis.to }
}));
where ranges will be your initial ranges. To prevent repeated Ajax loading you can use window.localStorage or just another var for storing plotData.

Is there a way to hyperlink the slices in a pie chart of a sharepoint(google visualization) web part?

I am working with Microsoft Sharepoint and Google Analytics - Visualization integration.
Currently I have a pie chart. My question is whether there is a way to hyperlink the slices in the chart, so that they could be linked to a specific object and is there a way of organizing the legend in the format of biggest slice to the lowest?
Thanks.
If you're using the Google Chart tools library you can have Pie charts that are selectable.
All you have to do is listen for the select Event on the Pie Chart. Than use the getSelection() method from Pie Chart to get the selected row. Than you go back to your dataTable and get the data you want based on the selected row.
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Work', 11],
['Eat', 2],
['Commute', 2],
['Watch TV', 2],
['Sleep', 7]
]);
// Create and draw the visualization.
var chart = new google.visualization.PieChart(document.getElementById('visualization'))
chart.draw(data, {title:"So, how was your day?"});
google.visualization.events.addListener(chart, 'select', function(){
var row = chart.getSelection()[0].row;
var element = data.getValue(row, 0);
alert('You just selected: ' + element);
});
}
​
example:
http://savedbythegoog.appspot.com/?id=7b92cc41120837bc319a69144925122670167cd7
In my example I only alert the value selected. But you can use javascript to redirect the user to a different page:
window.location.href = 'http://www.example.com';

Fix Bar Chart Width and Spacing between bars in JFreeChart

I have stacked bar chart in which the number of columns is dynamic, can change from 1 to n columns. I want the spacing between the charts and width of the bar to be consistent. How do I fix it. Please suggest solutions / ideas.
In a Stacked Bar chart, you can change the spacing between bars using
CategoryAxis.setLowerMargin
CategoryAxis.setMargin and
CategoryAxis.setUpperMargin
Code is below
protected JFreeChart generateGraph() {
CategoryAxis categoryAxis = new CategoryAxis("Categories");
categoryAxis.setLowerMargin(.01);
categoryAxis.setCategoryMargin(.01);
categoryAxis.setUpperMargin(.01);
categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
ValueAxis valueAxis = new NumberAxis("Values");
StackedBarRenderer renderer = new StackedBarRenderer();
renderer.setBarPainter(new StandardBarPainter());
renderer.setDrawBarOutline(false);
renderer.setShadowVisible(false);
renderer.setBaseItemLabelsVisible(true);
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
CategoryPlot plot = new CategoryPlot( _dataset,
categoryAxis,
valueAxis,
renderer);
plot.setOrientation(PlotOrientation.VERTICAL);
JFreeChart chart = new JFreeChart( "Title",
JFreeChart.DEFAULT_TITLE_FONT,
plot,
true);
//ChartFactory.getChartTheme().apply(_chart);
return chart;
}
StackedBarRenderer devotes some effort to making the "spacing between the [bars] and width of the bar to be consistent." It's not clear what you want it to do differently as the number of columns changes. The relevant geometry is determined by the parent BarRenderer in such methods as calculateBarWidth(), which can be overridden as desired. Also, verify that there is a value for each category in each series.

Resources