-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add step line #107
Open
cooljingle
wants to merge
1
commit into
yuankunzhang:main
Choose a base branch
from
cooljingle:step-line
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add step line #107
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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,9 @@ | ||
use serde::Serialize; | ||
|
||
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)] | ||
#[serde(rename_all = "snake_case")] | ||
pub enum Step { | ||
Start, | ||
Middle, | ||
End, | ||
} |
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
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
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
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,46 @@ | ||
use charming::{ | ||
component::{Axis, Feature, Grid, Legend, SaveAsImage, Title, Toolbox}, | ||
element::{AxisType, Step, Tooltip, Trigger}, | ||
series::Line, | ||
Chart, | ||
}; | ||
|
||
pub fn chart() -> Chart { | ||
Chart::new() | ||
.title(Title::new().text("Step Line")) | ||
.tooltip(Tooltip::new().trigger(Trigger::Axis)) | ||
.legend(Legend::new()) | ||
.grid( | ||
Grid::new() | ||
.left("3%") | ||
.right("4%") | ||
.bottom("3%") | ||
.contain_label(true), | ||
) | ||
.toolbox(Toolbox::new().feature(Feature::new().save_as_image(SaveAsImage::new()))) | ||
.x_axis( | ||
Axis::new() | ||
.type_(AxisType::Category) | ||
.boundary_gap(false) | ||
.data(vec!["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]), | ||
) | ||
.y_axis(Axis::new().type_(AxisType::Value)) | ||
.series( | ||
Line::new() | ||
.name("Step Start") | ||
.step(Step::Start) | ||
.data(vec![120, 132, 101, 134, 90, 230, 210]), | ||
) | ||
.series( | ||
Line::new() | ||
.name("Step Middle") | ||
.step(Step::Middle) | ||
.data(vec![220, 282, 201, 234, 290, 430, 410]), | ||
) | ||
.series( | ||
Line::new() | ||
.name("Step End") | ||
.step(Step::End) | ||
.data(vec![450, 432, 401, 454, 590, 530, 510]), | ||
) | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just about to create a PR with the support for this same feature =)
We could've made it fully compatible with Echarts by adding bool variants:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, although maybe I'm missing the serialization part, true and false would have to become boolean literals rather than strings, anyway, just a suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be correct. It should be fairly easy and examples of it are in the repo.
I will take a look at this PR and merge it at the start of next week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cooljingle Do you want to implement the suggestion from grinya, the implementation
From<bool>
and the correct serialization ofStep::True
andStep::False
?