-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chart: add intial support for secondary axes
- Loading branch information
Showing
17 changed files
with
838 additions
and
241 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Test case that compares a file generated by rust_xlsxwriter with a file | ||
// created by Excel. | ||
// | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
// | ||
// Copyright 2022-2024, John McNamara, [email protected] | ||
|
||
use crate::common; | ||
use rust_xlsxwriter::{Chart, ChartType, Workbook, XlsxError}; | ||
|
||
// Create rust_xlsxwriter file to compare against Excel file. | ||
fn create_new_xlsx_file(filename: &str) -> Result<(), XlsxError> { | ||
let mut workbook = Workbook::new(); | ||
|
||
let worksheet = workbook.add_worksheet(); | ||
|
||
// Add some test data for the chart(s). | ||
worksheet.write_column(0, 0, [1, 2, 3, 4, 5])?; | ||
worksheet.write_column(0, 1, [6, 8, 6, 4, 2])?; | ||
|
||
let mut chart = Chart::new(ChartType::Area); | ||
// Test without chart ids | ||
|
||
chart.add_series().set_values(("Sheet1", 0, 0, 4, 0)); | ||
|
||
chart | ||
.add_series() | ||
.set_values(("Sheet1", 0, 1, 4, 1)) | ||
.set_y2_axis(true); | ||
|
||
worksheet.insert_chart(8, 4, &chart)?; | ||
|
||
workbook.save(filename)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn test_bootstrap71() { | ||
let test_runner = common::TestRunner::new() | ||
.set_name("bootstrap71") | ||
.set_function(create_new_xlsx_file) | ||
.ignore_elements("xl/workbook.xml", "<fileVersion") | ||
.initialize(); | ||
|
||
test_runner.assert_eq(); | ||
test_runner.cleanup(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Test case that compares a file generated by rust_xlsxwriter with a file | ||
// created by Excel. | ||
// | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
// | ||
// Copyright 2022-2024, John McNamara, [email protected] | ||
|
||
use crate::common; | ||
use rust_xlsxwriter::{Chart, ChartType, Workbook, XlsxError}; | ||
|
||
// Create rust_xlsxwriter file to compare against Excel file. | ||
fn create_new_xlsx_file(filename: &str) -> Result<(), XlsxError> { | ||
let mut workbook = Workbook::new(); | ||
|
||
let worksheet = workbook.add_worksheet(); | ||
|
||
// Add some test data for the chart(s). | ||
worksheet.write_column(0, 0, [1, 2, 3, 4, 5])?; | ||
worksheet.write_column(0, 1, [6, 8, 6, 4, 2])?; | ||
|
||
let mut chart = Chart::new(ChartType::Area); | ||
chart.set_axis_ids(63591168, 63592704); | ||
chart.set_axis2_ids(74921856, 73764224); | ||
|
||
chart.add_series().set_values(("Sheet1", 0, 0, 4, 0)); | ||
|
||
chart | ||
.add_series() | ||
.set_values(("Sheet1", 0, 1, 4, 1)) | ||
.set_y2_axis(true); | ||
|
||
worksheet.insert_chart(8, 4, &chart)?; | ||
|
||
workbook.save(filename)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn test_chart_area04() { | ||
let test_runner = common::TestRunner::new() | ||
.set_name("chart_area04") | ||
.set_function(create_new_xlsx_file) | ||
.ignore_elements("xl/workbook.xml", "<fileVersion") | ||
.initialize(); | ||
|
||
test_runner.assert_eq(); | ||
test_runner.cleanup(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Test case that compares a file generated by rust_xlsxwriter with a file | ||
// created by Excel. | ||
// | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
// | ||
// Copyright 2022-2024, John McNamara, [email protected] | ||
|
||
use crate::common; | ||
use rust_xlsxwriter::{Chart, ChartType, Workbook, XlsxError}; | ||
|
||
// Create rust_xlsxwriter file to compare against Excel file. | ||
fn create_new_xlsx_file(filename: &str) -> Result<(), XlsxError> { | ||
let mut workbook = Workbook::new(); | ||
|
||
let worksheet = workbook.add_worksheet(); | ||
|
||
// Add some test data for the chart(s). | ||
worksheet.write_column(0, 0, [27, 33, 44, 12, 1])?; | ||
worksheet.write_column(0, 1, [6, 8, 6, 4, 2])?; | ||
|
||
let mut chart = Chart::new(ChartType::Bar); | ||
chart.set_axis_ids(63591168, 63592704); | ||
chart.set_axis2_ids(65934464, 72628864); | ||
|
||
chart.add_series().set_values(("Sheet1", 0, 0, 4, 0)); | ||
|
||
chart | ||
.add_series() | ||
.set_values(("Sheet1", 0, 1, 4, 1)) | ||
.set_y2_axis(true); | ||
|
||
worksheet.insert_chart(8, 4, &chart)?; | ||
|
||
workbook.save(filename)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn test_chart_bar24() { | ||
let test_runner = common::TestRunner::new() | ||
.set_name("chart_bar24") | ||
.ignore_elements("xl/workbook.xml", "<fileVersion") | ||
.set_function(create_new_xlsx_file) | ||
.initialize(); | ||
|
||
test_runner.assert_eq(); | ||
test_runner.cleanup(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Test case that compares a file generated by rust_xlsxwriter with a file | ||
// created by Excel. | ||
// | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
// | ||
// Copyright 2022-2024, John McNamara, [email protected] | ||
|
||
use crate::common; | ||
use rust_xlsxwriter::{Chart, ChartType, Workbook, XlsxError}; | ||
|
||
// Create rust_xlsxwriter file to compare against Excel file. | ||
fn create_new_xlsx_file(filename: &str) -> Result<(), XlsxError> { | ||
let mut workbook = Workbook::new(); | ||
|
||
let worksheet = workbook.add_worksheet(); | ||
|
||
// Add some test data for the chart(s). | ||
worksheet.write_column(0, 0, [1, 2, 3, 4, 5])?; | ||
worksheet.write_column(0, 1, [6, 8, 6, 4, 2])?; | ||
|
||
let mut chart = Chart::new(ChartType::Column); | ||
chart.set_axis_ids(63591936, 63593856); | ||
chart.set_axis2_ids(63613568, 63612032); | ||
|
||
chart.add_series().set_values(("Sheet1", 0, 0, 4, 0)); | ||
|
||
chart | ||
.add_series() | ||
.set_values(("Sheet1", 0, 1, 4, 1)) | ||
.set_y2_axis(true); | ||
|
||
worksheet.insert_chart(8, 4, &chart)?; | ||
|
||
workbook.save(filename)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn test_chart_column04() { | ||
let test_runner = common::TestRunner::new() | ||
.set_name("chart_column04") | ||
.set_function(create_new_xlsx_file) | ||
.ignore_elements("xl/workbook.xml", "<fileVersion") | ||
.initialize(); | ||
|
||
test_runner.assert_eq(); | ||
test_runner.cleanup(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Test case that compares a file generated by rust_xlsxwriter with a file | ||
// created by Excel. | ||
// | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
// | ||
// Copyright 2022-2024, John McNamara, [email protected] | ||
|
||
use crate::common; | ||
use rust_xlsxwriter::{Chart, ChartType, Workbook, XlsxError}; | ||
|
||
// Create rust_xlsxwriter file to compare against Excel file. | ||
fn create_new_xlsx_file(filename: &str) -> Result<(), XlsxError> { | ||
let mut workbook = Workbook::new(); | ||
|
||
let worksheet = workbook.add_worksheet(); | ||
|
||
// Add some test data for the chart(s). | ||
worksheet.write_column(0, 0, [1, 2, 3, 4, 5])?; | ||
worksheet.write_column(0, 1, [6, 8, 6, 4, 2])?; | ||
|
||
let mut chart = Chart::new(ChartType::Line); | ||
chart.set_axis_ids(63593856, 63612032); | ||
chart.set_axis2_ids(63615360, 63613568); | ||
|
||
chart.add_series().set_values(("Sheet1", 0, 0, 4, 0)); | ||
|
||
chart | ||
.add_series() | ||
.set_values(("Sheet1", 0, 1, 4, 1)) | ||
.set_y2_axis(true); | ||
|
||
worksheet.insert_chart(8, 4, &chart)?; | ||
|
||
workbook.save(filename)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn test_chart_line02() { | ||
let test_runner = common::TestRunner::new() | ||
.set_name("chart_line02") | ||
.set_function(create_new_xlsx_file) | ||
.ignore_elements("xl/workbook.xml", "<fileVersion") | ||
.initialize(); | ||
|
||
test_runner.assert_eq(); | ||
test_runner.cleanup(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Test case that compares a file generated by rust_xlsxwriter with a file | ||
// created by Excel. | ||
// | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
// | ||
// Copyright 2022-2024, John McNamara, [email protected] | ||
|
||
use crate::common; | ||
use rust_xlsxwriter::{Chart, ChartType, Workbook, XlsxError}; | ||
|
||
// Create rust_xlsxwriter file to compare against Excel file. | ||
fn create_new_xlsx_file(filename: &str) -> Result<(), XlsxError> { | ||
let mut workbook = Workbook::new(); | ||
|
||
let worksheet = workbook.add_worksheet(); | ||
|
||
// Add some test data for the chart(s). | ||
worksheet.write_column(0, 0, [27, 33, 44, 12, 1])?; | ||
worksheet.write_column(0, 1, [6, 8, 6, 4, 2])?; | ||
worksheet.write_column(0, 2, [20, 10, 30, 50, 40])?; | ||
worksheet.write_column(0, 3, [0, 27, 23, 30, 40])?; | ||
|
||
let mut chart = Chart::new(ChartType::Scatter); | ||
chart.set_axis_ids(63597952, 63616128); | ||
chart.set_axis2_ids(63617664, 63619456); | ||
|
||
chart | ||
.add_series() | ||
.set_categories(("Sheet1", 0, 0, 4, 0)) | ||
.set_values(("Sheet1", 0, 1, 4, 1)); | ||
|
||
chart | ||
.add_series() | ||
.set_categories(("Sheet1", 0, 2, 4, 2)) | ||
.set_values(("Sheet1", 0, 3, 4, 3)) | ||
.set_y2_axis(true); | ||
|
||
worksheet.insert_chart(8, 4, &chart)?; | ||
|
||
workbook.save(filename)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn test_chart_scatter07() { | ||
let test_runner = common::TestRunner::new() | ||
.set_name("chart_scatter07") | ||
.set_function(create_new_xlsx_file) | ||
.ignore_elements("xl/workbook.xml", "<fileVersion") | ||
.initialize(); | ||
|
||
test_runner.assert_eq(); | ||
test_runner.cleanup(); | ||
} |
Oops, something went wrong.