Update a chart
The name and categories of a chart can be updated by posting to /charts/{chart key}.
- Text
- PHP
- C#
- Java
- Python
- Ruby
- Javascript
- Go
POST https://api-{region}.seatsio.net/charts/{chartKey}
$cat1 = ['key' => 1, 'label' => 'Category 1', 'color' => '#aaaaaa'];
$cat2 = ['key' => 2, 'label' => 'Category 2', 'color' => '#bbbbbb'];
$seatsioClient->charts->update("4250fffc-e41f-c7cb-986a-2c5e728b8c28", "New name for my chart", [$cat1, $cat2])
var category1 = new Category(1, "Category 1", "#aaaaaa");
var category2 = new Category(2, "Category 2", "#bbbbbb");
var drawing = await Client.Charts.UpdateAsync("4250fffc-e41f-c7cb-986a-2c5e728b8c28", "New name for my chart", new [] { category1, category2 });
Category category1 = new Category(1, "Category 1", "#aaaaaa");
Category category2 = new Category(2, "Category 2", "#bbbbbb");
client.charts.update("4250fffc-e41f-c7cb-986a-2c5e728b8c28", "New name for my chart", List.of(category1, category2));
client.charts.update("4250fffc-e41f-c7cb-986a-2c5e728b8c28",
new_name="New name for my chart",
categories=[
{"key": 1, "label": "Category 1", "color": "#aaaaaa"}
])
client.charts.update key: "4250fffc-e41f-c7cb-986a-2c5e728b8c28",
new_name: "New name for my chart",
categories: [
{"key": 1, "label": "Category 1", "color": "#aaaaaa"}
]
let cat1 = {'key': 1, 'label': 'Category 1', 'color': '#aaaaaa'};
let cat2 = {'key': 2, 'label': 'Category 2', 'color': '#bbbbbb'};
await client.charts.update('chartKey', 'New name for my chart', [cat1, cat2]);
category1 := events.Category{Key: events.CategoryKey{Key: 1}, Label: "Category 1", Color: "#aaaaaa"}
category2 := events.Category{Key: events.CategoryKey{Key: "anotherCat"}, Label: "Category 2", Color: "#bbbbbb"}
categories := []events.Category{category1, category2}
chart, err := client.Charts.Update('chartKey', &charts.UpdateChartParams{
Name: "New name for my chart",
Categories: categories
})
Seats.io creates a draft chart version when you update a chart. If a draft version already exists, that draft gets updated.
This does not apply to charts without events. For those charts we don't create a draft version.
Update the chart name
To update the name of a chart, send the new name in the request body. If you don't send a name, it will not change.
{
"name": "New name for my chart"
}
Update chart categories
When using the Update a Chart endpoint, you are effectively replacing all of the categories on the chart. To simply add or remove a category, you should use the Manage Categories endpoint.
To update categories, you must send an updated array of categories, for example:
[
{ "key": 1, "label": "Category 1", "color": "#aaaaaa"},
{ "key": 2, "label": "Category 2", "color": "#bbbbbb", "accessible": true}
]
The fields are:
- key: a number or a string that uniquely identifies the category in the chart. Note that when passing in a number, it cannot exceed the value of Number.MAX_SAFE_INTEGER (i.e. 2^32 = 9007199254740991)
- label: the category label, a string
- color: a valid html color
Updating categories works as follows:
- A category with a key that did not yet exist is added as a new category
- A category with an existing key is updated. The label and color you provide overwrite the old label and color.
- All other categories, which are not included in the array, are deleted. Sending an empty array of categories removes all categories.
Suppose that this is the list of existing categories:
{
"categories": [
{ "key": 1, "label": "Category 1", "color": "#aaaaaa"},
{ "key": 2, "label": "Category 2", "color": "#bbbbbb"}
]
}
and you send this update chart request:
{
"categories": [
{ "key": 2, "label": "My category 2"}
]
}
then category 1 will be deleted, the label for category 2 will be set to "My category 2", and the color of category 2 is left unchanged.
{
"categories": [
{ "key": 2, "label": "My category 2", "color": "#bbbbbb"}
]
}
curl https://api-{region}.seatsio.net/charts/4250fffc-e41f-c7cb-986a-2c5e728b8c28 \
-u aSecretKey: -X POST -H 'Content-Type: application/json' -d '{"name": "New name for my chart"}'
Response
204 - No Content