I am new to ItextSharp Coding, where I have created a list
using the code
Dim li = New List(12)
li.ListSymbol = New Chunk(ChrW(&H2022), HeaderFont)
li.Add(New ListItem("Item 1", DefaultFont))
li.Add(New ListItem("Item 2", DefaultFont))
li.Add(New ListItem("Item 3", DefaultFont))
li.Add(New ListItem("Item 4", DefaultFont))
li.Add(New ListItem("Item 5", DefaultFont))
li.Add(New ListItem("Item 6", DefaultFont))
p1 = New Paragraph("", DefaultFont)
p1.IndentationLeft = 50
p1.SpacingBefore = 5
p1.Add(li)
myDocument.Add(p1)
DefaultFont and HeaderFont are delcared earlier for styling purpose.
So just wanted to know is there a way I can add vertical Spacing between the listed items (Need to add extra space between listed items) using above piece of code..?
Please take a look at the ListWithLeading example.
In this example, I first create a list the way you did:
List list1 = new List(12);
list1.setListSymbol("\u2022");
list1.add(new ListItem("Value 1", font));
list1.add(new ListItem("Value 2", font));
list1.add(new ListItem("Value 3", font));
document.add(list1);
Note that I add the list directly to the document, I don't see any reason why you would wrap it inside a Paragraph.
I then create a list the way you want it to be created:
List list2 = new List(12);
list2.setListSymbol("\u2022");
list2.add(new ListItem(30, "Value 1", font));
list2.add(new ListItem(30, "Value 2", font));
list2.add(new ListItem(30, "Value 3", font));
list2.setIndentationLeft(60);
document.add(list2);
Note that I define the left indentation using the setIndentationLeft() method (in C#, this is probably somethink like list2.IndentationLeft = 60;) and I change the leading of the ListItem objects from the default (which is 1.5 times the font size) to 30.
Note that the distance between the baselines of two consecutive lines is called the leading in PDF terminology. You can define this leading at the level of the ListItem.
I'm using itext 7 and I change the space between items with ListItem bottom margin.
In my case I wanted the items closer I do this:
listItem.SetMarginBottom(-5);
Related
I'm building a new grid but i need a select field that options appear depending on the choice of the first field.
I have two cellEditors
columnDefs = [
{ field: 'typePizza', editable:true, cellEditor:'pizza'},
{ field: 'toppings', editable: true, cellEditor: 'gridSelect' }
];
The 'pizza' one is a select that i choose a type of pizza, the gridSelect have a multiple select that i can choose one or more ingredients but I need to show the options that are affected by the type of pizza.
I have this toppingList on gridSelectComponent: toppingList: string[] = ['Extra cheese', 'Mushroom', 'Onion', 'Pepperoni', 'Sausage', 'Tomato'];
And PizzaList on PizzaComponent pizzaList: string[] = ['Pizza A','Pizza B', 'Pizza C'];
For example, if i choose Pizza A i want that on that row only appear the options 'Extra Cheese, Onion' options.
If i choose Pizza B only appear the options 'Mushroom, Tomato'
Stackblitz
How can i do this?
Thank you
On your mat-select, upon the event of the dropdown being expanded, call a method in your class:
(openedChange)="matOpenedChanged($event)"
In this method, see what the value of the typePizza field is and set your dropdown list appropriately:
matOpenedChanged(event) {
const currentPizzaType = this.params.data.typePizza;
if (currentPizzaType == 'Pizza A') {
this.toppingList = ['Extra cheese', 'Onion'];
} else if (currentPizzaType == 'Pizza B') {
this.toppingList = ['Mushroom', 'Tomato'];
} else {
this.toppingList = [
'Extra cheese',
'Mushroom',
'Onion',
'Pepperoni',
'Sausage',
'Tomato'
];
}
}
Demo.
I just started working with Leaflet. I want to create a map for a game, so this is a map created with L.CRS.Simple.
I have been able to set the map image, and add marker manually.
Now, I want to create markers and layers groups dynamicly from a json file that I generate in PHP from a sqlite database.
My json is this one for now : https://grounded.dubebenjamin.com/api/markers.json
My json is a list of type(layergroup) inside which I have put another object containing all the markers for the type(layergroup) :
Structure :
{
"landmarks": {
"id": 1,
"slug": "landmark",
"type": "Landmarks",
"markers": [
{"id": 1, "title": "Title of marker 1 of layergroup1"},
{"id": 2, "title": "Title of marker 2 of layergroup1"}
]
},
"science": {
"id": 2,
"slug": "science",
"type": "Science Points",
"markers": [
{"id": 1, "title": "Title of marker 1 of layergroup2"}
]
}
}
= Where landmarks and science are layergroup.
From this json, my plan was to have a first loop, where for each type I want to create a layer group, then create the markers for this layer group and assign the markers to the layer groups.
Manually, I understand the usage of L.marker and L.layerGroup, but where I am stuck, is how to do that in a loop, and defined the layoutgroup name from the json data.
From now, I have just been able to create the marker, but not the layer group. You can see my progress here: https://grounded.dubebenjamin.com/
If you need more precision, just ask me.
Use this code:
var layergroups = {};
fetch('https://grounded.dubebenjamin.com/api/markers.json').then(response => response.json())
.then((data)=>{
layergroups = {};
for(type in data){
var lg = L.layerGroup().addTo(map)
layergroups[type] = lg;
if(data[type].markers){
var markers = data[type].markers;
markers.forEach((marker)=>{
L.marker([marker.x,marker.y]).bindPopup(marker.desc).addTo(lg);
})
}
}
})
First fetch the data from the server, then loop through the layergroups and add them to the map and then to the Object/Array.
Then you create the markers and add them to the layergroup.
You can get the layergroups over the Object layergroups but keep in mind that the request is async.
I have tried adding buttons to HBox and FlexBox dynamically
In the XML view i have did as below:
<HBox id="upperchart">
<m:Input value=" Key Code " editable='false' width='360px'/>
</m:HBox>
<FlexBox
alignItems="Start" id="lowerchart">
<FlexBox>
In the controller I tried accessing these with the ID's as
Controller:
var lowerHBox = this.getView().byId("lowerchart");
var upperHBox = this.getView().byId('upperchart');
var oHBox = new sap.m.HBox();
oHBox.addItem(new sap.m.Input({
value: "Test Data",
editable: false,
width: graphWidth*10 + 'px'
}));
upperHBox.addItem(oHBox);
var oMyFlexbox = new sap.m.FlexBox();
// I am adding Buttons to HBox dynamically
for (var i = 0; i < 5.length; i++){
oMyFlexbox.addItem(new sap.m.Button({
text: "Button",
width: allWidths[i]*10 + 'px'
}));
}
lowerHBox.addItem(oMyFlexbox);
Here the thing is When i just navigate through the page it gets created multiple times.
so i have tried to remove on first and add as again under this as:
lowerHBox.removeItem();
upperHBox.removeItem();
But this doesn't work to my luck ,
May I know how can I avoid it creating again and again or check if items already exists remove and create a new like this..
Any help or guiding links are appreciated thanks in advance.
You can remove the items of HBox here as:
lowerHBox.removeAllItems();
upperHBox.removeAllItems();
This could remove Items which I understood is one of your Q's
link to docs:
https://sapui5.hana.ondemand.com/#/api/sap.m.HBox%23methods/Summary
I Would wait for other expert's say for more efficient way :)
i am trying to get the snippet to do this
recipes.addShaped("name", output,
[
[input,input,input],
[input,input,input],
[input,input,input]
]);
the code i am trying to use is this
"Add a shaped": {
"prefix": ["rec", "add"],
"body": ["
recipes.addShaped("${1:name}", ${2:output},
[
[${3:input},${4:input},${5:input}],
[${6:input},${7:input},${8:input}],
[${9:input},${10:input},${11:input}]
]);
"],
"description": "Add a shaped recipe."
}
any help would be appreciated.
dan
Try this:
"Add a shaped": {
"prefix": ["rec", "add"],
"body": [
"recipes.addShaped(\"${1:name}\", ${2:output},",
"[",
"[${3:input},${4:input},${5:input}],",
"[${6:input},${7:input},${8:input}],",
"[${9:input},${10:input},${11:input}]",
"]);"
],
"description": "Add a shaped recipe."
},
All lines of the body have to be separately quoted and the qoutes within a line have to be escaped.
And the result will appear flush left with your current indentation without having to put the body far left like you had it. Just indent the snippet normally to set the left point. Any indentation from there will indent the result.
So I upgraded my project, and pods, to work with Swift 2.0 and Xcode 7. But now my PieChart isn't working as expected anymore. My Pies are all starting from the 0 degree angle, which means that they are all beginning in the same place, above each other.
The data is added the same way as before and if I highlight them I can see that they are all there, but not originating from their respective places.
Code for adding my pieChartData:
var dataEntries: [ChartDataEntry] = []
var dataPoints: [String] = []
for var i = 0; i < expensesHistory.count; i++ {
let dataEntry = ChartDataEntry(value: expensesHistory[i].amount, xIndex: i)
dataEntries.append(dataEntry)
dataPoints.append(expensesHistory[i].category.rawValue)
}
let pieChartDataSet = PieChartDataSet(yVals: dataEntries)
let pieChartData = PieChartData(xVals: dataPoints, dataSet: pieChartDataSet)
pieChartView.data = pieChartData
var colors = [UIColor]()
colors.append(Colors.blueColor())
pieChartDataSet.colors = colors
pieChartDataSet.drawValuesEnabled = false
pieChartDataSet.sliceSpace = 4.0
The data gets loaded and added correctly, into different entries (there are 7) but all 7 pies are starting in the same place...so they don't result in a circle at all. Any ideas?
UPDATE #1
I translated the ChartsDemo to Swift as best I could and I end up with the same issue, but further debugging tells me that I'm probably only getting the last Entry pushed into the DataSet. If I set PieChartDataSet.drawValuesEnabled = true and PieChartView.legend.enabled = true I only see 1 value in the legend and 1 value for the DataSet. But I checked and my xVals and yVals contain more than 1 value, but it only displays one, and randomly chosen which one as well. I tried to find a pattern in which entry it chooses, but it just picks one at random.
I have added functionality to my PieChartView which allows me to press a button to highlight the entry associated with it, so that's why I thought that all the pies are placed above each other, but now I'm thinking it might be that the PieChartView is only showing 1 value, since I only get 1 value in the legend displayed, and not all of them on top of one another.
Here is my translation code from the ChartsDemo to Swift, keep in mind that I use Swift 2.0 (which is where this issue first presented itself).
private func setPieChartData() {
let mult = UInt32(100)
let count = Int(4)
let parties = [
"Party A", "Party B", "Party C", "Party D", "Party E", "Party F",
"Party G", "Party H", "Party I", "Party J", "Party K", "Party L",
"Party M", "Party N", "Party O", "Party P", "Party Q", "Party R",
"Party S", "Party T", "Party U", "Party V", "Party W", "Party X",
"Party Y", "Party Z"
]
var yVals1 = [ChartDataEntry]()
// IMPORTANT: In a PieChart, no values (Entry) should have the same xIndex (even if from different DataSets), since no values can be drawn above each other.
for var i = 0; i < count; i++
{
let chartDataEntry = ChartDataEntry(value: Double((arc4random_uniform(mult) + mult/5)), xIndex: i)
yVals1.append(chartDataEntry)
}
var xVals = [String?]()
for var i = 0; i < count; i++
{
xVals.append(parties[i % parties.count])
//[xVals addObject:parties[i % parties.count]]
}
let dataSet = PieChartDataSet(yVals: yVals1, label: "Election Results")
dataSet.sliceSpace = 3.0
// add a lot of colors
var testColors = [UIColor]()
testColors.append(Colors.blueColor())
let data = PieChartData(xVals: xVals, dataSet: dataSet)
pieChartView.data = data
dataSet.colors = testColors
dataSet.drawValuesEnabled = true
dataSet.sliceSpace = 4.0
}
Since this issue started when I updated to the Swift 2.0 compatible version of ios-charts I still think that this issue is connected to that update. I haven't touched this code in months prior to the update, and it works fine with the previous version. And as far as I can tell from a debugging point of view all my values are pushed correctly, but seems to not be handled correctly by the PieChartView.
UPDATE #2
Here is a sample project where I show you the issue I'm having. I did not include functionality for highlighting with buttons since it will take a bit more effort to get it working.
Link to sample project
How to:
You need Xcode 7 to run this.
You need CocoaPods installed.
Once you have installed CocoaPods use the terminal to go to the project folder and type "pod install" in root to install the Charts framework.
Use the ChartsIssue.xcworkspace to launch the project, NOT ChartsIssue.xcproj
I tried to simulate what your code do in ChartsDemo's pie chart view controller like below, but it does not have problem.
I looked at your code, it is also fine to me. I guess there might be something wrong with your data value, like class type? Anyway, based on current info, I cannot say what's wrong with it, but it seems like it's your project's problem.
There are two ways to move forward:
1.You double check the data value and try debug on your own, to figure out why;
2.Try to reproduce with ChartsDemo code, and post your data sample code, so I can reproduce it on my side; a screenshot is even better.
- (void)setDataCount:(int)count range:(double)range
{
double mult = range;
NSMutableArray *yVals1 = [[NSMutableArray alloc] init];
// IMPORTANT: In a PieChart, no values (Entry) should have the same xIndex (even if from different DataSets), since no values can be drawn above each other.
for (int i = 0; i < count; i++)
{
[yVals1 addObject:[[ChartDataEntry alloc] initWithValue:(arc4random_uniform(mult) + mult / 5) xIndex:i]];
}
NSMutableArray *xVals = [[NSMutableArray alloc] init];
for (int i = 0; i < count; i++)
{
[xVals addObject:parties[i % parties.count]];
}
PieChartDataSet *dataSet = [[PieChartDataSet alloc] initWithYVals:yVals1 label:#"Election Results"];
dataSet.sliceSpace = 3.0;
// add a lot of colors
NSMutableArray *colors = [[NSMutableArray alloc] init];
[colors addObject:[UIColor blueColor]];
PieChartData *data = [[PieChartData alloc] initWithXVals:xVals dataSet:dataSet];
_chartView.data = data;
dataSet.colors = colors;
dataSet.drawValuesEnabled = NO;
dataSet.sliceSpace = 4.0;
}
Update for question update 1&2:
I have download your demo project and manage to get it work on my side, I do see what you are saying, only one arc stripe while you should have 4 values;
I think you have hit an animation bug here or you mis-use it:
pieChartView.animate(xAxisDuration: 1.5, easingOption: ChartEasingOption.EaseOutBack)
pieChartView.animate(yAxisDuration: 1.5, easingOption: ChartEasingOption.EaseOutBack)
Simply comment one of them out and it will display correctly (not sure if the animation is fine), comment both will display correctly without animation too.
If you want animate both x and y axis, use below func also give you correct chart and animation:
pieChartView.animate(xAxisDuration: 1.5, yAxisDuration: 1.5, easingOption: ChartEasingOption.EaseOutBack)
I will post an issue to ask if using separate methods simultaneously is valid or not.